Skip to content

Instantly share code, notes, and snippets.

@SlyNet
Created July 4, 2011 18:10
Show Gist options
  • Save SlyNet/1063732 to your computer and use it in GitHub Desktop.
Save SlyNet/1063732 to your computer and use it in GitHub Desktop.
Faking the repository
public static class RepositoryFakes
{
public static IRepository<T> AsRepository<T>(this IList<T> list) where T : Entity
{
IQueryable<T> queryable = list.AsQueryable();
return Mock.Of<IRepository<T>>(x => x.Expression == queryable.Expression
&& x.ElementType == queryable.ElementType
&& x.Provider == queryable.Provider);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment