public async Task <bool> Testfor_Validate_UpdateCategory()
        {
            //Arrange
            bool res             = false;
            var  _categoryUpdate = new Category()
            {
                Id              = "5f0ff60a7b7be11c4c3c19e1",
                CatId           = 1,
                Url             = "~/Home",
                OpenInNewWindow = false
            };

            //Act
            groceryservice.Setup(repo => repo.UpdateCategory(_categoryUpdate.Id, _categoryUpdate)).ReturnsAsync(_categoryUpdate);
            var result = await _groceryS.UpdateCategory(_categoryUpdate.Id, _categoryUpdate);

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

            return(res);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Updatecategory(string Id, [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var getcategory = _groceryServices.GetCategoryById(Id);

            if (getcategory == null)
            {
                return(NotFound());
            }
            await _groceryServices.UpdateCategory(Id, category);

            return(Ok("Category Updated..."));
        }