public void test_repository_factory_usage() { var factoryTest = new RepositoryFactoryTestClass(); Product[] products = factoryTest.GetProducts(); Assert.IsTrue(products != null); }
public void test_factory_mocking2() { var products = new List <Product> { new Product { ProductId = 1, Name = "Mustang" }, new Product { ProductId = 2, Name = "Corvette" } }; Product[] array = products.ToArray(); var mockProductRepository = Substitute.For <IProductRepository>(); mockProductRepository.GetAll().Returns(array); var mockedDataRepository = Substitute.For <IDataRepositoryFactory>(); mockedDataRepository.GetDataRepository <IProductRepository>().Returns(mockProductRepository); var repositoryFactory = new RepositoryFactoryTestClass(mockedDataRepository); Product[] productsReturn = repositoryFactory.GetProducts(); Assert.IsTrue(array == productsReturn); }