private async void Task5_Delete_Category_OkResult() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new CodeCategoriesController(_context); var category = new CodeCategory() { CategoryName = "New and Del Pickle", }; //Act var resultCreate = await _controller.PostCodeCategory(category); var okResult = resultCreate.Should().BeOfType <CreatedAtActionResult>().Subject; var resClient = okResult.Value.Should().BeAssignableTo <CodeCategory>().Subject; int delId = resClient.CategoryId; var result = await _controller.DeleteCodeCategory(delId); //Assert Assert.IsType <OkObjectResult>(result); }
public async void Task3_Post_NewCategory_FindName() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new CodeCategoriesController(_context); var category = new CodeCategory() { CategoryName = "NewPickle", }; //Act var result = await _controller.PostCodeCategory(category); //Assert var okResult = result.Should().BeOfType <CreatedAtActionResult>().Subject; var resClient = okResult.Value.Should().BeAssignableTo <CodeCategory>().Subject; resClient.CategoryName.Should().Be("NewPickle"); //delete JayNew int newId = _context.CodeCategory.FirstOrDefault(p => p.CategoryName == "NewPickle").CategoryId; var resultDelete = await _controller.DeleteCodeCategory(newId); }