public void test_factory_mocking2() { List <Supplier> suppliers = new List <Supplier>() { new Supplier() { Id = 1, Name = "Supplier One" }, new Supplier() { Id = 2, Name = "Supplier Two" } }; Mock <ISupplierRepository> mockSupplierRepository = new Mock <ISupplierRepository>(); mockSupplierRepository.Setup(obj => obj.Get()).Returns(suppliers); Mock <IDataRepositoryFactory> mockDataRepository = new Mock <IDataRepositoryFactory>(); mockDataRepository.Setup(obj => obj.GetDataRepository <ISupplierRepository>()).Returns(mockSupplierRepository.Object); RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object); IEnumerable <Supplier> ret = factoryTest.GetSuppliers(); Assert.AreEqual(ret, suppliers); }
public void test_repository_factory_usage() { RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(); IEnumerable <Supplier> suppliers = factoryTest.GetSuppliers(); Assert.IsTrue(suppliers != null); }
public void test_repository_factory_usage() { RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(); IEnumerable<Supplier> suppliers = factoryTest.GetSuppliers(); Assert.IsTrue(suppliers != null); }
public void test_factory_mocking1() { List<Supplier> suppliers = new List<Supplier>() { new Supplier() { Id = 1, Name = "Supplier One" }, new Supplier() { Id = 2, Name = "Supplier Two" } }; Mock<IDataRepositoryFactory> mockDataRepository = new Mock<IDataRepositoryFactory>(); mockDataRepository.Setup(obj => obj.GetDataRepository<ISupplierRepository>().Get()).Returns(suppliers); RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object); IEnumerable<Supplier> ret = factoryTest.GetSuppliers(); Assert.AreEqual(ret, suppliers); }