public void ConvertFromTest(bool hasRelatedSocs) { // Arrange SetupCalls(hasRelatedSocs); var jobprofileConverter = new JobProfileOverloadForSearchConverter(fakeDynamicContentExtensions); var dummyRelatedItems = A.CollectionOfDummy <string>(1).AsEnumerable().AsQueryable(); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedContentUrl(A <DynamicContent> ._, A <string> ._)) .Returns(dummyRelatedItems); //Act jobprofileConverter.ConvertFrom(fakeDynamicContentItem); //Assert if (hasRelatedSocs) { A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(); } else { A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .MustNotHaveHappened(); } A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <IList <Guid> >(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedSearchItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .MustHaveHappened(); }
public JobProfileOverloadForSearch ConvertFrom(DynamicContent content) { var jobProfile = new JobProfileOverloadForSearch { //Need to use a string to get the content cannot use JobProfile.JobProfileCategories as this is already used in the search //index and we will get a clash JobProfileCategoryIdCollection = dynamicContentExtensions.GetFieldValue <IList <Guid> >(content, RelatedJobProfileCategoriesField) }; var socItem = dynamicContentExtensions.GetRelatedSearchItems(content, SocField, 1).FirstOrDefault(); if (socItem != null) { jobProfile.SOCCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.SOCCode)); jobProfile.ONetOccupationalCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.ONetOccupationalCode)); } //PSF jobProfile.RelatedInterests = dynamicContentExtensions.GetRelatedSearchItemsUrl(content, RelatedInterestsField); jobProfile.RelatedEnablers = dynamicContentExtensions.GetRelatedSearchItemsUrl(content, RelatedEnablersField); jobProfile.RelatedTrainingRoutes = dynamicContentExtensions.GetRelatedSearchItemsUrl(content, RelatedTrainingRoutesField); jobProfile.RelatedPreferredTaskTypes = dynamicContentExtensions.GetRelatedSearchItemsUrl(content, RelatedPreferredTaskTypesField); jobProfile.RelatedJobAreas = dynamicContentExtensions.GetRelatedSearchItemsUrl(content, RelatedJobAreasField); var skills = dynamicContentExtensions.GetRelatedSearchItemsUrl(content, RelatedSkills); if (skills != null) { jobProfile.RelatedSkills = new List <string>(); foreach (var skill in skills) { jobProfile.RelatedSkills.Add(skill.Substring(skill.IndexOf("-") + 1).Replace(" ", "-")); } } var relatedRelatedEntryQualifications = dynamicContentExtensions.GetRelatedSearchItems(content, RelatedEntryQualificationsField, 100); jobProfile.RelatedEntryQualifications = relatedRelatedEntryQualifications?.AsQueryable().Select(x => $"{x.UrlName}"); jobProfile.EntryQualificationLowestLevel = GetLowestLevel(relatedRelatedEntryQualifications); return(jobProfile); }
public JobProfileOverloadForSearch ConvertFrom(DynamicContent content) { var jobProfile = new JobProfileOverloadForSearch { //Need to use a string to get the content cannot use JobProfile.JobProfileCategories as this is already used in the search //index and we will get a clash JobProfileCategoryIdCollection = dynamicContentExtensions.GetFieldValue <IList <Guid> >(content, RelatedJobProfileCategoriesField) }; var socItem = dynamicContentExtensions.GetRelatedSearchItems(content, SocField, 1).FirstOrDefault(); if (socItem != null) { jobProfile.SOCCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.SOCCode)); jobProfile.ONetOccupationalCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.ONetOccupationalCode)); } return(jobProfile); }