Beispiel #1
0
        public void IndexTest()
        {
            //Assign
            A.CallTo(() => fakeSitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).Returns("test");
            A.CallTo(() => fakeStructuredDataInjectionRepository.GetByJobProfileUrlName(A <string> ._))
            .Returns(
                new StructuredDataInjection
            {
                Title              = nameof(StructuredDataInjection.Title),
                Script             = nameof(StructuredDataInjection.Script),
                DataType           = nameof(StructuredDataInjection.DataType),
                JobProfileLinkName = nameof(StructuredDataInjection.JobProfileLinkName)
            });

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

            //Assert
            indexMethodCall
            .ShouldRenderDefaultView()
            .WithModel <JobProfileStructuredDataViewModel>(vm =>
            {
                vm.Title.Should().BeEquivalentTo(nameof(StructuredDataInjection.Title));
                vm.Script.Should().BeEquivalentTo(nameof(StructuredDataInjection.Script));
                vm.DataType.Should().BeEquivalentTo(nameof(StructuredDataInjection.DataType));
                vm.JobProfileLinkName.Should().BeEquivalentTo(nameof(StructuredDataInjection.JobProfileLinkName));
            })
            .AndNoModelErrors();

            A.CallTo(() => fakeSitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).MustHaveHappened();
        }
Beispiel #2
0
        private void SetUpDependeciesAndCall(bool validJobProfile, bool isContentPreviewMode)
        {
            ////Set up comman call
            mapperCfg = new MapperConfiguration(cfg => { cfg.AddProfile <JobProfilesAutoMapperProfile>(); });

            dummyJobProfile = validJobProfile
                ? new JobProfile
            {
                AlternativeTitle      = nameof(JobProfile.AlternativeTitle),
                SalaryRange           = nameof(JobProfile.SalaryRange),
                Overview              = nameof(JobProfile.Overview),
                Title                 = nameof(JobProfile.Title),
                MaximumHours          = 40,
                MinimumHours          = 10,
                UrlName               = nameof(JobProfile.UrlName),
                WorkingHoursDetails   = nameof(JobProfile.WorkingHoursDetails),
                WorkingPattern        = nameof(JobProfile.WorkingPattern),
                WorkingPatternDetails = nameof(JobProfile.WorkingPatternDetails)
            }
                : null;

            var dummyIndex = new JobProfileIndex
            {
                Title                       = nameof(JobProfileIndex.Title),
                AlternativeTitle            = new[] { "alt" },
                SalaryStarter               = starterSalary,
                SalaryExperienced           = experiencedSalary,
                Overview                    = "overview",
                UrlName                     = "dummy-url",
                JobProfileCategoriesWithUrl = new[] { "CatOneURL|Cat One", "CatTwoURL|Cat Two" }
            };
            var resultsCount      = 1;
            var dummySearchResult = A.Dummy <SearchResult <JobProfileIndex> >();

            dummySearchResult.Count   = resultsCount;
            dummySearchResult.Results = A.CollectionOfDummy <SearchResultItem <JobProfileIndex> >(resultsCount);
            var rawResultItems = new List <SearchResultItem <JobProfileIndex> >
            {
                new SearchResultItem <JobProfileIndex> {
                    ResultItem = dummyIndex
                }
            };

            dummySearchResult.Results = rawResultItems;

            // Set up calls
            A.CallTo(() => searchQueryService.SearchAsync(A <string> ._, A <SearchProperties> ._)).Returns(dummySearchResult);
            A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(isContentPreviewMode);
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._))
            .ReturnsLazily((string defaultProfile) => defaultProfile);
            A.CallTo(() => govUkNotifyFake.SubmitEmail(A <string> ._, null)).Returns(false);
            A.CallTo(() => webAppContextFake.SetVocCookie(Constants.VocPersonalisationCookieName, A <string> ._)).DoesNothing();
            A.CallTo(() => loggerFake.Trace(A <string> ._)).DoesNothing();
        }
Beispiel #3
0
        public ActionResult Index()
        {
            if (webAppContext.IsContentAuthoringSite)
            {
                return(GetRelatedJobProfilesView(sitefinityPage.GetDefaultJobProfileToUse(DefaultJobProfileUrlName)));
            }

            return(Redirect("\\"));
        }
Beispiel #4
0
 /// <summary>
 /// Indexes this instance.
 /// </summary>
 /// <returns>Redirect</returns>
 public ActionResult BaseIndex()
 {
     if (WebAppContext.IsContentAuthoringSite)
     {
         CurrentJobProfileUrl = sitefinityPage.GetDefaultJobProfileToUse(DefaultJobProfileUrlName);
         return(GetEditorView());
     }
     else
     {
         return(Redirect("\\"));
     }
 }
Beispiel #5
0
        private void SetupCallsAndFakes(bool isValidJobProfile, bool inContentAuthoringSite = false, bool isContentPreviewMode = false)
        {
            webAppContextFake        = A.Fake <IWebAppContext>(ops => ops.Strict());
            jobProfileRepositoryFake = A.Fake <IJobProfileRepository>(ops => ops.Strict());
            applicationLoggerFake    = A.Fake <IApplicationLogger>();
            sitefinityPageFake       = A.Fake <ISitefinityPage>(ops => ops.Strict());
            mapper = new MapperConfiguration(c => c.AddProfile <JobProfilesAutoMapperProfile>()).CreateMapper();

            A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(inContentAuthoringSite);
            A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(isContentPreviewMode);
            A.CallTo(() => webAppContextFake.SetMetaDescription(A <string> ._)).DoesNothing();
            A.CallTo(() => jobProfileRepositoryFake.GetByUrlName(A <string> ._))
            .Returns(GetDummyJobProfile(isValidJobProfile));
            A.CallTo(() => jobProfileRepositoryFake.GetByUrlNameForPreview(A <string> ._))
            .Returns(GetDummyJobProfile(isValidJobProfile));
            A.CallTo(() => sitefinityPageFake.GetDefaultJobProfileToUse(A <string> ._))
            .Returns(nameof(JobProfile.UrlName));
        }
Beispiel #6
0
        private void SetUpDependeciesAndCall(bool validJobProfile, bool isContentPreviewMode)
        {
            ////Set up comman call
            dummyJobProfile = validJobProfile
                ? new JobProfile
            {
                AlternativeTitle = nameof(JobProfile.AlternativeTitle),
                SalaryRange      = nameof(JobProfile.SalaryRange),
                Overview         = nameof(JobProfile.Overview),
                Title            = nameof(JobProfile.Title),
                MaximumHours     = 40,
                MinimumHours     = 10
            }
                : null;

            // Set up calls
            A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile);
            A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(isContentPreviewMode);
            A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._))
            .ReturnsLazily((string defaultProfile) => defaultProfile);
        }
Beispiel #7
0
 public ActionResult Index()
 {
     return(GetActionResult(sitefinityPage.GetDefaultJobProfileToUse(DefaultJobProfileLinkName)));
 }