Exemplo n.º 1
0
        public async Task And_TransferDetailsForSender_Succeeds_Then_Api_Called_To_Update(
            Mock <ICommitmentsApiClient> mockCommitmentsApiClient,
            Mock <ILogger <TransferRequestController> > mockLogger,
            UpdateTransferApprovalForSenderRequest request,
            TransferRequestForSenderViewModel viewModel,
            [Frozen] Mock <IModelMapper> mockMapper)
        {
            mockMapper
            .Setup(mapper => mapper.Map <UpdateTransferApprovalForSenderRequest>(viewModel))
            .ReturnsAsync(request);

            mockCommitmentsApiClient
            .Setup(r => r.UpdateTransferRequestForSender(
                       It.IsAny <long>(),
                       It.IsAny <long>(),
                       It.IsAny <long>(),
                       It.IsAny <UpdateTransferApprovalForSenderRequest>(),
                       It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);

            TransferRequestController controller = new TransferRequestController(mockCommitmentsApiClient.Object,
                                                                                 mockLogger.Object, mockMapper.Object);

            var result = (await controller.TransferDetailsForSender(viewModel)) as RedirectToActionResult;

            mockCommitmentsApiClient.Verify(m => m.UpdateTransferRequestForSender(
                                                It.IsAny <long>(),
                                                It.IsAny <long>(),
                                                It.IsAny <long>(),
                                                It.IsAny <UpdateTransferApprovalForSenderRequest>(),
                                                It.IsAny <CancellationToken>()), Times.Once);
        }
Exemplo n.º 2
0
        public async Task And_TransferDetailsForSender_Succeeds_Then_Redirect_To_Confirmation(
            UpdateTransferApprovalForSenderRequest request,
            TransferRequestForSenderViewModel viewModel,
            [Frozen] Mock <IModelMapper> mockMapper,
            [Greedy] TransferRequestController controller)
        {
            mockMapper
            .Setup(mapper => mapper.Map <UpdateTransferApprovalForSenderRequest>(viewModel))
            .ReturnsAsync(request);

            var result = (await controller.TransferDetailsForSender(viewModel)) as RedirectToActionResult;

            result.Should().NotBeNull();
            result.ActionName.Should().Be("TransferConfirmation");
            result.ControllerName.Should().Be("TransferRequest");
        }