Ejemplo n.º 1
0
        public void BlankStandardsAndFrameworksAsync(string framework, string standard, bool requestShouldBeMade)
        {
            //arrange
            var fakeLogger       = A.Fake <ILogger <AVCurrentOpportuntiesRefresh> >();
            var fakeRepository   = A.Fake <ICosmosRepository <CurrentOpportunitiesSegmentModel> >();
            var fakeAVAPIService = A.Fake <IAVAPIService>();
            var fakeMapper       = A.Fake <AutoMapper.IMapper>();
            var fakejobProfileSegmentRefreshService = A.Fake <IJobProfileSegmentRefreshService <RefreshJobProfileSegmentServiceBusModel> >();

            var currentOpportunitiesSegmentModel = new CurrentOpportunitiesSegmentModel
            {
                CanonicalName = "DummyJob",
                Data          = new CurrentOpportunitiesSegmentDataModel()
                {
                    Apprenticeships = new Apprenticeships()
                    {
                        Standards = new List <ApprenticeshipStandard>()
                        {
                            new ApprenticeshipStandard
                            {
                                Url = standard,
                            },
                        },
                        Frameworks = new List <ApprenticeshipFramework>()
                        {
                            new ApprenticeshipFramework
                            {
                                Url = framework,
                            },
                        },
                    },
                },
            };

            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);
            A.CallTo(() => fakeAVAPIService.GetAVsForMultipleProvidersAsync(A <AVMapping> .Ignored)).Returns(GetTestVacancies(2));
            A.CallTo(() => fakeAVAPIService.GetApprenticeshipVacancyDetailsAsync(A <int> .Ignored)).Returns(A.Dummy <ApprenticeshipVacancyDetails>());
            A.CallTo(() => fakeMapper.Map <Vacancy>(A <ApprenticeshipVacancyDetails> .Ignored)).Returns(A.Dummy <Vacancy>());

            var aVCurrentOpportunitiesRefresh = new AVCurrentOpportuntiesRefresh(fakeLogger, fakeRepository, fakeAVAPIService, fakeMapper, fakejobProfileSegmentRefreshService);

            //Act
            var result = aVCurrentOpportunitiesRefresh.RefreshApprenticeshipVacanciesAsync(A.Dummy <Guid>()).Result;

            //Asserts
            if (requestShouldBeMade)
            {
                result.Should().Be(2);
                A.CallTo(() => fakeAVAPIService.GetAVsForMultipleProvidersAsync(A <AVMapping> .Ignored)).MustHaveHappenedOnceExactly();
            }
            else
            {
                result.Should().Be(0);
                A.CallTo(() => fakeAVAPIService.GetAVsForMultipleProvidersAsync(A <AVMapping> .Ignored)).MustNotHaveHappened();
            }
        }
Ejemplo n.º 2
0
        public void ProjectVacanciesForProfile(Scenario scenario, int expectedNumberDisplayed)
        {
            //arrange
            var fakeLogger       = A.Fake <ILogger <AVCurrentOpportuntiesRefresh> >();
            var fakeRepository   = A.Fake <ICosmosRepository <CurrentOpportunitiesSegmentModel> >();
            var fakeAVAPIService = A.Fake <AVAPIService>();
            var fakeMapper       = A.Fake <AutoMapper.IMapper>();
            var fakejobProfileSegmentRefreshService = A.Fake <IJobProfileSegmentRefreshService <RefreshJobProfileSegmentServiceBusModel> >();

            var aVCurrentOpportunitiesRefresh = new AVCurrentOpportuntiesRefresh(fakeLogger, fakeRepository, fakeAVAPIService, fakeMapper, fakejobProfileSegmentRefreshService);

            //Act
            var projectedVacancies = aVCurrentOpportunitiesRefresh.ProjectVacanciesForProfile(GetTestMappedVacancySummary(scenario));

            //Asserts
            CheckResultIsAsExpected(projectedVacancies, expectedNumberDisplayed);
        }
Ejemplo n.º 3
0
        public void RefreshApprenticeshipVacanciesAndUpdateJobProfileSendsMsg()
        {
            //arrange
            var fakeLogger       = A.Fake <ILogger <AVCurrentOpportuntiesRefresh> >();
            var fakeRepository   = A.Fake <ICosmosRepository <CurrentOpportunitiesSegmentModel> >();
            var fakeAVAPIService = A.Fake <IAVAPIService>();
            var fakeMapper       = A.Fake <AutoMapper.IMapper>();
            var fakejobProfileSegmentRefreshService = A.Fake <IJobProfileSegmentRefreshService <RefreshJobProfileSegmentServiceBusModel> >();

            var currentOpportunitiesSegmentModel = new CurrentOpportunitiesSegmentModel
            {
                CanonicalName = "DummyJob",
                Data          = new CurrentOpportunitiesSegmentDataModel()
                {
                    Apprenticeships = new Apprenticeships()
                    {
                        Standards = new List <ApprenticeshipStandard>()
                        {
                            new ApprenticeshipStandard
                            {
                                Url = "S1",
                            },
                        },
                        Frameworks = new List <ApprenticeshipFramework>()
                        {
                            new ApprenticeshipFramework
                            {
                                Url = "F1",
                            },
                        },
                    },
                },
            };

            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);

            var aVCurrentOpportunitiesRefresh = new AVCurrentOpportuntiesRefresh(fakeLogger, fakeRepository, fakeAVAPIService, fakeMapper, fakejobProfileSegmentRefreshService);

            //Act
            _ = aVCurrentOpportunitiesRefresh.RefreshApprenticeshipVacanciesAndUpdateJobProfileAsync(A.Dummy <Guid>()).Result;

            //Asserts
            A.CallTo(() => fakejobProfileSegmentRefreshService.SendMessageAsync(A <RefreshJobProfileSegmentServiceBusModel> .Ignored)).MustHaveHappenedOnceExactly();
        }