Exemplo n.º 1
0
        public async Task Then_The_Api_Is_Called_With_The_Request_And_Vacancy_And_Course_Not_looked_Up_If_Standard_Is_Null(
            GetVacancyQuery query,
            GetVacancyApiResponse apiApiResponse,
            GetStandardsListItem courseResponse,
            string findAnApprenticeshipBaseUrl,
            List <string> categories,
            [Frozen] Mock <ICourseService> standardsService,
            [Frozen] Mock <IFindApprenticeshipApiClient <FindApprenticeshipApiConfiguration> > apiClient,
            [Frozen] Mock <IOptions <VacanciesConfiguration> > vacanciesConfiguration,
            GetVacancyQueryHandler handler)
        {
            vacanciesConfiguration.Object.Value.FindAnApprenticeshipBaseUrl = findAnApprenticeshipBaseUrl;
            apiApiResponse.StandardLarsCode = null;
            standardsService.Setup(x => x.GetActiveStandards <GetStandardsListResponse>(nameof(GetStandardsListResponse))).ReturnsAsync(new GetStandardsListResponse
            {
                Standards = new List <GetStandardsListItem> {
                    courseResponse
                }
            });

            var expectedGetRequest = new GetVacancyRequest(query.VacancyReference);

            apiClient.Setup(x =>
                            x.Get <GetVacancyApiResponse>(It.Is <GetVacancyRequest>(c =>
                                                                                    c.GetUrl.Equals(expectedGetRequest.GetUrl)))).ReturnsAsync(apiApiResponse);

            var actual = await handler.Handle(query, CancellationToken.None);

            actual.Vacancy.Should().BeEquivalentTo(apiApiResponse);
        }
Exemplo n.º 2
0
        public async Task Then_If_Vacancy_Not_Found_Then_Null_Returned(
            GetVacancyQuery query,
            GetVacancyApiResponse apiApiResponse,
            GetStandardsListItem courseResponse,
            string findAnApprenticeshipBaseUrl,
            List <string> categories,
            [Frozen] Mock <IFindApprenticeshipApiClient <FindApprenticeshipApiConfiguration> > apiClient,
            [Frozen] Mock <IOptions <VacanciesConfiguration> > vacanciesConfiguration,
            GetVacancyQueryHandler handler)
        {
            apiClient.Setup(x =>
                            x.Get <GetVacancyApiResponse>(It.IsAny <GetVacancyRequest>())).ReturnsAsync((GetVacancyApiResponse)null);

            var actual = await handler.Handle(query, CancellationToken.None);

            actual.Vacancy.Should().BeNull();
        }