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);
        }
Exemplo n.º 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);
        }