private void AssertPeriodForEntity(Data.CollectionPeriod period, PeriodEntity entity) { Assert.AreEqual(period.Id, $"{entity.AcademicYear}-R{entity.Period:D2}"); Assert.AreEqual(period.CalendarMonth, PeriodExtensions.GetMonthFromPaymentEntity(entity.Period)); Assert.AreEqual(period.CalendarYear, PeriodExtensions.GetYearFromPaymentEntity(entity.AcademicYear, entity.Period)); Assert.AreEqual(period.AccountDataValidAt, entity.ReferenceDataValidationDate); Assert.AreEqual(period.CommitmentDataValidAt, entity.ReferenceDataValidationDate); Assert.AreEqual(period.CompletionDateTime, entity.CompletionDate); }
public async Task ThenTheDataIsCorrect() { var results = await IntegrationTestServer.GetInstance().Client.GetAsync($"/api/payments?employerAccountId={TestData.EmployerAccountId}").ConfigureAwait(false); var resultsAsString = await results.Content.ReadAsStringAsync().ConfigureAwait(false); var result = JsonConvert.DeserializeObject <PageOfResults <Payment> >(resultsAsString); for (var i = 0; i < 250; i++) { var randomReturnedPayment = result.Items[new Random().Next(10000)]; var matchingPayment = TestData.Payments.Single(x => x.EventId == Guid.Parse(randomReturnedPayment.Id)); randomReturnedPayment.Amount.Should().Be(matchingPayment.Amount); randomReturnedPayment.ApprenticeshipId.Should().Be(matchingPayment.ApprenticeshipId); randomReturnedPayment.CollectionPeriod.Month.Should().Be(PeriodExtensions.GetMonthFromPaymentEntity(matchingPayment.CollectionPeriod)); randomReturnedPayment.CollectionPeriod.Year.Should().Be(PeriodExtensions.GetYearFromPaymentEntity(matchingPayment.AcademicYear, matchingPayment.CollectionPeriod)); randomReturnedPayment.CollectionPeriod.Id.Should().Be(matchingPayment.GetPeriodId()); ((byte)randomReturnedPayment.ContractType).Should().Be(matchingPayment.ContractType); randomReturnedPayment.DeliveryPeriod.Month.Should().Be(PeriodExtensions.GetMonthFromPaymentEntity(matchingPayment.DeliveryPeriod)); randomReturnedPayment.DeliveryPeriod.Year.Should().Be(PeriodExtensions.GetYearFromPaymentEntity(matchingPayment.AcademicYear, matchingPayment.DeliveryPeriod)); randomReturnedPayment.EarningDetails.Count.Should().Be(1); var earningDetails = randomReturnedPayment.EarningDetails.Single(); earningDetails.ActualEndDate.Should().BeCloseTo(matchingPayment.EarningsActualEndDate.GetValueOrDefault(), 1000); earningDetails.CompletionAmount.Should().Be(matchingPayment.EarningsCompletionAmount); earningDetails.CompletionStatus.Should().Be(matchingPayment.EarningsCompletionStatus); earningDetails.EndpointAssessorId.Should().BeNull(); earningDetails.MonthlyInstallment.Should().Be(matchingPayment.EarningsInstalmentAmount); earningDetails.PlannedEndDate.Should().BeCloseTo(matchingPayment.EarningsPlannedEndDate.GetValueOrDefault(), 1000); earningDetails.RequiredPaymentId.Should().Be(matchingPayment.RequiredPaymentEventId.GetValueOrDefault()); earningDetails.StartDate.Should().BeCloseTo(matchingPayment.EarningsStartDate, 1000); earningDetails.TotalInstallments.Should().Be(matchingPayment.EarningsNumberOfInstalments); randomReturnedPayment.EmployerAccountId.Should().Be(matchingPayment.AccountId.ToString()); randomReturnedPayment.EmployerAccountVersion.Should().BeNullOrEmpty(); randomReturnedPayment.EvidenceSubmittedOn.Should().BeCloseTo(matchingPayment.IlrSubmissionDateTime, 1000); randomReturnedPayment.FrameworkCode.Should().Be(matchingPayment.LearningAimFrameworkCode); randomReturnedPayment.FundingAccountId.Should().BeNull(); ((byte)randomReturnedPayment.FundingSource).Should().Be(matchingPayment.FundingSource); //byte cast? randomReturnedPayment.Id.ToLower().Should().Be(matchingPayment.EventId.ToString().ToLower()); randomReturnedPayment.PathwayCode.Should().Be(matchingPayment.LearningAimPathwayCode); randomReturnedPayment.ProgrammeType.Should().Be(matchingPayment.LearningAimProgrammeType); randomReturnedPayment.StandardCode.Should().Be(matchingPayment.LearningAimStandardCode); ((byte)randomReturnedPayment.TransactionType).Should().Be(matchingPayment.TransactionType); //byte cast? randomReturnedPayment.Ukprn.Should().Be(matchingPayment.Ukprn); randomReturnedPayment.Uln.Should().Be(matchingPayment.LearnerUln); } }