Exemplo n.º 1
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable<Product> products = factoryTest.GetProducts();

            Assert.IsTrue(products != null);
        }
Exemplo n.º 2
0
        public void test_factory_mocking1()
        {
            List<Product> products = new List<Product>()
            {
                new Product() { ProductId = 1, Name = "Product1" ,Asin = "ABC" , Price = 15.5m},
                new Product() { ProductId = 2, Name = "Product2" , Asin = "ABC", Price = 55.99m}
            };

            Mock<IDataRepositoryFactory> mockDataRepository = new Mock<IDataRepositoryFactory>();
            mockDataRepository.Setup(obj => obj.GetDataRepository<IProductRepository>().Get()).Returns(products);

            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object);

            IEnumerable<Product> ret = factoryTest.GetProducts();

            Assert.IsTrue(ret == products);
        }