public string CreateProduct(Product product) { if (!repo.AddProduct(product)) { return("Error: Database write failed"); } return(null); }
[InlineData("A1=?")] // mix public void AddProductShouldAddProduct(string productName) { using (var createCtx = new StoreContext(options)) { StoreRepoDB repo = new StoreRepoDB(createCtx); Product testProduct = new Product(); testProduct.ProductName = productName; testProduct.ProductPrice = 1; repo.AddProduct(testProduct); createCtx.SaveChanges(); } using (var assertCtx = new StoreContext(options)) { var result = assertCtx.Products.FirstOrDefault(user => user.ProductName == productName); Assert.NotNull(result); Assert.Equal(productName, result.ProductName); } }