public SocSkillMatrix ConvertFrom(DynamicContent content) { var socSkillsMatrix = new SocSkillMatrix { Title = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(SocSkillMatrix.Title)), Contextualised = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(SocSkillMatrix.Contextualised)), ONetAttributeType = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(SocSkillMatrix.ONetAttributeType)), ONetRank = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(SocSkillMatrix.ONetRank)), Rank = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(SocSkillMatrix.Rank)) }; var socItem = dynamicContentExtensions.GetRelatedItems(content, SocField, 1).FirstOrDefault(); if (socItem != null) { socSkillsMatrix.SocCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.SOCCode)); } var skillItem = dynamicContentExtensions.GetRelatedItems(content, SkillField, 1).FirstOrDefault(); if (skillItem != null) { socSkillsMatrix.ONetElementId = dynamicContentExtensions.GetFieldValue <Lstring>(skillItem, nameof(socSkillsMatrix.ONetElementId)); socSkillsMatrix.Skill = dynamicContentExtensions.GetFieldValue <Lstring>(skillItem, nameof(socSkillsMatrix.Title)); } return(socSkillsMatrix); }
public void ConvertFromTest(bool hasValidSkill) { //set up calls var jobProfileRelatedSkillConverter = new JobProfileRelatedSkillConverter(fakeDynamicContentExtensions); var expectedSkillDescription = "TestSkillDescription"; var dummysRelatedSkills = hasValidSkill ? A.CollectionOfDummy <DynamicContent>(1).AsEnumerable().AsQueryable() : Enumerable.Empty <DynamicContent>().AsQueryable(); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)).Returns(dummysRelatedSkills); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .Returns("DummyText"); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, nameof(WhatItTakesSkill.Description))) .Returns(hasValidSkill ? expectedSkillDescription : null); var relatedSkill = jobProfileRelatedSkillConverter.ConvertFrom(fakeDynamicContentItem); //Assert if (hasValidSkill) { relatedSkill.Description.Should().BeEquivalentTo(expectedSkillDescription); } else { relatedSkill.Should().BeNull(); } }
public void ConvertFromTest(bool cadReady) { //Assign SetupCalls(cadReady); var whatYouWillDoConverter = new WhatYouWillDoConverter(fakeDynamicContentExtensions); //Act whatYouWillDoConverter.ConvertFrom(fakeDynamicContentItem); if (cadReady) { //Assert A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .MustHaveHappened(); } else { //Assert A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .MustNotHaveHappened(); } }
public void GetByParentNameTest(string urlName, int numberOfItemsToReturn) { //Assign var fakeRepo = GetTestJobProfilesRelatedCareersRepository(1, true); //Act fakeRepo.GetByParentName(urlName, numberOfItemsToReturn); // Assert A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .MustHaveHappened(); A.CallTo(() => fakeRepository.Get(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.UrlName == urlName && item.Status == ContentLifecycleStatus.Live && item.Visible)))) .MustHaveHappened(); }
private IEnumerable <RelatedSocCodeItem> GetRelatedSocsData(DynamicContent content, string relatedField) { var relatedSocsData = new List <RelatedSocCodeItem>(); var relatedItems = dynamicContentExtensions.GetRelatedItems(content, relatedField); if (relatedItems != null) { foreach (var relatedItem in relatedItems) { relatedSocsData.Add(GenerateSocData(relatedItem)); } } return(relatedSocsData); }
public void ConvertFromTest() { // Arrange SetupCalls(); var socSkillsMatrixConverter = new SocSkillsMatrixConverter(fakeDynamicContentExtensions); //Act socSkillsMatrixConverter.ConvertFrom(fakeDynamicContentItem); //Assert A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(6, Times.Exactly); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(2, Times.Exactly); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .MustHaveHappened(2, Times.Exactly); }
public JobProfileOverloadForWhatItTakes ConvertFrom(DynamicContent content) { var jobProfile = new JobProfileOverloadForWhatItTakes(); jobProfile.UrlName = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.UrlName)); jobProfile.Title = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Title)); jobProfile.DigitalSkillsLevel = dynamicContentExtensions.GetFieldChoiceValue(content, nameof(JobProfile.DigitalSkillsLevel)); var socItem = dynamicContentExtensions.GetRelatedItems(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)); } jobProfile.HasRelatedSocSkillMatrices = dynamicContentExtensions.GetRelatedItems(content, RelatedSkillsField, 1)?.Any() == true; return(jobProfile); }
private void SetupCalls() { A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .Returns("test"); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <bool>(A <DynamicContent> ._, A <string> ._)) .Returns(false); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, A <string> ._)) .Returns(10); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, nameof(JobProfile.SalaryStarter))) .Returns(10); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, nameof(JobProfile.SalaryExperienced))) .Returns(20); A.CallTo(() => fakeRelatedClassificationsRepository.GetRelatedClassifications(A <DynamicContent> ._, A <string> ._, A <string> ._)).Returns(new EnumerableQuery <string>(new List <string> { "test" })); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .Returns(new EnumerableQuery <DynamicContent>(new List <DynamicContent> { fakeDynamicContentItem })); A.CallTo(() => htbContentPropertyConverter.ConvertFrom(A <DynamicContent> ._)).Returns(new HowToBecome()); }
private IEnumerable <MoreInformationLink> GetRelatedLinkItems(DynamicContent content, string relatedField) { var linkItems = new List <MoreInformationLink>(); var relatedItems = dynamicContentExtensions.GetRelatedItems(content, relatedField); if (relatedItems != null) { foreach (var relatedItem in relatedItems) { var link = dynamicContentExtensions.GetFieldValue <Lstring>(relatedItem, nameof(MoreInformationLink.Url)); linkItems.Add(new MoreInformationLink { Title = dynamicContentExtensions.GetFieldValue <Lstring>(relatedItem, nameof(MoreInformationLink.Title)), Url = !string.IsNullOrWhiteSpace(link) ? new Uri(link, UriKind.RelativeOrAbsolute) : default,
public void ConvertFromTest(bool hasRelatedSocs) { // Arrange SetupCalls(hasRelatedSocs); var jobprofileConverter = new JobProfileOverloadForWhatItTakesConverter(fakeDynamicContentExtensions); var dummyRelatedItems = A.CollectionOfDummy <string>(1).AsEnumerable().AsQueryable(); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedContentUrl(A <DynamicContent> ._, A <string> ._)) .Returns(dummyRelatedItems); //Act var jobProfile = jobprofileConverter.ConvertFrom(fakeDynamicContentItem); //Assert jobProfile.HasRelatedSocSkillMatrices.Should().Be(hasRelatedSocs); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(); A.CallTo(() => fakeDynamicContentExtensions.GetFieldChoiceValue(A <DynamicContent> ._, A <string> ._)) .MustHaveHappened(); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .MustHaveHappened(); }
public IEnumerable <JobProfileRelatedCareer> GetRelatedCareers(DynamicContent jobProfile, int maximumItemsToReturn) { var relatedCareerProfilesItem = dynamicContentExtensions.GetRelatedItems(jobProfile, RelatedCareersFieldName, maximumItemsToReturn); if (relatedCareerProfilesItem != null) { if (relatedCareerProfilesItem.Any()) { return(relatedCareerProfilesItem.ToList().Where(x => !dynamicContentExtensions.GetFieldValue <bool>(x, IsImportedField)).Select(item => converter.ConvertFrom(item))); } } return(null); }
private void SetupCalls(bool cadReady) { A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .Returns("test"); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <bool>(A <DynamicContent> ._, A <string> ._)) .Returns(cadReady); A.CallTo(() => fakeRelatedClassificationsRepository.GetRelatedClassifications(A <DynamicContent> ._, A <string> ._, A <string> ._)).Returns(new EnumerableQuery <string>(new List <string> { "test" })); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .Returns(new EnumerableQuery <DynamicContent>(new List <DynamicContent> { fakeDynamicContentItem })); }
private void SetupCalls(bool hasRelatedSocs) { A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .Returns("test"); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <IList <Guid> >(A <DynamicContent> ._, A <string> ._)) .Returns(new List <Guid>()); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, A <string> ._)) .Returns(1); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedSearchItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .Returns(hasRelatedSocs ? new EnumerableQuery <DynamicContent>(new List <DynamicContent> { fakeDynamicContentItem }) : Enumerable.Empty <DynamicContent>().AsQueryable()); A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._)) .Returns("test"); A.CallTo(() => fakeDynamicContentExtensions.GetRelatedItems(A <DynamicContent> ._, A <string> ._, A <int> ._)) .Returns(Enumerable.Empty <DynamicContent>().AsQueryable()); }
private IEnumerable <string> GetRelatedItemDescription(DynamicContent content, string relatedField) { var items = dynamicContentExtensions.GetRelatedItems(content, relatedField); var descriptionList = new List <string>(); if (items != null && items.Any()) { foreach (var item in items) { var description = dynamicContentExtensions.GetFieldValue <Lstring>(item, DescriptionField); descriptionList.Add(description); } return(descriptionList); } return(Enumerable.Empty <string>()); }
public JobProfile ConvertFrom(DynamicContent content) { var jobProfile = new JobProfile { Title = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Title)), AlternativeTitle = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.AlternativeTitle)), WidgetContentTitle = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.WidgetContentTitle)), Overview = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Overview)), IsLMISalaryFeedOverriden = dynamicContentExtensions.GetFieldValue <bool?>(content, nameof(JobProfile.IsLMISalaryFeedOverriden)), SalaryStarter = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.SalaryStarter)), SalaryExperienced = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.SalaryExperienced)), MinimumHours = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.MinimumHours)), MaximumHours = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.MaximumHours)), CareerPathAndProgression = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.CareerPathAndProgression)), Skills = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Skills)), HowToBecome = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.HowToBecome)), WhatYouWillDo = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.WhatYouWillDo)), WorkingHoursPatternsAndEnvironment = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.WorkingHoursPatternsAndEnvironment)), Salary = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Salary)), CourseKeywords = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.CourseKeywords)), //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), UrlName = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.UrlName)), DoesNotExistInBAU = dynamicContentExtensions.GetFieldValue <bool>(content, nameof(JobProfile.DoesNotExistInBAU)), BAUSystemOverrideUrl = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.BAUSystemOverrideUrl)), IsImported = dynamicContentExtensions.GetFieldValue <bool>(content, nameof(JobProfile.IsImported)), // How To Become section HowToBecomeData = htbContentPropertyConverter.ConvertFrom(content), Restrictions = GetRestrictions(content, RelatedRestrictionsField), OtherRequirements = dynamicContentExtensions.GetFieldValue <Lstring>(content, OtherRequirementsField), DynamicTitlePrefix = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfile.DynamicTitlePrefix)), //What You will do section WhatYouWillDoData = whatYouWillDoPropertyConverter.ConvertFrom(content), RelatedSkills = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedSkillsField)?.ToList(), DigitalSkillsLevel = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfile.DigitalSkillsLevel)) }; var socItem = dynamicContentExtensions.GetRelatedItems(content, Constants.SocField, 1).FirstOrDefault(); if (socItem != null) { jobProfile.SOCCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.SOCCode)); jobProfile.ONetOccupationalCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.ONetOccupationalCode)); } jobProfile.WorkingHoursDetails = relatedClassificationsRepository.GetRelatedClassifications(content, nameof(JobProfile.WorkingHoursDetails), nameof(JobProfile.WorkingHoursDetails)).FirstOrDefault(); jobProfile.WorkingPattern = relatedClassificationsRepository.GetRelatedClassifications(content, nameof(JobProfile.WorkingPattern), nameof(JobProfile.WorkingPattern)).FirstOrDefault(); jobProfile.WorkingPatternDetails = relatedClassificationsRepository.GetRelatedClassifications(content, nameof(JobProfile.WorkingPatternDetails), nameof(JobProfile.WorkingPatternDetails)).FirstOrDefault(); //PSF jobProfile.RelatedInterests = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedInterestsField); jobProfile.RelatedEnablers = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedEnablersField); jobProfile.RelatedEntryQualifications = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedEntryQualificationsField); jobProfile.RelatedTrainingRoutes = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedTrainingRoutesField); jobProfile.RelatedPreferredTaskTypes = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedPreferredTaskTypesField); jobProfile.RelatedJobAreas = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedJobAreasField); return(jobProfile); }
public JobProfileMessage ConvertFrom(DynamicContent content) { DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(Constants.DynamicProvider); var jobProfileMessage = new JobProfileMessage { JobProfileId = dynamicContentExtensions.GetFieldValue <Guid>(content, content.GetContentItemIdKey()), Title = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.Title)), WidgetContentTitle = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.WidgetContentTitle)), AlternativeTitle = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.AlternativeTitle)), Overview = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.Overview)), SalaryStarter = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.SalaryStarter)), SalaryExperienced = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.SalaryExperienced)), MinimumHours = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.MinimumHours)), MaximumHours = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.MaximumHours)), CareerPathAndProgression = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.CareerPathAndProgression)), CourseKeywords = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.CourseKeywords)), //Need to use a string to get the content cannot use JobProfileMessage.JobProfileCategories as this is already used in the search //index and we will get a clash UrlName = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.UrlName)), IsImported = dynamicContentExtensions.GetFieldValue <bool>(content, nameof(JobProfileMessage.IsImported)), // How To Become section HowToBecomeData = htbContentPropertyConverter.ConvertFrom(content), RelatedCareersData = GetRelatedCareersData(content, Constants.RelatedCareerProfiles), Restrictions = GetRestrictions(content, RelatedRestrictionsField), OtherRequirements = dynamicContentExtensions.GetFieldValue <Lstring>(content, OtherRequirementsField), DynamicTitlePrefix = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfileMessage.DynamicTitlePrefix)), DigitalSkillsLevel = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfileMessage.DigitalSkillsLevel)), }; jobProfileMessage.IncludeInSitemap = content.IncludeInSitemap; //What You will do section jobProfileMessage.WhatYouWillDoData = GetWYDRelatedDataForJobProfiles(content); //Related Skills Data jobProfileMessage.SocSkillsMatrixData = GetSocSkillMatrixItems(content, Constants.RelatedSkills); //Get SOC Code data var socItem = dynamicContentExtensions.GetRelatedItems(content, Constants.SocField, 1).FirstOrDefault(); //SocCode Data jobProfileMessage.SocCodeData = GenerateSocData(content, socItem); //Working Pattern Details jobProfileMessage.WorkingPatternDetails = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.WorkingPatternDetail)); //Working Hours Details jobProfileMessage.WorkingHoursDetails = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.WorkingHoursDetail)); //Working Pattern jobProfileMessage.WorkingPattern = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.WorkingPattern)); //Hidden Alternative Title jobProfileMessage.HiddenAlternativeTitle = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.HiddenAlternativeTitle)); //Job Profile Specialism jobProfileMessage.JobProfileSpecialism = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.JobProfileSpecialism)); if (socItem != null) { jobProfileMessage.SocLevelTwo = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, Constants.SOCCode).ToString().Substring(0, 2); } jobProfileMessage.LastModified = dynamicContentExtensions.GetFieldValue <DateTime>(content, nameof(JobProfileMessage.LastModified)); jobProfileMessage.CanonicalName = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.UrlName)).ToLower(); jobProfileMessage.JobProfileCategories = GetJobCategories(dynamicContentExtensions.GetFieldValue <IList <Guid> >(content, RelatedJobProfileCategoriesField)); return(jobProfileMessage); }