示例#1
0
        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);
        }
示例#2
0
        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);
        }