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
            adminservice.Setup(repo => repo.UpdateProduct(_updateproduct.ProductId, _updateproduct)).ReturnsAsync(_updateproduct);
            var result = await _adminGroceryS.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);
        }
Exemple #2
0
        public async Task <IActionResult> UpdateProduct(string ProductId, [FromBody] Product product)
        {
            //Do code here
            if (ProductId is null)
            {
                return(NotFound("Product Id not found"));
            }

            Task <Product> up_pro = _adminGS.UpdateProduct(ProductId, product);

            if (up_pro.Result is null)
            {
                return(Ok("Make sure ProductId and Product is correct"));
            }
            return(Ok("Updated"));
        }