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(); }
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(); }
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(); }
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(); }