Esempio n. 1
0
        public void test_repository_usage()
        {
            RepositoryTestClass repositoryTest = new RepositoryTestClass();

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

            Assert.IsTrue(cars != null);
        }
Esempio n. 2
0
        public void test_repository_mocking()
        {
            List <Car> cars = new List <Car>()
            {
                new Car()
                {
                    CarId = 1, Description = "Mustang"
                },
                new Car {
                    CarId = 2, Description = "Corvet"
                }
            };
            Mock <ICarRepository> mockCarRepository = new Mock <ICarRepository>();

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

            RepositoryTestClass repositoryTest = new RepositoryTestClass(mockCarRepository.Object);

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

            Assert.IsTrue(ret == cars);
        }