public void IndexWithUrlNameTest(string urlName, bool validJobProfile) { SetupCallsAndFakes(validJobProfile); //Act var jobprofilehtbController = new JobProfileHowToBecomeController(webAppContextFake, jobProfileRepositoryFake, applicationLoggerFake, sitefinityPageFake, mapper); var indexWithUrlNameMethodCall = jobprofilehtbController.WithCallTo(c => c.Index(urlName)); //Assert if (validJobProfile) { indexWithUrlNameMethodCall .ShouldRenderDefaultView() .WithModel <JobProfileHowToBecomeViewModel>(vm => { AssertViewModelProperties(vm, jobprofilehtbController, validJobProfile); }) .AndNoModelErrors(); A.CallTo(() => jobProfileRepositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened(); } else { indexWithUrlNameMethodCall.ShouldGiveHttpStatus(404); } }
public void IndexTest(bool validJobProfile, bool inContentAuthoringSite, bool isContentPreviewMode) { //Assign SetupCallsAndFakes(validJobProfile, inContentAuthoringSite, isContentPreviewMode); //Act var jobprofilehtbController = new JobProfileHowToBecomeController(webAppContextFake, jobProfileRepositoryFake, applicationLoggerFake, sitefinityPageFake, mapper); var indexMethodCall = jobprofilehtbController.WithCallTo(c => c.Index()); //Assert if (inContentAuthoringSite) { indexMethodCall .ShouldRenderDefaultView() .WithModel <JobProfileHowToBecomeViewModel>(vm => { AssertViewModelProperties(vm, jobprofilehtbController, validJobProfile); }) .AndNoModelErrors(); if (!isContentPreviewMode) { A.CallTo(() => jobProfileRepositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened(); } else { A.CallTo(() => jobProfileRepositoryFake.GetByUrlNameForPreview(A <string> ._)).MustHaveHappened(); } } else { indexMethodCall.ShouldRedirectTo("\\"); } }
private static void AssertViewModelProperties(JobProfileHowToBecomeViewModel vm, JobProfileHowToBecomeController jobprofilehtbController, bool validJobProfile) { vm.SubsectionApprenticeship.Should().BeEquivalentTo(jobprofilehtbController.SubsectionApprenticeship); vm.MainSectionTitle.Should().BeEquivalentTo(validJobProfile ? $"{jobprofilehtbController.MainSectionTitle} a Title" : jobprofilehtbController.MainSectionTitle); vm.SectionId.Should().BeEquivalentTo(jobprofilehtbController.SectionId); vm.SubsectionUniversity.Should().BeEquivalentTo(jobprofilehtbController.SubsectionUniversity); vm.SubsectionUniversityMoreInformation.Should().BeEquivalentTo(jobprofilehtbController.SubsectionUniversityMoreInformation); vm.SubsectionCollege.Should().BeEquivalentTo(jobprofilehtbController.SubsectionCollege); vm.SubsectionCollegeRequirements.Should().BeEquivalentTo(jobprofilehtbController.SubsectionCollegeRequirements); vm.SubsectionCollegeMoreInformation.Should().BeEquivalentTo(jobprofilehtbController.SubsectionCollegeMoreInformation); vm.SubsectionApprenticeship.Should().BeEquivalentTo(jobprofilehtbController.SubsectionApprenticeship); vm.SubsectionApprenticeshipRequirements.Should().BeEquivalentTo(jobprofilehtbController.SubsectionApprenticeshipRequirements); vm.SubsectionApprenticeshipMoreInformation.Should().BeEquivalentTo(jobprofilehtbController.SubsectionApprenticeshipMoreInformation); vm.SubsectionWork.Should().BeEquivalentTo(jobprofilehtbController.SubsectionWork); vm.SubsectionVolunteering.Should().BeEquivalentTo(jobprofilehtbController.SubsectionVolunteering); vm.SubsectionDirectApplication.Should().BeEquivalentTo(jobprofilehtbController.SubsectionDirectApplication); vm.SubsectionOtherRoutes.Should().BeEquivalentTo(jobprofilehtbController.SubsectionOtherRoutes); vm.SubsectionMoreInfo.Should().BeEquivalentTo(jobprofilehtbController.SubsectionMoreInfo); vm.SubsectionMoreInfoRegistration.Should().BeEquivalentTo(jobprofilehtbController.SubsectionMoreInfoRegistration); vm.SubsectionMoreInfoRegistrationOpeningText.Should().BeEquivalentTo(jobprofilehtbController.SubsectionMoreInfoRegistrationOpeningText); vm.SubsectionMoreInfoBodies.Should().BeEquivalentTo(jobprofilehtbController.SubsectionMoreInfoBodies); vm.SubsectionMoreInfoTips.Should().BeEquivalentTo(jobprofilehtbController.SubsectionMoreInfoTips); vm.SubsectionMoreInfoFurtherInfo.Should().BeEquivalentTo(jobprofilehtbController.SubsectionMoreInfoFurtherInfo); }