Beispiel #1
0
        public void Update_ShouldUpdateEstimateTask()
        {
            // Arrange
            int markId     = 2;
            int employeeId = 1;

            var estimateTaskRequest = new EstimateTaskUpdateRequest
            {
                TaskText           = "NewUpdate",
                AdditionalText     = "NewUpdate",
                ApprovalEmployeeId = employeeId,
            };

            // Act
            _service.Update(markId,
                            estimateTaskRequest);

            // Assert
            _repository.Verify(mock => mock.Update(It.IsAny <EstimateTask>()), Times.Once);
            Assert.Equal("NewUpdate", _estimateTask.SingleOrDefault(
                             v => v.Mark.Id == markId).TaskText);
            Assert.Equal("NewUpdate", _estimateTask.SingleOrDefault(
                             v => v.Mark.Id == markId).AdditionalText);
            Assert.Equal(employeeId, _estimateTask.SingleOrDefault(
                             v => v.Mark.Id == markId).ApprovalEmployee.Id);
        }
 public ActionResult Update(
     int markId,
     [FromBody] EstimateTaskUpdateRequest estimateTaskRequest)
 {
     if (!estimateTaskRequest.Validate())
     {
         return(BadRequest());
     }
     try
     {
         _service.Update(markId, estimateTaskRequest);
     }
     catch (ArgumentNullException)
     {
         return(NotFound());
     }
     return(NoContent());
 }