public void Then_an_exception_is_thrown_when_the_pending_payment_does_not_exist() { // act Action result = () => _sut.CreatePayment(Guid.NewGuid(), _collectionPeriod.AcademicYear, _collectionPeriod.PeriodNumber); // assert result.Should().Throw <ArgumentException>().WithMessage("Pending payment does not exist."); }
public async Task Then_earnings_with_sent_payments_are_clawed_back_when_the_collection_period_has_changed() { // arrange await _sut.CalculateEarnings(_mockPaymentProfilesService.Object, _mockCollectionCalendarService.Object); byte collectionPeriod = 6; short collectionYear = 2020; var pendingPayment = _sutModel.PendingPaymentModels.Single(x => x.EarningType == EarningType.FirstPayment); pendingPayment.PendingPaymentValidationResultModels = new List <PendingPaymentValidationResultModel>(); pendingPayment.PendingPaymentValidationResultModels.Add(_fixture.Build <PendingPaymentValidationResultModel>().With(x => x.CollectionPeriod, new CollectionPeriod(collectionPeriod, collectionYear)).With(x => x.Result, true).Create()); _sut.CreatePayment(pendingPayment.Id, collectionPeriod, collectionPeriod); _sutModel.PaymentModels.First().PaidDate = DateTime.Now; _collectionPeriods.Add(new CollectionPeriod(4, (byte)_collectionPeriod.AddMonths(3).Month, (short)_collectionPeriod.AddMonths(3).Year, _collectionPeriod.AddMonths(3).AddDays(1), _fixture.Create <DateTime>(), _fixture.Create <short>(), true)); // act _sut.SetStartDate(_plannedStartDate.AddMonths(1)); await _sut.CalculateEarnings(_mockPaymentProfilesService.Object, _mockCollectionCalendarService.Object); // assert pendingPayment.ClawedBack.Should().BeTrue(); _sutModel.PendingPaymentModels.Count(x => x.EarningType == EarningType.FirstPayment).Should().Be(2); }
public void Then_the_payment_is_created(DateTime dob, DateTime plannedStartDate, ApprenticeshipEmployerType employerType, SubnominalCode expectedSubnominalCode) { // arrange var apprenticeship = new Apprenticeship(_fixture.Create <long>(), _fixture.Create <string>(), _fixture.Create <string>(), dob, _fixture.Create <long>(), employerType, _fixture.Create <string>()); _sutModel = _fixture.Build <ApprenticeshipIncentiveModel>() .With(x => x.StartDate, plannedStartDate) .With(x => x.Apprenticeship, apprenticeship) .With(x => x.PaymentModels, new List <PaymentModel>()).Create(); _sut = Sut(_sutModel); var pendingPayment = _sut.PendingPayments.First(); // act _sut.CreatePayment(pendingPayment.Id, _collectionPeriod.AcademicYear, _collectionPeriod.PeriodNumber); // assert _sut.Payments.Count.Should().Be(1); var actualPayment = _sut.Payments.First(); actualPayment.SubnominalCode.Should().Be(expectedSubnominalCode); }