public async Task ShouldReturnPayRunDetails()
        {
            _payRunGateway.Setup(g => g.GetPayRunAsync(It.IsAny <Guid>(), It.IsAny <PayRunFields>(), It.IsAny <bool>()))
            .ReturnsAsync(_payrun);
            var pagedInvoices = _fixture.Build <PagedList <PayRunInvoiceDomain> >()
                                .Without(p => p.Capacity)
                                .Create();

            _payRunInvoiceGateway
            .Setup(g => g.GetPayRunInvoicesSummaryAsync(It.IsAny <Guid>(), It.IsAny <PayRunDetailsQueryParameters>()))
            .ReturnsAsync(pagedInvoices);

            var requestParam = new PayRunDetailsQueryParameters()
            {
                PageNumber = 1, PageSize = 11
            };
            var expectedResponse = PayrunExtensions.CreateDetailsViewResponse(_payrun, pagedInvoices, pagedInvoices.PagingMetaData);
            var response         = await _useCase.ExecuteAsync(_payrun.Id, requestParam).ConfigureAwait(false);

            _payRunGateway.Verify(x => x.GetPayRunAsync
                                      (_payrun.Id, It.IsAny <PayRunFields>(), It.IsAny <bool>()), Times.Once);

            _payRunInvoiceGateway.Verify(x => x.GetPayRunInvoicesSummaryAsync
                                             (_payrun.Id, It.Is <PayRunDetailsQueryParameters>(d => d.PageSize == 11 && d.PageNumber == 1)), Times.Once);

            response.Should().BeEquivalentTo(expectedResponse);
        }
Exemplo n.º 2
0
        public async Task <PayRunDetailsViewResponse> ExecuteAsync(Guid payrunId, PayRunDetailsQueryParameters parameters)
        {
            // Get pay run
            var payRun = await _payRunGateway
                         .GetPayRunAsync(payrunId)
                         .EnsureExistsAsync($"Pay Run {payrunId} not found");

            // Get pay run items
            var payRunInvoices =
                await _payRunInvoiceGateway.GetPayRunInvoicesSummaryAsync(payrunId, parameters);

            var result = PayrunExtensions.CreateDetailsViewResponse(payRun, payRunInvoices, payRunInvoices.PagingMetaData);

            return(result);
        }