Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable<Car> cars = factoryTest.GetCars();

            Assert.IsTrue(cars != null);
        }
Esempio n. 3
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

            IEnumerable <Car> cars = factoryTest.GetCars();

            Assert.IsTrue(cars != null);
        }
Esempio n. 4
0
        public void test_factory_mocking1()
        {
            List<Car> cars = new List<Car>(){
                new Car() { CarId = 1, Description = "Mustang" },
                new Car() { CarId = 2, Description = "Corvette" }
            };

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

            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object);

            IEnumerable<Car> ret = factoryTest.GetCars();

            Assert.IsTrue(ret == cars);
        }