public void test_repository_usage() { RepositoryTestClass repositoryTest = new RepositoryTestClass(); IEnumerable <Car> cars = repositoryTest.GetCars(); Assert.IsTrue(cars != null); }
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); }