public void Should_ReturnAllProducts_When_GetAllIsCalled() { var dbContext = DBContextMocker.GetMockedProductDbContext("productDB"); var productRepository = new ProductRepository(dbContext); var allProducts = productRepository.GetAll().AsEnumerable <Product>().ToList(); Assert.NotEmpty(allProducts); }
public void Should_Not_ReturnCorrectProduct_When_GetByIdIsCalled(int id, string code) { var dbContext = DBContextMocker.GetMockedProductDbContext("productDB"); var productRepository = new ProductRepository(dbContext); var matchedProduct = productRepository.GetById(id).Result; Assert.NotNull(matchedProduct); Assert.Equal(id, matchedProduct.ProductID); Assert.NotEqual(code, matchedProduct.Code); }