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

            //Act
            groceryservice.Setup(repo => repo.AddProduct(_product)).ReturnsAsync(_product);
            var result = await _groceryS.AddProduct(_product);

            if (result != null)
            {
                res = true;
            }
            //Asert
            //final result displaying in text file
            await File.AppendAllTextAsync("../../../../output_revised.txt", "Testfor_Validate_AddValidProduct=" + res + "\n");

            return(res);
        }
示例#2
0
        public async Task <IActionResult> AddNewProduct([FromBody] ProductViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Product newproduct = new Product
            {
                ProductName = model.ProductName,
                Description = model.Description,
                Amount      = model.Amount,
                stock       = model.stock,
                photo       = model.photo,
                CatId       = model.CatId
            };
            await _groceryServices.AddProduct(newproduct);

            return(Ok("Product Addeed..."));
        }