예제 #1
0
        public async Task <IActionResult> AddNewCategory([FromBody] CategoryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Category newcategory = new Category
            {
                Title           = model.Title,
                Url             = model.Url,
                OpenInNewWindow = model.OpenInNewWindow
            };
            await _groceryServices.AddCategory(newcategory);

            return(Ok("New Category Addeed..."));
        }
        public async Task <bool> Testfor_Validate_ValidAddCategory()
        {
            //Arrange
            bool res = false;

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

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

            return(res);
        }