예제 #1
0
        public void SkillsController_Create_ReturnsBadRequest_WhenGivenNullSkill()
        {
            //Arrange
            Skill skill = null;

            //Act
            var result = controller.Create(skill);

            //Assert
            Assert.IsType <BadRequestObjectResult>(result);
            //Major inconsistencies in whether is return BadRequestResult or BadRequestObjectResult
        }
예제 #2
0
        public void SkillsController_Create_ReturnsObjectResultContainingCreatedSkill_WhenGivenValidSkill()
        {
            controller = createContext(controller);
            //Arrange
            Skill skill = new Skill()
            {
                Id    = 1,
                Title = "Skill1"
            };

            //Act
            var result = controller.Create(skill);
            var createdResultObject = result as ObjectResult;
            var createdSkill        = createdResultObject.Value as Skill;

            //Assert
            Assert.IsType <ObjectResult>(result);
            Assert.Equal(createdSkill.Title, skill.Title);
            Assert.Equal(createdSkill.Id, skill.Id);
        }