public void test_factory_mocking2() { List <Car> cars = new List <Car>() { new Car() { CarId = 1, Description = "Mustang" }, new Car() { CarId = 2, Description = "Corvette" } }; Mock <ICarRepository> mockCarRepository = new Mock <ICarRepository>(); mockCarRepository.Setup(obj => obj.Get()).Returns(cars); Mock <IDataRepositoryFactory> mockDataRepository = new Mock <IDataRepositoryFactory>(); mockDataRepository.Setup(obj => obj.GetDataRepository <ICarRepository>()).Returns(mockCarRepository.Object); RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object); IEnumerable <Car> ret = factoryTest.GetCars(); Assert.IsTrue(ret == cars); }
public void test_repository_factory_usage() { RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(); IEnumerable <Car> cars = factoryTest.GetCars(); Assert.IsTrue(cars == null); }