Example #1
0
        public void IndexUrlNameTest(string urlName, bool useValidJobProfile, bool isContentPreviewMode)
        {
            //Setup the fakes and dummies
            var repositoryFake       = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var skillsRepositoryFake = A.Fake <IJobProfileRelatedSkillsRepository>(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 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(() => webAppContextFake.IsContentAuthoringSite).Returns(isContentPreviewMode);
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);

            //Instantiate & Act
            var jobProfileWhatItTakesController =
                new JobProfileWhatItTakesController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, skillsRepositoryFake);

            //Act
            var indexWithUrlNameMethodCall = jobProfileWhatItTakesController.WithCallTo(c => c.Index(urlName));

            if (useValidJobProfile)
            {
                indexWithUrlNameMethodCall
                .ShouldRenderDefaultView()
                .WithModel <JobProfileWhatItTakesViewModel>(vm =>
                {
                    vm.Title.Should().BeEquivalentTo(jobProfileWhatItTakesController.MainSectionTitle);
                    vm.JobProfileWhatItTakesSkillsViewModel.TopSectionContent.Should().BeEquivalentTo(jobProfileWhatItTakesController.TopSectionContent);
                    vm.JobProfileWhatItTakesSkillsViewModel.BottomSectionContent.Should().BeEquivalentTo(jobProfileWhatItTakesController.BottomSectionContent);
                    vm.JobProfileWhatItTakesSkillsViewModel.BottomSectionContent.Should().BeEquivalentTo(jobProfileWhatItTakesController.BottomSectionContent);
                    vm.JobProfileWhatItTakesSkillsViewModel.DigitalSkillsLevel.Should().BeEquivalentTo(nameof(JobProfile.DigitalSkillsLevel));
                })
                .AndNoModelErrors();
            }
            else
            {
                indexWithUrlNameMethodCall
                .ShouldGiveHttpStatus(404);
            }

            if (!isContentPreviewMode)
            {
                A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened();
            }
            else
            {
                A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).MustHaveHappened();
            }
        }
Example #2
0
        public void IndexTest(bool inContentAuthoringSite, bool isContentPreviewMode)
        {
            //Setup the fakes and dummies
            var repositoryFake       = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var skillsRepositoryFake = A.Fake <IJobProfileRelatedSkillsRepository>(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 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);

            //Instantiate & Act
            var jobProfileWhatItTakesController =
                new JobProfileWhatItTakesController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, skillsRepositoryFake);

            //Act
            var indexMethodCall = jobProfileWhatItTakesController.WithCallTo(c => c.Index());

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

                if (!isContentPreviewMode)
                {
                    A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened();
                }
                else
                {
                    A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).MustHaveHappened();
                }
            }
            else
            {
                indexMethodCall.ShouldRedirectTo("\\");
            }
        }
Example #3
0
        public void IndexWithCadHowToBecome(string urlName, bool cadReady, bool expected)
        {
            //Setup the fakes and dummies
            var repositoryFake       = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var skillsRepositoryFake = A.Fake <IJobProfileRelatedSkillsRepository>(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 dummyJobProfile = GetDummyJobPRofile(true);

            dummyJobProfile.HowToBecomeData.IsHTBCaDReady = 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(() => webAppContextFake.IsContentAuthoringSite).Returns(false);
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);

            //Instantiate & Act
            var jobProfileWhatItTakesController =
                new JobProfileWhatItTakesController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, skillsRepositoryFake);

            //Act
            var indexWithUrlNameMethodCall = jobProfileWhatItTakesController.WithCallTo(c => c.Index(urlName));

            indexWithUrlNameMethodCall
            .ShouldRenderDefaultView()
            .WithModel <JobProfileWhatItTakesViewModel>(vm =>
            {
                vm.Title.Should().BeEquivalentTo(jobProfileWhatItTakesController.MainSectionTitle);
                vm.JobProfileWhatItTakesSkillsViewModel.TopSectionContent.Should().BeEquivalentTo(jobProfileWhatItTakesController.TopSectionContent);
                vm.JobProfileWhatItTakesSkillsViewModel.BottomSectionContent.Should().BeEquivalentTo(jobProfileWhatItTakesController.BottomSectionContent);
                vm.IsWhatItTakesCadView.Should().Be(expected);
                if (expected)
                {
                    vm.RestrictionsOtherRequirements.SectionIntro.Should()
                    .BeEquivalentTo(jobProfileWhatItTakesController.RestrictionsIntro);
                    vm.RestrictionsOtherRequirements.SectionTitle.Should()
                    .BeEquivalentTo(jobProfileWhatItTakesController.RestrictionsTitle);
                    vm.RestrictionsOtherRequirements.Restrictions.Should()
                    .BeEquivalentTo(dummyJobProfile.Restrictions);
                    vm.RestrictionsOtherRequirements.OtherRequirements.Should()
                    .BeEquivalentTo(dummyJobProfile.OtherRequirements);
                }
            })
            .AndNoModelErrors();
        }
Example #4
0
        public void IndexWithONetData(bool shouldUseSkillsFrameworkForCitizen, bool shouldUseSkillsFrameworkInPreview, bool isContentPreviewMode)
        {
            var repositoryFake       = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            var skillsRepositoryFake = A.Fake <IJobProfileRelatedSkillsRepository>(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 dummyJobProfile = GetDummyJobPRofile(true);

            dummyJobProfile.RelatedSkills = new List <string> {
                "DummyRelated1", "DummyRelated2"
            };

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

            //These two are linked you cannot be in content preview mode with out being in editor mode.
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(isContentPreviewMode);
            A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(isContentPreviewMode);
            A.CallTo(() => webAppContextFake.SetMetaDescription(A <string> ._)).DoesNothing();
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile);
            A.CallTo(() => skillsRepositoryFake.GetContextualisedSkillsById(A <IEnumerable <string> > ._)).Returns(new List <WhatItTakesSkill> {
                new WhatItTakesSkill()
            });

            //Instantiate & Act
            var jobProfileWhatItTakesController =
                new JobProfileWhatItTakesController(repositoryFake, webAppContextFake, loggerFake, sitefinityPage, skillsRepositoryFake);

            jobProfileWhatItTakesController.ShouldUseSkillsFrameworkForCitizen = shouldUseSkillsFrameworkForCitizen;
            jobProfileWhatItTakesController.ShouldUseSkillsFrameworkInPreview  = shouldUseSkillsFrameworkInPreview;
            jobProfileWhatItTakesController.NumberOfSkillsToDisplay            = 1;

            //Act
            var indexWithUrlNameMethodCall = jobProfileWhatItTakesController.WithCallTo(c => c.Index("Test"));

            indexWithUrlNameMethodCall
            .ShouldRenderDefaultView()
            .WithModel <JobProfileWhatItTakesViewModel>(vm =>
            {
                if (isContentPreviewMode)
                {
                    if (shouldUseSkillsFrameworkInPreview)
                    {
                        vm.JobProfileWhatItTakesSkillsViewModel.UseSkillsFramework.Should().BeTrue();
                        vm.JobProfileWhatItTakesSkillsViewModel.WhatItTakesSkills.Should().HaveCount(1);
                    }
                    else
                    {
                        vm.JobProfileWhatItTakesSkillsViewModel.UseSkillsFramework.Should().BeFalse();
                        vm.JobProfileWhatItTakesSkillsViewModel.WhatItTakesSkills.Should().BeNullOrEmpty();
                    }
                }
                else
                {
                    if (shouldUseSkillsFrameworkForCitizen)
                    {
                        vm.JobProfileWhatItTakesSkillsViewModel.UseSkillsFramework.Should().BeTrue();
                        vm.JobProfileWhatItTakesSkillsViewModel.WhatItTakesSkills.Should().HaveCount(1);
                    }
                    else
                    {
                        vm.JobProfileWhatItTakesSkillsViewModel.UseSkillsFramework.Should().BeFalse();
                        vm.JobProfileWhatItTakesSkillsViewModel.WhatItTakesSkills.Should().BeNullOrEmpty();
                    }
                }
            }).AndNoModelErrors();
        }