public async Task Then_TheApprenticeFeedbackApiIsCalledWithTheRequest_And_ReturnsTrainingProviders(
            GetApprenticeTrainingProvidersQuery query,
            [Frozen] Mock <IApprenticeFeedbackApiClient <ApprenticeFeedbackApiConfiguration> > feedbackApiClient,
            GetApprenticeTrainingProvidersQueryHandler handler,
            GetApprenticeTrainingProvidersResult apiResponse)
        {
            feedbackApiClient.Setup(x => x.Get <GetApprenticeTrainingProvidersResult>(
                                        It.Is <GetAllTrainingProvidersForApprenticeRequest>(x => x.ApprenticeId == query.ApprenticeId))).ReturnsAsync(apiResponse);

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

            actual.Should().BeEquivalentTo(apiResponse);
        }
示例#2
0
        public async Task Then_GetsApprenticeFromMediator(
            GetApprenticeTrainingProvidersQuery request,
            GetApprenticeTrainingProvidersResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ProviderController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetApprenticeTrainingProvidersQuery>(x => x.ApprenticeId == request.ApprenticeId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.GetApprenticeTrainingProviders(request);

            Assert.IsNotNull(controllerResult);
            var model = controllerResult.Value;

            Assert.IsNotNull(model);
            model.Should().BeEquivalentTo(mediatorResult);
        }
 public async Task <ActionResult <GetApprenticeTrainingProvidersResult> > GetApprenticeTrainingProviders([FromRoute] GetApprenticeTrainingProvidersQuery request)
 {
     _logger.LogDebug($"Begin Get Apprentice Training Providers for ApprenticeId: {request?.ApprenticeId}");
     // Endpoint updates the relevant targets first if they need to be updated by the Learner Endpoint
     // This will eventually be moved to a daily function app.
     if (request == null)
     {
         // Temp safety check for sonar cloud due to the splitting of commands.
         return(default);