Skip to content

Instantly share code, notes, and snippets.

@testfirstcoder
Created June 14, 2016 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save testfirstcoder/edd7a3561a8e9403395a136e4d32e2c7 to your computer and use it in GitHub Desktop.
Save testfirstcoder/edd7a3561a8e9403395a136e4d32e2c7 to your computer and use it in GitHub Desktop.
Mock IQueryable with NSubstitute
public static class IQueryableMockExtensions
{
public static void SetUp<T>(this T self, IQueryable queryable) where T : IQueryable
{
self.GetEnumerator().Returns(queryable.GetEnumerator());
self.ElementType.Returns(queryable.ElementType);
self.Expression.Returns(queryable.Expression);
self.Provider.Returns(queryable.Provider);
}
}
@michael-freidgeim-webjet

I just found the gist on Google. Can you give any examples how to use them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment