Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ynauls opened this issue Oct 16, 2018 · 2 comments · May be fixed by #2215
Open

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

ynauls opened this issue Oct 16, 2018 · 2 comments · May be fixed by #2215
Labels
Milestone

Comments

@ynauls
Copy link

ynauls commented Oct 16, 2018

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

@freeranger
Copy link
Contributor

@ynauls #1352 (comment) may help you with your unit testing - not nice, but it works :)

@ynauls
Copy link
Author

ynauls commented Oct 17, 2018

@freeranger, thank you, i saw that earlier and it works. I would def like some support out of the box :)

@madansr7 madansr7 added this to the vNext milestone Oct 19, 2018
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jun 29, 2020
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jun 29, 2020
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jun 30, 2020
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jun 30, 2020
OData#1645 unit test added and all unit tests passing
@kccarter76 kccarter76 mentioned this issue Jun 30, 2020
2 tasks
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jul 1, 2020
@kccarter76 kccarter76 linked a pull request Jul 1, 2020 that will close this issue
2 tasks
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jul 1, 2020
kccarter76 added a commit to kccarter76/WebApi that referenced this issue Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants