Пример #1
0
        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 void ConvertFromTest(bool socAssigned)
        {
            //Assign
            SetupSocCall(socAssigned);
            var jobprofileConverter = new JobProfileConverter(fakeRelatedClassificationsRepository, fakeDynamicContentExtensions, htbContentPropertyConverter, wywdPropertyConverter);

            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
            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();
            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <bool>(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();
            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();

            A.CallTo(() => fakeDynamicContentExtensions.GetFieldChoiceLabel(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();

            A.CallTo(() => fakeRelatedClassificationsRepository.GetRelatedClassifications(A <DynamicContent> ._, A <string> ._, A <string> ._)).MustHaveHappened();
            A.CallTo(() => htbContentPropertyConverter.ConvertFrom(A <DynamicContent> ._)).MustHaveHappened();

            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, nameof(JobProfile.SalaryStarter)))
            .MustHaveHappened();
            jobProfile.SalaryStarter.Should().Be(10);

            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, nameof(JobProfile.SalaryExperienced)))
            .MustHaveHappened();
            jobProfile.SalaryExperienced.Should().Be(20);

            if (socAssigned)
            {
                A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, nameof(JobProfile.SOCCode)))
                .MustHaveHappened();
                jobProfile.SOCCode.Should().NotBeNullOrEmpty();
            }
            else
            {
                A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, nameof(JobProfile.SOCCode)))
                .MustNotHaveHappened();
                jobProfile.SOCCode.Should().BeNullOrEmpty();
            }
        }
        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();
        }
Пример #4
0
        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);
        }