public async Task <bool> Testfor_Validate_UpdateProduct() { //Arrange bool res = false; var _updateproduct = new Product() { ProductId = "5f45df48ff7f1df2085ec8fd", ProductName = "Samsung", Description = "Procesor i9, 2 GB, 32 GB SSD, Corning Grollia Glass", Amount = 24900.0, stock = 10, photo = "", CatId = 1 }; //Act groceryservice.Setup(repo => repo.UpdateProduct(_updateproduct.ProductId, _updateproduct)).ReturnsAsync(_updateproduct); var result = await _groceryS.UpdateProduct(_updateproduct.ProductId, _updateproduct); if (result == _updateproduct) { res = true; } //Asert //final result displaying in text file await File.AppendAllTextAsync("../../../../output_revised.txt", "Testfor_Validate_UpdateProduct=" + res + "\n"); return(res); }
public async Task <IActionResult> UpdateProduct(string ProductId, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest()); } var getproduct = _groceryServices.GetProductById(ProductId); if (getproduct == null) { return(NotFound()); } await _groceryServices.UpdateProduct(ProductId, product); return(Ok("Product Updated...")); }