Пример #1
0
        public async Task JobProfileServiceGetMappingsAsyncReturnsSuccess()
        {
            //arrange
            const int jobProfilesCount = 2;

            A.CallTo(() => fakeJobProfileApiConnector.GetSummaryAsync()).Returns(A.CollectionOfDummy <JobProfileSummaryModel>(jobProfilesCount));
            A.CallTo(() => fakeJobProfileApiConnector.GetDetailsAsync(A <IList <JobProfileSummaryModel> > .Ignored)).Returns(A.CollectionOfDummy <JobProfileDetailModel>(jobProfilesCount));
            A.CallTo(() => fakeJobProfilesToSocMappingService.Map(A <IList <JobProfileDetailModel> > .Ignored)).Returns(A.CollectionOfDummy <SocJobProfileMappingModel>(jobProfilesCount));

            //act
            var results = await jobProfileService.GetMappingsAsync().ConfigureAwait(false);

            //assert
            A.CallTo(() => fakeJobProfileApiConnector.GetSummaryAsync()).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeJobProfileApiConnector.GetDetailsAsync(A <IList <JobProfileSummaryModel> > .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeJobProfilesToSocMappingService.Map(A <IList <JobProfileDetailModel> > .Ignored)).MustHaveHappenedOnceExactly();

            Assert.NotNull(results);
        }
        public async Task <IList <SocJobProfileMappingModel>?> GetMappingsAsync()
        {
            logger.LogInformation($"Retrieving from job-profiles API");

            var jobProfileSummaries = await jobProfileApiConnector.GetSummaryAsync().ConfigureAwait(false);

            if (jobProfileSummaries != null && jobProfileSummaries.Any())
            {
                logger.LogInformation($"Retrieved {jobProfileSummaries.Count} job-profiles from job-profiles API");

                var jobProfileDetails = await jobProfileApiConnector.GetDetailsAsync(jobProfileSummaries).ConfigureAwait(false);

                socJobProfilesMappingsCachedModel.SocJobProfileMappings = jobProfilesToSocMappingService.Map(jobProfileDetails);

                logger.LogInformation($"Transformed {jobProfileSummaries.Count} job-profiles into {socJobProfilesMappingsCachedModel.SocJobProfileMappings.Count} SOC / job-profile mapping");

                return(socJobProfilesMappingsCachedModel.SocJobProfileMappings);
            }
            else
            {
                logger.LogWarning($"Failed to retrieve data from job-profiles API");
            }

            return(default);
Пример #3
0
        public async Task JobProfileApiConnectorGetSummaryReturnsSuccess()
        {
            // arrange
            var expectedResults = new List <JobProfileSummaryModel>
            {
                new JobProfileSummaryModel
                {
                    Title = "A title",
                    Url   = new Uri("https://somewhere.com/", UriKind.Absolute),
                },
            };

            A.CallTo(() => fakeApiDataConnector.GetAsync <IList <JobProfileSummaryModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(expectedResults);

            // act
            var results = await jobProfileApiConnector.GetSummaryAsync().ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeApiDataConnector.GetAsync <IList <JobProfileSummaryModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            Assert.NotNull(results);
            Assert.Equal(expectedResults.Count, results !.Count);
            Assert.Equal(expectedResults.First().Title, results.First().Title);
            Assert.Equal(expectedResults.First().Url, results.First().Url);
        }