public async Task <bool> TestFor_RemoveProduct()
        {
            //Arrange
            var res = false;

            //Action
            groceryservice.Setup(repos => repos.RemoveProduct(_product.ProductId)).ReturnsAsync(true);
            var resultDelete = await _groceryS.RemoveProduct(_product.ProductId);

            //Assertion
            if (resultDelete == true)
            {
                res = true;
            }
            //final result displaying in text file
            await File.AppendAllTextAsync("../../../../output_revised.txt", "TestFor_RemoveProduct=" + res + "\n");

            return(res);
        }
Пример #2
0
        public async Task <IActionResult> RemoveProduct(string ProductId)
        {
            if (ProductId == null)
            {
                return(BadRequest());
            }
            try
            {
                var result = await _groceryServices.RemoveProduct(ProductId);

                if (result == false)
                {
                    return(NotFound());
                }
                return(Ok("Product Deleted"));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
        public async Task <bool> Testfor_Validate_InValid_RemoveProduct()
        {
            //Arrange
            var res         = false;
            var _productdel = new Product()
            {
            };

            //Action
            groceryservice.Setup(repos => repos.RemoveProduct(_productdel.ProductId)).ReturnsAsync(true);
            var result = await _groceryS.RemoveProduct(_productdel.ProductId);

            if (result == true)
            {
                res = true;
            }
            //Assert
            //final result displaying in text file
            await File.AppendAllTextAsync("../../../../output_exception_revised.txt", "Testfor_Validate_InValid_RemoveProduct=" + res + "\n");

            return(res);
        }