public void IndexPOST_GivenValidModelAndOptionClicked_UpdateQuestionViewModelShouldBeCalled() { var assessmentId = Guid.NewGuid(); var optionId = Guid.NewGuid(); var model = new QuestionViewModel() { AssessmentId = assessmentId }; _questionController.Index(model, false, optionId, A <Guid> ._); A.CallTo(() => _questionViewModelBuilder.UpdateQuestionViewModel(model, optionId)).MustHaveHappened(Repeated.Exactly.Once); }
public virtual ActionResult Index(QuestionViewModel model, bool?continueButton, Guid?chosenOption, Guid assessmentId) { if (ModelState.IsValid) { if (ContinueClicked(continueButton)) { if (model.ChosenOption.HasValue) { var status = _workflowHandler.SetAssessmentNextStep(model.AssessmentId, model.ChosenOption.Value, model.FurtherInformationAnswer); var actionResult = RedirectAssessment(model, status); if (Request.IsAjaxRequest()) { return(Json(new { Redirect = _urlHelper.RouteUrl(actionResult.RouteValues) })); } return(actionResult); } } } if (OptionClicked(chosenOption)) { model = _questionViewModelBuilder.UpdateQuestionViewModel(model, chosenOption.Value); ModelState.Remove("DisplayFurtherInformationQuestion"); } if (Request.IsAjaxRequest()) { return(Json(new { Html = _partialViewRenderer.RenderPartialViewToString(ControllerContext, ViewData, TempData, MVC.Question.Views._OptionsPartial, model), Valid = ModelState.IsValid })); } return(View(model)); }