public void MockDataList() { var personList = PersonList().AsQueryable(); var personDbSetMock = new Mock <DbSet <Customer> >(); personDbSetMock.As <IQueryable <Customer> >() .Setup(m => m.Provider) .Returns(personList.Provider); personDbSetMock.As <IQueryable <Customer> >() .Setup(m => m.Expression) .Returns(personList.Expression); personDbSetMock.As <IQueryable <Customer> >() .Setup(m => m.ElementType) .Returns(personList.ElementType); personDbSetMock.As <IQueryable <Customer> >() .Setup(m => m.GetEnumerator()) .Returns(personList.GetEnumerator()); var webContextMock = new Mock <ContextoWebDb>(); webContextMock.Setup(m => m.Customer). Returns(personDbSetMock.Object); webContextMock.Setup(m => m.Set <Customer>()). Returns(personDbSetMock.Object); var repositorio = new BaseRepositorio <Customer>(webContextMock.Object); var personGetByID = repositorio .ObtenerId(p => p.FirstName == "Name1"); personGetByID.Should().NotBeNull(); }