public void IndexTest(bool inContentAuthoringSite, bool isContentPreviewMode)
        {
            //Setup the fakes and dummies
            var repositoryFake           = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var loggerFake               = A.Fake <IApplicationLogger>();
            var webAppContextFake        = A.Fake <IWebAppContext>(ops => ops.Strict());
            var sitefinityPage           = A.Fake <ISitefinityPage>(ops => ops.Strict());
            var formatContentServiceFake = A.Fake <IFormatContentService>(ops => ops.Strict());

            var dummyJobProfile = GetDummyJobPRofile(true);

            // Set up calls
            A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile);

            A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(inContentAuthoringSite);
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(isContentPreviewMode);

            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);
            A.CallTo(() => formatContentServiceFake.GetParagraphText(A <string> ._, A <IEnumerable <string> > ._, A <string> ._)).Returns("test");

            //Instantiate & Act
            using (var jobProfileWhatYouWillDoController =
                       new JobProfileWhatYouWillDoController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, formatContentServiceFake))
            {
                //Act
                var indexMethodCall = jobProfileWhatYouWillDoController.WithCallTo(c => c.Index());

                //Assert
                if (inContentAuthoringSite)
                {
                    indexMethodCall
                    .ShouldRenderDefaultView()
                    .WithModel <JobProfileWhatYouWillDoViewModel>(vm =>
                    {
                        vm.Title.Should().BeEquivalentTo(jobProfileWhatYouWillDoController.MainSectionTitle);
                        vm.TopSectionContent.Should().BeEquivalentTo(jobProfileWhatYouWillDoController.TopSectionContent);
                        vm.BottomSectionContent.Should().BeEquivalentTo(jobProfileWhatYouWillDoController.BottomSectionContent);
                    })
                    .AndNoModelErrors();

                    if (!isContentPreviewMode)
                    {
                        A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened();
                    }
                    else
                    {
                        A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).MustHaveHappened();
                    }
                }
                else
                {
                    indexMethodCall.ShouldRedirectTo("\\");
                }
            }
        }
        public void IndexWithCadWhatYouWillDo(string urlName, bool cadReady, bool expected)
        {
            //Setup the fakes and dummies
            var repositoryFake           = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var loggerFake               = A.Fake <IApplicationLogger>();
            var webAppContextFake        = A.Fake <IWebAppContext>(ops => ops.Strict());
            var sitefinityPage           = A.Fake <ISitefinityPage>(ops => ops.Strict());
            var formatContentServiceFake = A.Fake <IFormatContentService>(ops => ops.Strict());

            var dummyJobProfile = GetDummyJobPRofile(true);

            dummyJobProfile.WhatYouWillDoData.IsCadReady = cadReady;

            // Set up calls
            A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(false);
            A.CallTo(() => webAppContextFake.SetMetaDescription(A <string> ._)).DoesNothing();
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);
            A.CallTo(() => formatContentServiceFake.GetParagraphText(A <string> ._, A <IEnumerable <string> > ._, A <string> ._)).Returns("test");

            //Instantiate & Act
            using (var jobProfileWhatYouWillDoController =
                       new JobProfileWhatYouWillDoController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, formatContentServiceFake)
            {
                TopSectionContent = nameof(JobProfileWhatYouWillDoController.TopSectionContent),
                BottomSectionContent = nameof(JobProfileWhatYouWillDoController.BottomSectionContent),
                MainSectionTitle = nameof(JobProfileWhatYouWillDoController.MainSectionTitle),
                SectionId = nameof(JobProfileWhatYouWillDoController.SectionId),
                WhatYouWillDoSectionTitle = nameof(JobProfileWhatYouWillDoController.WhatYouWillDoSectionTitle),
                EnvironmentTitle = nameof(JobProfileWhatYouWillDoController.EnvironmentTitle),
                IsWYDIntroActive = true
            })
            {
                //Act
                var indexWithUrlNameMethodCall = jobProfileWhatYouWillDoController.WithCallTo(c => c.Index(urlName));
                indexWithUrlNameMethodCall
                .ShouldRenderDefaultView()
                .WithModel <JobProfileWhatYouWillDoViewModel>(vm =>
                {
                    vm.Title.Should().BeEquivalentTo(jobProfileWhatYouWillDoController.MainSectionTitle);
                    vm.TopSectionContent.Should().BeEquivalentTo(jobProfileWhatYouWillDoController.TopSectionContent);
                    vm.BottomSectionContent.Should().BeEquivalentTo(jobProfileWhatYouWillDoController.BottomSectionContent);
                    vm.IsWhatYouWillDoCadView.Should().Be(expected);
                    if (expected)
                    {
                        vm.DailyTasksSectionTitle.Should()
                        .BeEquivalentTo(jobProfileWhatYouWillDoController.WhatYouWillDoSectionTitle);
                    }
                })
                .AndNoModelErrors();
            }
        }
        public void BaseIndexUrlNameTest(string urlName, bool useValidJobProfile, bool isContentPreviewMode)
        {
            //Setup the fakes and dummies
            var repositoryFake           = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var loggerFake               = A.Fake <IApplicationLogger>();
            var webAppContextFake        = A.Fake <IWebAppContext>(ops => ops.Strict());
            var sitefinityPage           = A.Fake <ISitefinityPage>(ops => ops.Strict());
            var formatContentServiceFake = A.Fake <IFormatContentService>(ops => ops.Strict());

            var dummyJobProfile = GetDummyJobPRofile(useValidJobProfile);

            // Set up calls
            A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(isContentPreviewMode);
            A.CallTo(() => webAppContextFake.SetMetaDescription(A <string> ._)).DoesNothing();
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);
            A.CallTo(() => formatContentServiceFake.GetParagraphText(A <string> ._, A <IEnumerable <string> > ._, A <string> ._)).Returns("test");

            //Instantiate & Act
            using (var baseJobprofileController = new JobProfileWhatYouWillDoController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, formatContentServiceFake))
            {
                //Act
                var indexWithUrlNameMethodCall = baseJobprofileController.WithCallTo(c => c.BaseIndex(urlName));
                A.CallTo(() => webAppContextFake.IsContentPreviewMode).MustHaveHappened();
                if (isContentPreviewMode)
                {
                    A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).MustHaveHappened();
                    A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).MustNotHaveHappened();
                }
                else
                {
                    A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened();
                    A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).MustNotHaveHappened();
                }

                if (useValidJobProfile)
                {
                    A.CallTo(() => webAppContextFake.SetMetaDescription(A <string> ._)).MustHaveHappened();
                }
                else
                {
                    A.CallTo(() => webAppContextFake.SetMetaDescription(A <string> ._)).MustNotHaveHappened();
                    indexWithUrlNameMethodCall.ShouldGiveHttpStatus(404);
                }
            }
        }
        public void BaseIndexTest(bool inContentAuthoringSite, bool isContentPreviewMode)
        {
            //Setup the fakes and dummies
            var repositoryFake           = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var loggerFake               = A.Fake <IApplicationLogger>();
            var webAppContextFake        = A.Fake <IWebAppContext>(ops => ops.Strict());
            var sitefinityPage           = A.Fake <ISitefinityPage>(ops => ops.Strict());
            var formatContentServiceFake = A.Fake <IFormatContentService>(ops => ops.Strict());
            var dummyJobProfile          = GetDummyJobPRofile(true);

            // Set up calls
            A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(inContentAuthoringSite);
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(isContentPreviewMode);
            A.CallTo(() => formatContentServiceFake.GetParagraphText(A <string> ._, A <IEnumerable <string> > ._, A <string> ._)).Returns("test");
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);

            //Instantiate & Act
            using (var baseJobprofileController = new JobProfileWhatYouWillDoController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, formatContentServiceFake))
            {
                //Act
                var indexMethodCall = baseJobprofileController.WithCallTo(c => c.BaseIndex());

                //Assert
                A.CallTo(() => webAppContextFake.IsContentAuthoringSite).MustHaveHappened();

                if (inContentAuthoringSite)
                {
                    A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).MustHaveHappened();
                }
                else
                {
                    indexMethodCall.ShouldRedirectTo("\\");
                }
            }
        }