public void test_repository_usage() { RepositoryTestClass repositoryTest = new RepositoryTestClass(); IEnumerable<Product> products = repositoryTest.GetProducts(); Assert.IsTrue(products != null); }
public void test_repository_mocking() { 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> mockProductrRepository = new Mock<IProductRepository>(); mockProductrRepository.Setup(obj => obj.Get()).Returns(products); RepositoryTestClass repositoryTest = new RepositoryTestClass(mockProductrRepository.Object); IEnumerable<Product> ret = repositoryTest.GetProducts(); Assert.IsTrue(ret == products); }