public void GetByIdMethodTest() { List <TestEntity> data = new List <TestEntity>() { new TestEntity() { ID = 1, Field1 = "111", Field2 = true }, new TestEntity() { ID = 2, Field1 = "222", Field2 = false } }; _fakeCollection.FindById(1).Returns(data[0]); _fakeCollection.FindById(2).Returns(data[1]); _fakeDbWrapper.Execute <TestEntity>(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Func <ICollectionWrapper <TestEntity>, TestEntity> >()) .Returns(x => ((Func <ICollectionWrapper <TestEntity>, TestEntity>)x[2]).Invoke(_fakeCollection)); TestEntity result = _sut.GetById(2); Assert.IsNotNull(result); Assert.AreSame(data[1], result); }