public async Task And_UpdateProviderPaymentsPriority_Succeeds_Then_Redirect_To_Home(
            Mock <ICommitmentsApiClient> mockCommitmentsApiClient,
            UpdateProviderPaymentsPriorityRequest request,
            PaymentOrderViewModel viewModel,
            [Frozen] Mock <IModelMapper> mockMapper,
            PaymentOrderController controller)
        {
            mockMapper
            .Setup(mapper => mapper.Map <UpdateProviderPaymentsPriorityRequest>(viewModel))
            .ReturnsAsync(request);

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

            var expectedRouteValues = new RouteValueDictionary(new
            {
                viewModel.AccountHashedId
            });

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

            result.Should().NotBeNull();
            result.ActionName.Should().Be("Index");
            result.ControllerName.Should().Be("Home");
            result.RouteValues.Should().BeEquivalentTo(expectedRouteValues);
        }
        public async Task UpdateProviderPaymentPriority_VerifyUrlAndDataIsCorrectPassedIn()
        {
            //Arrange
            var accountId = 123;
            var request   = new UpdateProviderPaymentsPriorityRequest
            {
                ProviderPriorities = new List <UpdateProviderPaymentsPriorityRequest.ProviderPaymentPriorityUpdateItem>(),
                UserInfo           = new UserInfo()
            };

            //Act
            await _fixture.CommitmentsApiClient.UpdateProviderPaymentsPriority(accountId, request, CancellationToken.None);

            // Assert
            _fixture.MockRestHttpClient.Verify(x => x.PostAsJson($"api/accounts/{accountId}/update-provider-payments-priority", request, CancellationToken.None));
        }
        public async Task <IActionResult> UpdateProviderPaymentsPriority(long accountId, [FromBody] UpdateProviderPaymentsPriorityRequest request)
        {
            await _mediator.Send(new UpdateProviderPaymentsPriorityCommand(
                                     accountId,
                                     request.ProviderPriorities.Select(p => new UpdateProviderPaymentsPriorityCommand.ProviderPaymentPriorityUpdateItem
            {
                ProviderId = p.ProviderId,
                PriorityOrder = p.PriorityOrder
            }).ToList(),
                                     request.UserInfo));

            return(Ok());
        }
コード例 #4
0
 public Task UpdateProviderPaymentsPriority(long accountId, UpdateProviderPaymentsPriorityRequest request, CancellationToken cancellationToken = default)
 {
     return(_client.PostAsJson($"api/accounts/{accountId}/update-provider-payments-priority", request, cancellationToken));
 }