Exemplo n.º 1
0
        public void TasksController_Update_ReturnsBadRequestResult_WhenTaskIsNull()
        {
            //Arrange
            TaskHouseApi.Model.Task task = null;
            int id = 0;

            //Act
            var result = controller.Update(id, task);

            //Assert
            Assert.IsType <BadRequestResult>(result);
            //inconsistencies across tests in whether it returns BadRequestResult or BadRequestObjectResult
        }
Exemplo n.º 2
0
        public void TasksController_Create_ReturnsBadRequest_WhenGivenNullTask()
        {
            //Arrange
            TaskHouseApi.Model.Task task = null;

            controller = createContext(controller, "Employer");

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

            //Assert
            Assert.IsType <BadRequestObjectResult>(result);
            //Major inconsistencies in whether is return BadRequestResult or BadRequestObjectResult
        }
Exemplo n.º 3
0
        public void TasksController_Update_ReturnsNotFoundResult_WhenParametersAreValidButTaskDoesNotExist()
        {
            //Arrange
            TaskHouseApi.Model.Task task = new TaskHouseApi.Model.Task()
            {
                Id          = 10,
                Description = "Task1"
            };
            int id = 10;

            //Act
            var result = controller.Update(id, task);

            //Assert
            Assert.IsType <NotFoundResult>(result);
        }
Exemplo n.º 4
0
        public void TasksController_Create_ReturnsObjectResultContainingCreatedTask_WhenGivenValidTask()
        {
            //Arrange
            TaskHouseApi.Model.Task task = new TaskHouseApi.Model.Task();
            task.UrgencyString = "norush";

            controller = createContext(controller, "Employer");

            task.Description = "TestTask";

            //Act
            var result = controller.Create(task);
            var createdResultObject = result as ObjectResult;
            var createdTask         = createdResultObject.Value as TaskHouseApi.Model.Task;

            //Assert
            Assert.IsType <ObjectResult>(result);
            Assert.Equal(task.Description, createdTask.Description);
        }
Exemplo n.º 5
0
        public void TasksController_Update_ReturnsNoContentResultAndCreatedObject_WhenParametersAreValid()
        {
            //Arrange
            TaskHouseApi.Model.Task task = new TaskHouseApi.Model.Task()
            {
                Id            = 1,
                Description   = "UpdatedTask",
                UrgencyString = "asap"
            };
            int id = 1;

            //Act
            var result = controller.Update(id, task);
            var updatedResultObject = controller.Get(id) as ObjectResult;
            var updatedTask         = updatedResultObject.Value as TaskHouseApi.Model.Task;

            //Assert
            Assert.IsType <NoContentResult>(result);
            Assert.Equal(updatedTask.Description, task.Description);
        }