private async void Task5_Delete_JobType_OkResult() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); var jobType = new JobType() { JobTitle = "New and Del title", }; //Act var resultCreate = await _controller.PostJobType(jobType); var okResult = resultCreate.Should().BeOfType <CreatedAtActionResult>().Subject; var resClient = okResult.Value.Should().BeAssignableTo <JobType>().Subject; int delId = resClient.JobId; var result = await _controller.DeleteJobType(delId); //Assert Assert.IsType <OkObjectResult>(result); }
public async void Task3_Post_NewJobType_JobTitle() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); var jobType = new JobType() { JobTitle = "Mechanic", }; //Act var result = await _controller.PostJobType(jobType); //Assert var okResult = result.Should().BeOfType <CreatedAtActionResult>().Subject; var resClient = okResult.Value.Should().BeAssignableTo <JobType>().Subject; resClient.JobTitle.Should().Be("Mechanic"); //delete JayNew int newId = _context.JobType.FirstOrDefault(p => p.JobTitle == "Mechanic").JobId; var resultDelete = await _controller.DeleteJobType(newId); }