public void IndexGetSessionTests(ContactOption contactOption, ContactOption contactOptionProperty, bool redirectExpected)
        {
            // Assign
            var controller = new YourDetailsController(fakeApplicationLogger, fakeSendEmailService, fakeAsyncHelper, fakeContext, fakeSessionStorage)
            {
                ContactOption              = contactOptionProperty,
                PageTitle                  = nameof(YourDetailsController.PageTitle),
                AdviserIntroductionTwo     = nameof(YourDetailsController.AdviserIntroductionTwo),
                AdviserIntroduction        = nameof(YourDetailsController.AdviserIntroduction),
                NonAdviserIntroduction     = nameof(YourDetailsController.NonAdviserIntroduction),
                DateOfBirthHint            = nameof(YourDetailsController.DateOfBirthHint),
                PostcodeHint               = nameof(YourDetailsController.PostcodeHint),
                SuccessPage                = nameof(YourDetailsController.SuccessPage),
                DoYouWantUsToContactUsText = nameof(YourDetailsController.DoYouWantUsToContactUsText),
                TermsAndConditionsText     = nameof(YourDetailsController.TermsAndConditionsText),
                TemplateName               = nameof(YourDetailsController.TemplateName)
            };

            var sessionObject = GetSessionObject(contactOption);

            A.CallTo(() => fakeSessionStorage.Get()).Returns(sessionObject);

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

            // Assert
            if (redirectExpected)
            {
                controllerResult.ShouldRedirectTo(controller.ContactOptionPage);
            }
            else
            {
                AssertIndexGetViews(contactOption, controllerResult, controller);
            }
        }
        public void SubmitTests(bool modelStateValid, bool validSubmission, bool validSession, ContactOption contactOption)
        {
            //Assign
            var postModel = new ContactUsWithConsentViewModel();

            A.CallTo(() => fakeSendEmailService.SendEmailAsync(A <ContactUsRequest> ._)).Returns(validSubmission);
            A.CallTo(() => fakeSessionStorage.Get()).Returns(validSession ? GetSessionObject(contactOption) : null);
            A.CallTo(() => fakeSessionStorage.Remove()).DoesNothing();

            var controller = new YourDetailsController(fakeApplicationLogger, fakeSendEmailService, fakeAsyncHelper, fakeContext, fakeSessionStorage)
            {
                SuccessPage   = nameof(YourDetailsController.SuccessPage),
                FailurePage   = nameof(YourDetailsController.FailurePage),
                ContactOption = contactOption
            };

            if (!modelStateValid)
            {
                controller.ModelState.AddModelError(nameof(ContactUsWithDobPostcodeViewModel.Firstname), nameof(ContactUsWithDobPostcodeViewModel.Firstname));
            }

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

            //Assert
            if (modelStateValid)
            {
                if (validSession)
                {
                    A.CallTo(() => fakeSessionStorage.Get()).MustHaveHappened(2, Times.Exactly);

                    A.CallTo(() => fakeSessionStorage.Remove()).MustHaveHappened();
                    A.CallTo(() => fakeSendEmailService.SendEmailAsync(A <ContactUsRequest> ._)).MustHaveHappened();

                    if (validSubmission)
                    {
                        controllerResult.ShouldRedirectTo(controller.SuccessPage);
                    }
                    else
                    {
                        controllerResult.ShouldRedirectTo(controller.FailurePage);
                    }
                }
                else
                {
                    A.CallTo(() => fakeSessionStorage.Get()).MustHaveHappened(1, Times.Exactly);

                    controllerResult.ShouldRedirectTo(controller.ContactOptionPage);
                }
            }
            else
            {
                controllerResult.ShouldRenderView("Feedback")
                .WithModel <ContactUsWithConsentViewModel>()
                .AndModelErrorFor(model => model.Firstname);
            }
        }
        public void IndexGetTest(ContactOption contactOption, bool validSessionVm)
        {
            var controller = new YourDetailsController(fakeApplicationLogger, fakeSendEmailService, fakeAsyncHelper, fakeContext, fakeSessionStorage)
            {
                ContactOption              = contactOption,
                PageTitle                  = nameof(YourDetailsController.PageTitle),
                AdviserIntroductionTwo     = nameof(YourDetailsController.AdviserIntroductionTwo),
                AdviserIntroduction        = nameof(YourDetailsController.AdviserIntroduction),
                NonAdviserIntroduction     = nameof(YourDetailsController.NonAdviserIntroduction),
                DateOfBirthHint            = nameof(YourDetailsController.DateOfBirthHint),
                PostcodeHint               = nameof(YourDetailsController.PostcodeHint),
                SuccessPage                = nameof(YourDetailsController.SuccessPage),
                DoYouWantUsToContactUsText = nameof(YourDetailsController.DoYouWantUsToContactUsText),
                TermsAndConditionsText     = nameof(YourDetailsController.TermsAndConditionsText),
                TemplateName               = nameof(YourDetailsController.TemplateName)
            };

            if (!validSessionVm)
            {
                A.CallTo(() => fakeSessionStorage.Get()).Returns(null);
            }
            else
            {
                A.CallTo(() => fakeSessionStorage.Get()).Returns(new ContactUs {
                    ContactUsOption = new ContactUsOption {
                        ContactOptionType = contactOption
                    }, ContactAnAdviserFeedback = new ContactAnAdviserFeedback(), GeneralFeedback = new GeneralFeedback(), TechnicalFeedback = new TechnicalFeedback()
                });
            }

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

            //Assert
            if (validSessionVm)
            {
                AssertIndexGetViews(contactOption, controllerResult, controller);
            }
            else
            {
                controllerResult.ShouldRedirectTo(controller.ContactOptionPage);
            }
        }