示例#1
0
        public void test_repository_factory_mocking2()
        {
            var cars = new List <Car>()
            {
                new Car()
                {
                    CarId = 1, Description = "Mustang"
                },
                new Car()
                {
                    CarId = 2, Description = "Corvette"
                }
            };

            var mockCarRepository = new Mock <ICarRepository>();

            mockCarRepository.Setup(m => m.Get()).Returns(cars);

            var mockDataRepositoryFactory = new Mock <IDataRepositoryFactory>();

            mockDataRepositoryFactory.Setup(m => m.GetDataRepository <ICarRepository>()).Returns(mockCarRepository.Object);

            var repositoryFactoryTest = new RepositoryFactoryTestClass(mockDataRepositoryFactory.Object);

            var result = repositoryFactoryTest.GetCars();

            Assert.IsTrue(result == cars);
        }
        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);
        }
示例#3
0
        public void Test_repository_factory_usage()
        {
            RepositoryFactoryTestClass repositoryFactoryTestClass = new RepositoryFactoryTestClass();
            IEnumerable <Car>          cars = repositoryFactoryTestClass.GetCars();

            Assert.IsTrue(cars != null);
        }
示例#4
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factory = new RepositoryFactoryTestClass();
            IEnumerable <Car>          cars    = factory.GetCars();

            Assert.IsNotNull(cars);
        }
示例#5
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass repositoryTest = new RepositoryFactoryTestClass();
            var cars = repositoryTest.GetCars();

            Assert.IsTrue(cars != null);
        }
示例#6
0
        public void test_repository_factory_usage()
        {
            var factoryTest = new RepositoryFactoryTestClass();

            var cars = factoryTest.GetCars();

            Assert.IsTrue(cars != null);
        }
示例#7
0
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass factoryTest = new RepositoryFactoryTestClass();

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

            Assert.IsTrue(cars != null, "Cars list cant be null");
        }
        public void test_repository_factory_usage()
        {
            RepositoryFactoryTestClass repositoryTest = new RepositoryFactoryTestClass();

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

            Assert.IsTrue(cars != null);
        }
示例#9
0
        public void test_repository_factory_usage()
        {
            // Arrange
            var repositoryFactory = new RepositoryFactoryTestClass();

            // Act
            var cars = repositoryFactory.GetCars();

            // Assert
            Assert.IsNotNull(cars);
        }
示例#10
0
        public void test_repository_factory_mocking1()
        {
            var cars = new List<Car>()
            {
                new Car() { CarId = 1, Description = "Mustang"},
                new Car() { CarId = 2, Description = "Corvette"}
            };

            var mockDataRepositoryFactory = new Mock<IDataRepositoryFactory>();
            mockDataRepositoryFactory.Setup(m => m.GetDataRepository<ICarRepository>().Get()).Returns(cars);

            var repositoryFactoryTest = new RepositoryFactoryTestClass(mockDataRepositoryFactory.Object);

            var result = repositoryFactoryTest.GetCars();

            Assert.IsTrue(result == cars);
        }
        public void test_repository_factory_mockup()
        {
            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 repositoryTest = new RepositoryFactoryTestClass(mockDataRepository.Object);

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

            Assert.IsTrue(ret == cars);
        }
示例#12
0
        public void test_repository_factory_mocking()
        {
            List <Car> cars = new List <Car>()
            {
                new Car {
                    CarId = 1, Description = "Mustang"
                },
                new Car {
                    CarId = 2, Description = "Vaz"
                }
            };
            Mock <IDataRepositoryFactory> mock = new Mock <IDataRepositoryFactory>();

            mock.Setup(obj => obj.GetDataRepository <ICarRepository>().Get()).Returns(cars);
            RepositoryFactoryTestClass factory = new RepositoryFactoryTestClass(mock.Object);
            IEnumerable <Car>          dcars   = factory.GetCars();

            Assert.IsTrue(cars == dcars);
        }
示例#13
0
        public void test_repository_factory_mocking()
        {
            // Arrange
            var repositoryFactory = new Mock <IDataRepositoryFactory>();

            var cars = new List <Car>
            {
                new Car {
                    CarId = 1, Description = "Car1"
                },
                new Car {
                    CarId = 2, Description = "Car2"
                }
            };

            repositoryFactory.Setup(x => x.GetDataRepository <ICarRepository>().Get()).Returns(cars);

            var repositoryFactoryTest = new RepositoryFactoryTestClass(repositoryFactory.Object);
            // Act
            var actual = repositoryFactoryTest.GetCars();

            // Assert
            Assert.AreSame(cars, actual);
        }