Skip to content

Support: Add interface to create ODataQueryOptions via a mock framework #1645

Open
@ynauls

Description

@ynauls

Add interface/support to unit test ODataQueryOptions with a mock framework. I implemented logic using the following sample from here Server-Driven Paging. The code works, however, i am unable to unit test due to complexity of creating ODataQueryOptions

public PageResult<Product> Get(ODataQueryOptions<Product> options)
{
    ODataQuerySettings settings = new ODataQuerySettings()
    {
        PageSize = 5
    };

    IQueryable results = options.ApplyTo(_products.AsQueryable(), settings);

    return new PageResult<Product>(
        results as IEnumerable<Product>, 
        Request.GetNextPageLink(), 
        Request.GetInlineCount());
}

Assemblies affected

Microsoft.AspNet.OData.Query (7.0.1)

Reproduce steps

Create unit test sample outside "Microsoft.AspNet.OData" package.

Expected result

Able to easily create unit test for logic passing in a ODataQueryOptions

Actual result

unable to create unit tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions