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

Unit testable LINQ extensions #1125

Closed
HarshaliRaka opened this issue Jan 2, 2020 · 1 comment
Closed

Unit testable LINQ extensions #1125

HarshaliRaka opened this issue Jan 2, 2020 · 1 comment
Labels

Comments

@HarshaliRaka
Copy link

I am using LINQ extensions MaxAsync and CountAsync in my code. Is there a way for me to Unit test it?
I see comments here and here which say it is very difficult to mock extensions. If you can help with any other way of doing it, it will be really helpful.

Thanks!

@j82w
Copy link
Contributor

j82w commented Jan 3, 2020

The easiest solution is create a wrapper as explained in this issue you already have linked.

The other solution is mocking Container.GetItemLinqQueryable and return a List . When you call CountAsync it will just call the List.Count method. The downside to this is it won't support any of the inner linq extensions like IsDefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants