public void SubmitTests(bool modelStateValid)
        {
            //Assign
            var postModel = new GeneralFeedbackViewModel();

            A.CallTo(() => fakeSessionStorage.Save(A <ContactUs> ._)).DoesNothing();

            A.CallTo(() => fakeSessionStorage.Get()).Returns(new ContactUs {
                ContactUsOption = new ContactUsOption()
            });

            var controller = new FeedbackController(fakeApplicationLogger, fakeMapper, fakeWebAppcontext, fakeSessionStorage);

            if (!modelStateValid)
            {
                controller.ModelState.AddModelError(nameof(GeneralFeedbackViewModel.FeedbackQuestionType), nameof(GeneralFeedbackViewModel.Feedback));
            }

            //Act
            var controllerResult = controller.WithCallTo(contrl => contrl.Index(postModel));

            //Assert
            if (modelStateValid)
            {
                controllerResult.ShouldRedirectTo(controller.NextPage);
            }
            else
            {
                controllerResult.ShouldRenderDefaultView()
                .WithModel <GeneralFeedbackViewModel>()
                .AndModelError(nameof(GeneralFeedbackViewModel.FeedbackQuestionType));
            }
        }
예제 #2
0
 private GeneralFeedbackViewModel AddWidgetPropertyFields(GeneralFeedbackViewModel model)
 {
     model.NextPage            = this.NextPage;
     model.Title               = this.Title;
     model.PersonalInformation = this.PersonalInformation;
     model.CharacterLimit      = this.CharacterLimit;
     model.ContinueText        = ContinueText;
     model.MessageLabel        = MessageLabel;
     return(model);
 }
예제 #3
0
        public ActionResult Index(GeneralFeedbackViewModel model)
        {
            if (ModelState.IsValid)
            {
                var mappedModel = mapper.Map(model, sessionStorage.Get());

                sessionStorage.Save(mappedModel);

                return(Redirect($"{NextPage}"));
            }

            return(View("Index", AddWidgetPropertyFields(model)));
        }
예제 #4
0
        public ActionResult Index()
        {
            if (!context.IsContentAuthoringSite)
            {
                var sessionModel = sessionStorage.Get();
                if (sessionModel is null || sessionModel.ContactUsOption?.ContactOptionType != ContactOption.Feedback)
                {
                    return(Redirect(ContactOptionPage));
                }
            }

            var model = new GeneralFeedbackViewModel();

            return(View("Index", AddWidgetPropertyFields(model)));
        }
        public void Dfc7630FeedbackViewTests()
        {
            // Arrange
            var feedbackIndex     = new _MVC_Views_Feedback_Index_cshtml();
            var feedbackViewModel = new GeneralFeedbackViewModel
            {
                Title = nameof(GeneralFeedbackViewModel.Title)
            };

            // Act
            var htmlDocument = feedbackIndex.RenderAsHtml(feedbackViewModel);

            // Assert
            AssertTagInnerTextValue(htmlDocument, feedbackViewModel.Title, "h1");
            AssertFormGroupsCounts(htmlDocument, 3);
            AssertRadioGroupsCounts(htmlDocument, 7);
        }