private void AddWidgetProperties(ContactAdviserViewModel model) { model.Title = Title; model.Hint = PersonalInformation; model.NextPage = NextPage; model.CharacterLimit = CharacterLimit; }
public ActionResult Index(ContactAdviserViewModel model) { if (ModelState.IsValid) { var mappedModel = mapper.Map(model, sessionStorage.Get()); sessionStorage.Save(mappedModel); return(Redirect($"{NextPage}")); } AddWidgetProperties(model); return(View("Index", model)); }
public ActionResult Index() { if (!context.IsContentAuthoringSite) { var sessionModel = sessionStorage.Get(); if (sessionModel is null || sessionModel.ContactUsOption?.ContactOptionType != ContactOption.ContactAdviser) { return(Redirect(ContactOptionPage)); } } var model = new ContactAdviserViewModel(); AddWidgetProperties(model); return(View("Index", model)); }
public void Dfc7630ContactAdviserViewTests() { // Arrange var contactAdviserIndex = new _MVC_Views_ContactAdviser_Index_cshtml(); var contactAdviserViewModel = new ContactAdviserViewModel { Title = nameof(ContactAdviserViewModel.Title) }; // Act var htmlDocument = contactAdviserIndex.RenderAsHtml(contactAdviserViewModel); // Assert AssertTagInnerTextValue(htmlDocument, contactAdviserViewModel.Title, "h1"); AssertFormGroupsCounts(htmlDocument, 3); AssertRadioGroupsCounts(htmlDocument, 5); }
public void SubmitTests(bool modelStateValid) { //Assign var postModel = new ContactAdviserViewModel(); A.CallTo(() => fakeSessionStorage.Get()).Returns(new ContactUs()); var controller = new ContactAdviserController(fakeApplicationLogger, fakeMapper, fakeWebAppcontext, fakeSessionStorage) { Title = nameof(ContactAdviserController.Title) }; if (!modelStateValid) { controller.ModelState.AddModelError(nameof(ContactAdviserViewModel.ContactAdviserQuestionType), nameof(ContactAdviserViewModel.Message)); } else { A.CallTo(() => fakeSessionStorage.Save(A <ContactUs> ._)).DoesNothing(); } //Act var controllerResult = controller.WithCallTo(contrl => contrl.Index(postModel)); //Assert if (modelStateValid) { controllerResult.ShouldRedirectTo(controller.NextPage); } else { controllerResult.ShouldRenderDefaultView() .WithModel <ContactAdviserViewModel>() .AndModelError(nameof(ContactAdviserViewModel.ContactAdviserQuestionType)); } }