public void GetDynamicTitleTest(string dynamicTitlePrefix, string title, string 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 dummyJobProfile = GetDummyJobPRofile(true); dummyJobProfile.DynamicTitlePrefix = dynamicTitlePrefix; dummyJobProfile.Title = title; dummyJobProfile.WidgetContentTitle = title; // Set up calls //A.CallTo(() => repositoryFake.GetByUrlName(A<string>._)).Returns(dummyJobProfile); A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile); A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile); A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(true); A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(true); //Instantiate & Act using (var jobProfileHowToBecomeController = new TestBaseJobProfileWidgetController(webAppContextFake, repositoryFake, loggerFake, sitefinityPage)) { //Act var result = jobProfileHowToBecomeController.GetDynamicTitle(false); //Assert result.Should().BeEquivalentTo(expected); } }
public void DynamicSectionTitleCheckForSpecialConditionTest(string title, string widgetContentTitle, string 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 dummyJobProfile = GetDummyJobPRofile(true); dummyJobProfile.Title = title; dummyJobProfile.WidgetContentTitle = widgetContentTitle; // Set up calls A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile); A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile); A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile); A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(true); A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(true); using (var jobProfileHowToBecomeController = new TestBaseJobProfileWidgetController(webAppContextFake, repositoryFake, loggerFake, sitefinityPage)) { //Act var result = jobProfileHowToBecomeController.GetDynamicTitle(false); //Assert Assert.Equal(result, expected, ignoreCase: false); } }
public void DynamicSectionTitleForCoursesAndApprenticeshipsTest(string htbPrefix, string title, string expected) { //Setup the fakes and dummies var repositoryFake = A.Fake <IJobProfileRepository>(ops => ops.Strict()); var socCodeRepositoryFake = A.Fake <IJobProfileSocCodeRepository>(ops => ops.Strict()); var coursesearchFake = A.Fake <ICourseSearchService>(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.DynamicTitlePrefix = htbPrefix; dummyJobProfile.Title = title; dummyJobProfile.WidgetContentTitle = title; var dummyCourses = new EnumerableQuery <Course>(new List <Course> { new Course { Title = $"dummy {nameof(Course.Title)}", Location = $"dummy {nameof(Course.Location)}", CourseId = $"dummy {nameof(Course.CourseId)}", StartDate = default(DateTime), ProviderName = $"dummy {nameof(Course.ProviderName)}" }, new Course { Title = $"dummy {nameof(Course.Title)}", Location = $"dummy {nameof(Course.Location)}", CourseId = $"dummy {nameof(Course.CourseId)}", StartDate = default(DateTime), ProviderName = $"dummy {nameof(Course.ProviderName)}" } }); var dummyApprenticeships = new EnumerableQuery <ApprenticeVacancy>(new List <ApprenticeVacancy> { new ApprenticeVacancy { Title = $"dummy {nameof(ApprenticeVacancy.Title)}", Location = $"dummy {nameof(ApprenticeVacancy.Location)}", URL = new Uri($"/dummy{nameof(ApprenticeVacancy.URL)}", UriKind.RelativeOrAbsolute), VacancyId = $"dummy {nameof(ApprenticeVacancy.VacancyId)}", WageAmount = "£3", WageUnitType = $"dummy {nameof(ApprenticeVacancy.WageUnitType)}" }, new ApprenticeVacancy { Title = $"dummy {nameof(ApprenticeVacancy.Title)}", Location = $"dummy {nameof(ApprenticeVacancy.Location)}", URL = new Uri($"/dummy{nameof(ApprenticeVacancy.URL)}", UriKind.RelativeOrAbsolute), VacancyId = $"dummy {nameof(ApprenticeVacancy.VacancyId)}", WageAmount = "£3", WageUnitType = $"dummy {nameof(ApprenticeVacancy.WageUnitType)}" } }); // Set up calls A.CallTo(() => repositoryFake.GetByUrlName(A <string> ._)).Returns(dummyJobProfile); A.CallTo(() => repositoryFake.GetByUrlNameForPreview(A <string> ._)).Returns(dummyJobProfile); A.CallTo(() => socCodeRepositoryFake.GetApprenticeVacanciesBySocCode(A <string> ._)).Returns(dummyApprenticeships); A.CallTo(() => coursesearchFake.GetCoursesAsync(A <string> ._)).Returns(dummyCourses); A.CallTo(() => sitefinityPage.GetDefaultJobProfileToUse(A <string> ._)).ReturnsLazily((string defaultProfile) => defaultProfile); A.CallTo(() => webAppContextFake.IsContentAuthoringSite).Returns(true); A.CallTo(() => webAppContextFake.IsContentPreviewMode).Returns(true); //Instantiate & Act using (var jobProfileApprenticeshipsAndCoursesController = new TestBaseJobProfileWidgetController(webAppContextFake, repositoryFake, loggerFake, sitefinityPage)) { //Act var result = jobProfileApprenticeshipsAndCoursesController.GetDynamicTitle(true); //Assert result.Should().BeEquivalentTo(expected); } }