public void Dfc2857MoreinfomationViewTests(string careerTips, string professionalAndIndustryBodies, string furtherInformation, bool validRegistrations) { // Arrange var moreInformationView = new _MVC_Views_JobProfileHowToBecome_MoreInformation_cshtml(); var jobProfileHowToBecomeView = new JobProfileHowToBecomeViewModel { HowToBecome = new HowToBecome { FurtherInformation = new MoreInformation { CareerTips = careerTips, ProfessionalAndIndustryBodies = professionalAndIndustryBodies, FurtherInformation = furtherInformation }, Registrations = GetRegistrations(validRegistrations) } }; // Act var htmlDocument = moreInformationView.RenderAsHtml(jobProfileHowToBecomeView); // Assert if (string.IsNullOrWhiteSpace(careerTips) && string.IsNullOrWhiteSpace(professionalAndIndustryBodies) && string.IsNullOrWhiteSpace(furtherInformation) && !validRegistrations) { AssertViewIsEmpty(htmlDocument); } if (!string.IsNullOrWhiteSpace(careerTips)) { AssertContentExistsInView(careerTips, htmlDocument); } if (!string.IsNullOrWhiteSpace(professionalAndIndustryBodies)) { AssertContentExistsInView(professionalAndIndustryBodies, htmlDocument); } if (!string.IsNullOrWhiteSpace(furtherInformation)) { AssertContentExistsInView(furtherInformation, htmlDocument); } if (validRegistrations) { htmlDocument.DocumentNode.Descendants("li").Count().Should().IsSameOrEqualTo(jobProfileHowToBecomeView.HowToBecome.Registrations.Count()); } }
public void Dfc2857IndexViewTests(string content) { // Arrange var indexView = new _MVC_Views_JobProfileHowToBecome_Index_cshtml(); var jobProfileHowToBecomeView = new JobProfileHowToBecomeViewModel { HowToBecomeText = content, HowToBecome = new HowToBecome() }; // Act var htmlDocument = indexView.RenderAsHtml(jobProfileHowToBecomeView); // Assert AssertContentExistsInView(content, htmlDocument); }
public void Dfc2857ExtrainfomationViewTests(string work, string directApplication, string otherRoutes, string volunteering) { // Arrange var extraInformationView = new _MVC_Views_JobProfileHowToBecome_FurtherRoutes_cshtml(); var jobProfileHowToBecomeViewModel = new JobProfileHowToBecomeViewModel { HowToBecome = new HowToBecome { FurtherRoutes = new FurtherRoutes { Work = work, DirectApplication = directApplication, OtherRoutes = otherRoutes, Volunteering = volunteering } } }; // Act var htmlDocument = extraInformationView.RenderAsHtml(jobProfileHowToBecomeViewModel); // Assert if (!string.IsNullOrWhiteSpace(work)) { ContentDisplayedBySectionId(htmlDocument, "work").Should().BeTrue(); } if (!string.IsNullOrWhiteSpace(directApplication)) { ContentDisplayedBySectionId(htmlDocument, "directapplication").Should().BeTrue(); } if (!string.IsNullOrWhiteSpace(volunteering)) { ContentDisplayedBySectionId(htmlDocument, "volunteering").Should().BeTrue(); } if (!string.IsNullOrWhiteSpace(otherRoutes)) { ContentDisplayedBySectionId(htmlDocument, "otherroutes").Should().BeTrue(); } }
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); }