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();
        }
Esempio n. 2
0
        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);
        }