Exemple #1
0
        public void test_repository_factory_Resources()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable<ResourceMaster> resources = factoryTest.GetResources();

            Assert.IsTrue(resources != null);
        }
Exemple #2
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

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

            Assert.IsTrue(products != null);
        }
Exemple #3
0
        public void test_repository_factory_countryCultureCodes()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable<CultureCountryCode> cultureCountryCodes = factoryTest.GetCultureCountryCodes();

            var countries = cultureCountryCodes.Select(e => e.Country).Distinct().ToList();

            var cultures = cultureCountryCodes.Select(e => e.CultureInfoCode).Distinct().ToList();

            Assert.IsTrue(cultureCountryCodes != null);
        }
Exemple #4
0
        public void test_factory_mocking2()
        {
            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<IProductRepository> mockProductRepository = new Mock<IProductRepository>();
            mockProductRepository.Setup(obj => obj.Get()).Returns(products);

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

            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object);

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

            Assert.IsTrue(ret == products);
        }