public void GetCurrentHealthStatusAsyncExceptionTestAsync()
        {
            //Arrange
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, false)).Throws(new ApplicationException());
            var courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);

            //Act
            Func <Task> serviceHealthStatus = async() => await courseCurrentOpportunitiesRefresh.CheckHealthAsync(dummyHealthCheckContext).ConfigureAwait(false);

            //Asserts
            serviceHealthStatus.Should().Throw <Exception>();
        }
        public async Task GetCurrentHealthStatusAsyncTestAsync(int recordsToReturn, HealthStatus expectedStatus)
        {
            //Arrange
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, false)).Returns(GetTestCourses(recordsToReturn));
            var courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);

            //Act
            var serviceHealthStatus = await courseCurrentOpportunitiesRefresh.CheckHealthAsync(dummyHealthCheckContext).ConfigureAwait(false);

            //Asserts
            serviceHealthStatus.Status.Should().Be(expectedStatus);
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> ._, false)).MustHaveHappened();
        }
Example #3
0
        public async Task RefreshApprenticeshipVacanciesAndUpdateJobProfileSendsMsg()
        {
            //arrange
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);

            var courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);

            //Act
            _ = await courseCurrentOpportunitiesRefresh.RefreshCoursesAndUpdateJobProfileAsync(A.Dummy <Guid>()).ConfigureAwait(false);

            //Asserts
            A.CallTo(() => fakejobProfileSegmentRefreshService.SendMessageAsync(A <RefreshJobProfileSegmentServiceBusModel> .Ignored)).MustHaveHappenedOnceExactly();
        }
Example #4
0
        public async Task ShouldHandleFACClientReturningNullForASearch()
        {
            //arrange
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, false)).Returns(GetTestCourses(0));

            var courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);

            //Act
            var result = await courseCurrentOpportunitiesRefresh.RefreshCoursesAsync(A.Dummy <Guid>()).ConfigureAwait(false);

            //Asserts
            result.Should().Be(0);
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, true)).MustHaveHappened();
        }
Example #5
0
        public async Task ShouldNotMakeACallToFACClientIfCousreKeyWordIsBlank()
        {
            //arrange
            var modelWithBlankCourses = currentOpportunitiesSegmentModel;

            modelWithBlankCourses.Data.Courses.CourseKeywords = string.Empty;
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);
            var courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);

            //Act
            var result = await courseCurrentOpportunitiesRefresh.RefreshCoursesAsync(A.Dummy <Guid>()).ConfigureAwait(false);

            //Asserts
            result.Should().Be(0);
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, true)).MustNotHaveHappened();
        }
Example #6
0
        public void RefreshCoursesAsyncExceptionTest()
        {
            //Arrange
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, true)).Throws(new ApplicationException());

            var         courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);
            Func <Task> serviceHealthStatus = async() => await courseCurrentOpportunitiesRefresh.RefreshCoursesAsync(A.Dummy <Guid>()).ConfigureAwait(false);

            //Asserts
            serviceHealthStatus.Should().Throw <ApplicationException>();

            //Asserts
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeRepository.UpsertAsync(A <CurrentOpportunitiesSegmentModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeMapper.Map <Opportunity>(A <object> .Ignored)).MustNotHaveHappened();
        }
Example #7
0
        public async Task RefreshCoursesAsync(int numberVacanciesFound)
        {
            //arrange
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);
            A.CallTo(() => fakeCourseSearchClient.GetCoursesAsync(A <string> .Ignored, true)).Returns(GetTestCourses(numberVacanciesFound));
            A.CallTo(() => fakeMapper.Map <Opportunity>(A <Course> .Ignored)).Returns(new Opportunity()
            {
                CourseId = "1"
            });

            var courseCurrentOpportunitiesRefresh = new CourseCurrentOpportunitiesRefresh(fakeLogger, fakeRepository, fakeCourseSearchClient, fakeMapper, courseSearchSettings, fakejobProfileSegmentRefreshService);

            //Act
            var result = await courseCurrentOpportunitiesRefresh.RefreshCoursesAsync(A.Dummy <Guid>()).ConfigureAwait(false);

            //Asserts
            result.Should().Be(numberVacanciesFound);
            A.CallTo(() => fakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeRepository.UpsertAsync(A <CurrentOpportunitiesSegmentModel> .Ignored)).MustHaveHappenedOnceExactly();
        }