public void GetFundedPaymentsShouldCallAllPaymentProcessors()
        {
            // Arrange
            var message = new CalculatedRequiredCoInvestedAmount();
            var requiredCoInvestedPayment = new RequiredCoInvestedPayment();
            var fundingSourcePayment      = new EmployerCoInvestedPayment();

            var sfaPaymentProcessor      = new Mock <ICoInvestedPaymentProcessorOld>(MockBehavior.Strict);
            var employerPaymentProcessor = new Mock <ICoInvestedPaymentProcessorOld>(MockBehavior.Strict);

            var sfaPaymentEvent = new SfaCoInvestedFundingSourcePaymentEvent();

            var mapper = new Mock <ICoInvestedFundingSourcePaymentEventMapper>(MockBehavior.Strict);

            mapper.Setup(o => o.MapToRequiredCoInvestedPayment(message)).Returns(requiredCoInvestedPayment);
            mapper.Setup(o => o.MapToCoInvestedPaymentEvent(message, fundingSourcePayment)).Returns(sfaPaymentEvent);

            sfaPaymentProcessor
            .Setup(o => o.Process(requiredCoInvestedPayment)).Returns(fundingSourcePayment)
            .Verifiable();

            employerPaymentProcessor
            .Setup(o => o.Process(requiredCoInvestedPayment)).Returns(fundingSourcePayment)
            .Verifiable();

            var paymentProcessors = new List <ICoInvestedPaymentProcessorOld>
            {
                sfaPaymentProcessor.Object,
                employerPaymentProcessor.Object
            };

            // Act
            var handler = new CoInvestedFundingSourceService(paymentProcessors, mapper.Object);

            handler.GetFundedPayments(message);

            //Assert
            sfaPaymentProcessor.Verify();
            employerPaymentProcessor.Verify();
        }
Exemple #2
0
        public void TestMapToValidSfaCoInvestedFundingSourcePaymentEvent()
        {
            var expectedEvent = new SfaCoInvestedFundingSourcePaymentEvent();

            PopulateCommonProperties(expectedEvent);

            var actualEvent = new LevyFundingSourcePaymentEvent
            {
                AmountDue         = 55,
                FundingSourceType = FundingSourceType.Levy
            };

            // act
            autoMapper.Map(requiredPaymentEvent, actualEvent);

            // assert
            actualEvent.EventTime.Should().NotBe(expectedEvent.EventTime);
            actualEvent.EventId.Should().NotBe(expectedEvent.EventId);
            actualEvent.EventTime = expectedEvent.EventTime;
            actualEvent.EventId   = expectedEvent.EventId;
            actualEvent.Should().BeEquivalentTo(expectedEvent);
        }
        public void ShouldMapToValidSfaCoInvestedFundingSourcePaymentEvent()
        {
            //Arrange
            var coInvestedPayment = new SfaCoInvestedPayment
            {
                AmountDue = 900.00m,
                Type      = FundingSourceType.CoInvestedSfa,
            };

            var expectedPayment = new SfaCoInvestedFundingSourcePaymentEvent
            {
                RequiredPaymentEventId = requiredCoInvestedAmount.EventId,
                AmountDue    = 900.00m,
                ContractType = ContractType.Act2,
                SfaContributionPercentage = requiredCoInvestedAmount.SfaContributionPercentage,
                CollectionPeriod          = requiredCoInvestedAmount.CollectionPeriod,
                DeliveryPeriod            = requiredCoInvestedAmount.DeliveryPeriod,
                EventTime                  = requiredCoInvestedAmount.EventTime,
                JobId                      = requiredCoInvestedAmount.JobId,
                Learner                    = requiredCoInvestedAmount.Learner,
                TransactionType            = (TransactionType)requiredCoInvestedAmount.OnProgrammeEarningType,
                LearningAim                = requiredCoInvestedAmount.LearningAim,
                PriceEpisodeIdentifier     = requiredCoInvestedAmount.PriceEpisodeIdentifier,
                Ukprn                      = requiredCoInvestedAmount.Ukprn,
                FundingSourceType          = FundingSourceType.CoInvestedSfa,
                AccountId                  = 1000000,
                ApprenticeshipEmployerType = requiredCoInvestedAmount.ApprenticeshipEmployerType,
            };

            var actualSfaCoInvestedPayment = coInvestedFundingMapper.MapToCoInvestedPaymentEvent(requiredCoInvestedAmount, coInvestedPayment);

            expectedPayment.EventId   = actualSfaCoInvestedPayment.EventId;
            expectedPayment.EventTime = actualSfaCoInvestedPayment.EventTime;

            actualSfaCoInvestedPayment.Should().BeEquivalentTo(expectedPayment);
        }