public async Task Then_the_nonsensitive_payment_data_is_logged()
        {
            //Arrange
            var loggerMock = new Mock <ILogger <BusinessCentralFinancePaymentsService> >();

            _sut = new BusinessCentralFinancePaymentsService(_httpClient, 3, "XXX", false, loggerMock.Object);
            _httpClient.SetUpPostAsAsync(HttpStatusCode.Accepted);
            var payment1 = _fixture.Create <PaymentDto>();
            var payment2 = _fixture.Create <PaymentDto>();
            var req1     = _sut.MapToBusinessCentralPaymentRequest(payment1);
            var req2     = _sut.MapToBusinessCentralPaymentRequest(payment2);

            //Act
            await _sut.SendPaymentRequests(new List <PaymentDto> {
                payment1, payment2
            });

            //Assert
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req1.ActivityCode);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req1.AccountCode);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req1.CostCentreCode);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req1.RequestorUniquePaymentIdentifier);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req1.DueDate);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req2.ActivityCode);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req2.AccountCode);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req2.CostCentreCode);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req2.RequestorUniquePaymentIdentifier);
            loggerMock.VerifyLogContains(LogLevel.Information, Times.Once(), req2.DueDate);
        }
        public void Then_the_payment_fields_are_mapped_correctly()
        {
            var payment = _fixture.Build <PaymentDto>().Create();

            var paymentRequest = _sut.MapToBusinessCentralPaymentRequest(payment);

            paymentRequest.RequestorUniquePaymentIdentifier.Should().Be(payment.PaymentId.ToString("N"));
            paymentRequest.Requestor.Should().Be("ApprenticeServiceEI");
            paymentRequest.FundingStream.Code.Should().Be("EIAPP");
            paymentRequest.FundingStream.StartDate.Should().Be("2020-09-01");
            paymentRequest.FundingStream.EndDate.Should().Be("2021-08-30");
            paymentRequest.DueDate.Should().Be(DateTime.UtcNow.ToString("yyyy-MM-dd"));
            paymentRequest.VendorNo.Should().Be(payment.VendorId);
            paymentRequest.CostCentreCode.Should().Be("10233");
            paymentRequest.Amount.Should().Be(payment.Amount);
            paymentRequest.Currency.Should().Be("GBP");
            paymentRequest.ExternalReference.Type.Should().Be("ApprenticeIdentifier");
            paymentRequest.ExternalReference.Value.Should().Be(payment.HashedLegalEntityId);
        }
        public void Then_the_PaymentLineDescription_is_constructed_with_uln_obfuscated(long uln, string expected)
        {
            _sut = new BusinessCentralFinancePaymentsService(_httpClient, 3, "XXX", true, Mock.Of <ILogger <BusinessCentralFinancePaymentsService> >());

            var payment = _fixture.Build <PaymentDto>()
                          .With(x => x.EarningType, EarningType.FirstPayment)
                          .With(x => x.HashedLegalEntityId, "ABCD")

                          .With(x => x.ULN, uln)
                          .Create();

            var paymentRequest = _sut.MapToBusinessCentralPaymentRequest(payment);

            paymentRequest.PaymentLineDescription.Should().Be($"Hire a new apprentice (first payment). Employer: ABCD ULN: {expected}");
        }