public async Task ShouldRemoveOnlyCurrentSuccessfulProviderJobSubmission()
        {
            var keys = new List <string> {
                "1", "2"
            };
            var successfulUkprn       = 23456;
            var requiredPaymentEvent1 = new CalculatedRequiredLevyAmount
            {
                EventId   = Guid.NewGuid(),
                AmountDue = 100,
                SfaContributionPercentage = 11,
                OnProgrammeEarningType    = OnProgrammeEarningType.Completion,
                Learner          = new Learner(),
                CollectionPeriod = new CollectionPeriod {
                    AcademicYear = 1920, Period = 1
                },
                Ukprn     = 123456,
                AccountId = 1,
                JobId     = 1
            };
            var requiredPaymentEvent2 = new CalculatedRequiredLevyAmount
            {
                EventId   = Guid.NewGuid(),
                AmountDue = 100,
                SfaContributionPercentage = 11,
                OnProgrammeEarningType    = OnProgrammeEarningType.Completion,
                Learner          = new Learner(),
                CollectionPeriod = new CollectionPeriod {
                    AcademicYear = 1920, Period = 1
                },
                Ukprn     = successfulUkprn,
                AccountId = 1,
                JobId     = 2
            };

            generateSortedPaymentKeysMock
            .Setup(x => x.GeyKeys())
            .ReturnsAsync(keys)
            .Verifiable();

            eventCacheMock.Setup(c => c.TryGet("1", CancellationToken.None))
            .ReturnsAsync(() => new ConditionalValue <CalculatedRequiredLevyAmount>(true, requiredPaymentEvent1))
            .Verifiable();
            eventCacheMock.Setup(c => c.TryGet("2", CancellationToken.None))
            .ReturnsAsync(() => new ConditionalValue <CalculatedRequiredLevyAmount>(true, requiredPaymentEvent2))
            .Verifiable();

            eventCacheMock.Setup(c => c.Clear("2", CancellationToken.None)).Returns(Task.CompletedTask).Verifiable();


            // act
            await service.RemoveCurrentSubmission(requiredPaymentEvent2.JobId,
                                                  requiredPaymentEvent2.CollectionPeriod.Period,
                                                  requiredPaymentEvent2.CollectionPeriod.AcademicYear,
                                                  requiredPaymentEvent2.IlrSubmissionDateTime,
                                                  requiredPaymentEvent2.Ukprn);

            // assert
        }
예제 #2
0
        public async Task RemoveCurrentSubmission(SubmissionFailedEvent message)
        {
            paymentLogger.LogVerbose($"Handling ProcessCurrentSubmissionDeletionCommand for {Id}, Job: {message.JobId}");
            try
            {
                using (var operation = telemetry.StartOperation())
                {
                    await fundingSourceService.RemoveCurrentSubmission(message.JobId, message.CollectionPeriod, message.AcademicYear, message.IlrSubmissionDateTime, message.Ukprn);

                    telemetry.StopOperation(operation);
                }
            }
            catch (Exception ex)
            {
                paymentLogger.LogError($"Failed to remove current submission required payments. Error: {ex.Message}", ex);
                throw;
            }
        }