public void When_CheckFireRiskAssessmentHasOutstandingFurtherControlMeasureTasks_Then_should_call_correct_methods()
        {
            // Given
            var target = GetTarget();
            var viewModel = new DoesAnswerHaveFurtherControlMeasureTasksViewModel
                                {
                                    FireChecklistId = _fireChecklistId,
                                    FireQuestionId = _fireQuestionId
                                };

            _fireRiskAssessmentFurtherControlMeasureTaskService
              .Setup(x => x.GetFurtherControlMeasureTaskCountsForAnswer(It.Is<GetFurtherControlMeasureTaskCountsForAnswerRequest>(
                                                                          y => y.FireChecklistId == viewModel.FireChecklistId &&
                                                                               y.FireQuestionId == viewModel.FireQuestionId
                                                                          ))).Returns(new GetFurtherControlMeasureTaskCountsForAnswerResponse() );

            // When
            target.CheckFireAnswerCanBeChanged(viewModel);

            // Then
            _fireRiskAssessmentFurtherControlMeasureTaskService
                .VerifyAll();
        }
        public void Given_tasks_exist_When_CheckFireRiskAssessmentHasOutstandingFurtherControlMeasureTasks_Then_should_return_correct_results()
        {
            // Given
            var target = GetTarget();
            var viewModel = new DoesAnswerHaveFurtherControlMeasureTasksViewModel
            {
                FireChecklistId = _fireChecklistId,
                FireQuestionId = _fireQuestionId
            };

            _fireRiskAssessmentFurtherControlMeasureTaskService
                .Setup(x => x.GetFurtherControlMeasureTaskCountsForAnswer(It.IsAny<GetFurtherControlMeasureTaskCountsForAnswerRequest>()))
                .Returns(new GetFurtherControlMeasureTaskCountsForAnswerResponse
                             {
                                 TotalFurtherControlMeasureTaskCount = 1
                             });

            // When
            var result = target.CheckFireAnswerCanBeChanged(viewModel) as JsonResult;

            // Then
            Assert.That(result.Data.ToString(), Contains.Substring("CanBeChanged = False"));
        }
 public JsonResult CheckFireAnswerCanBeChanged(DoesAnswerHaveFurtherControlMeasureTasksViewModel viewModel)
 {
     var response = _furtherControlMeasureTaskService
                                 .GetFurtherControlMeasureTaskCountsForAnswer(new GetFurtherControlMeasureTaskCountsForAnswerRequest
                                                                                                                     {
                                                                                                                         FireChecklistId = viewModel.FireChecklistId,
                                                                                                                         FireQuestionId = viewModel.FireQuestionId
                                                                                                                     });
     return Json(
         new
             {
                 CanBeChanged = response.TotalFurtherControlMeasureTaskCount == 0,
                 CanBeDeleted = response.TotalCompletedFurtherControlMeasureTaskCount == 0
             }, JsonRequestBehavior.AllowGet);
 }