public void SetUp() { var fixture = new Fixture(); _ukprn = fixture.Create <long>(); _uln = fixture.Create <long>(); _academicYear1 = fixture.Create <short>(); _academicYear2 = fixture.Create <short>(); _dataLockEventAy1 = fixture.Create <DataLockEventModel>(); _dataLockEventAy2 = fixture.Create <DataLockEventModel>(); _dataLockEventPayablePeriodAy1 = fixture.Create <DataLockEventPayablePeriodModel>(); _dataLockEventPayablePeriodAy2 = fixture.Create <DataLockEventPayablePeriodModel>(); _dataLockEventPriceEpisodeAy1 = fixture.Create <DataLockEventPriceEpisodeModel>(); _dataLockEventPriceEpisodeAy2 = fixture.Create <DataLockEventPriceEpisodeModel>(); var bsContextOption = new DbContextOptionsBuilder <MatchedLearnerDataContext>() .UseInMemoryDatabase($"TestDb-{Guid.NewGuid()}", new InMemoryDatabaseRoot()) .Options; _dataDataContext = new MatchedLearnerDataContext(bsContextOption); var matchLearnerContextFactory = new MatchedLearnerDataContextFactory(bsContextOption); _sut = new MatchedLearnerRepository(_dataDataContext, matchLearnerContextFactory, fixture.Create <Mock <ILogger <MatchedLearnerRepository> > >().Object); }
public void SetUp() { var fixture = new Fixture(); fixture.Behaviors .OfType <ThrowingRecursionBehavior>() .ToList() .ForEach(b => fixture.Behaviors.Remove(b)); fixture.Behaviors.Add(new OmitOnRecursionBehavior()); _ukprn = fixture.Create <long>(); _uln = fixture.Create <long>(); _dataLockEvent = fixture.Create <DataLockEventModel>(); _dataLockEventNonPayablePeriod = fixture.Freeze <DataLockEventNonPayablePeriodModel>(); _dataLockEventPayablePeriod = fixture.Freeze <DataLockEventPayablePeriodModel>(); _dataLockEventPriceEpisode = fixture.Freeze <DataLockEventPriceEpisodeModel>(); _dataLockEventPriceEpisode.PriceEpisodeIdentifier = Guid.NewGuid().ToString(); var dbOptions = new DbContextOptionsBuilder <MatchedLearnerDataContext>() .UseInMemoryDatabase($"TestDb-{Guid.NewGuid()}", new InMemoryDatabaseRoot()) .Options; _dataDataContext = new MatchedLearnerDataContext(dbOptions); var contextFactory = new MatchedLearnerDataContextFactory(dbOptions); _sut = new MatchedLearnerRepository(_dataDataContext, contextFactory, fixture.Create <Mock <ILogger <MatchedLearnerRepository> > >().Object); }
public List <DataLockEventPriceEpisodeModel> Resolve(DataLockEvent source, DataLockEventModel destination, List <DataLockEventPriceEpisodeModel> destMember, ResolutionContext context) { var priceEpisodeModels = source.PriceEpisodes? .Select(priceEpisode => context.Mapper.Map <DataLockEventPriceEpisodeModel>(priceEpisode)) .ToList() ?? new List <DataLockEventPriceEpisodeModel>(); priceEpisodeModels.ForEach(model => model.DataLockEventId = source.EventId); return(priceEpisodeModels); }
public List <DataLockEventPayablePeriodModel> Resolve(DataLockEvent source, DataLockEventModel destination, List <DataLockEventPayablePeriodModel> destMember, ResolutionContext context) { var periods = destination.PayablePeriods ?? new List <DataLockEventPayablePeriodModel>(); periods.AddRange(source.OnProgrammeEarnings? .SelectMany(onProgEarning => onProgEarning.Periods, (onProgEarning, period) => new { onProgEarning, period }) .Select(item => new DataLockEventPayablePeriodModel { TransactionType = (TransactionType)item.onProgEarning.Type, DeliveryPeriod = item.period.Period, Amount = item.period.Amount, PriceEpisodeIdentifier = item.period.PriceEpisodeIdentifier, SfaContributionPercentage = item.period.SfaContributionPercentage, DataLockEventId = source.EventId, LearningStartDate = source.LearningAim.StartDate, ApprenticeshipId = item.period.ApprenticeshipId, ApprenticeshipPriceEpisodeId = item.period.ApprenticeshipPriceEpisodeId, ApprenticeshipEmployerType = item.period.ApprenticeshipEmployerType, }) ?? new List <DataLockEventPayablePeriodModel>() ); periods.AddRange(source.IncentiveEarnings? .SelectMany(incentiveEarning => incentiveEarning.Periods, (incentiveEarning, period) => new { incentiveEarning, period }) .Select(item => new DataLockEventPayablePeriodModel { TransactionType = (TransactionType)item.incentiveEarning.Type, DeliveryPeriod = item.period.Period, Amount = item.period.Amount, PriceEpisodeIdentifier = item.period.PriceEpisodeIdentifier, SfaContributionPercentage = item.period.SfaContributionPercentage, DataLockEventId = source.EventId, LearningStartDate = source.LearningAim.StartDate, ApprenticeshipId = item.period.ApprenticeshipId, ApprenticeshipPriceEpisodeId = item.period.ApprenticeshipPriceEpisodeId, ApprenticeshipEmployerType = item.period.ApprenticeshipEmployerType, }) ?? new List <DataLockEventPayablePeriodModel>() ); return(periods); }
public List <DataLockEventNonPayablePeriodModel> Resolve(DataLockEvent source, DataLockEventModel destination, List <DataLockEventNonPayablePeriodModel> destMember, ResolutionContext context) { var periods = destination.NonPayablePeriods ?? new List <DataLockEventNonPayablePeriodModel>(); periods.AddRange(source.OnProgrammeEarnings? .SelectMany(onProgEarning => onProgEarning.Periods, (onProgEarning, period) => new { onProgEarning, period }) .Select(item => new DataLockEventNonPayablePeriodModel { TransactionType = (TransactionType)item.onProgEarning.Type, DeliveryPeriod = item.period.Period, Amount = item.period.Amount, PriceEpisodeIdentifier = item.period.PriceEpisodeIdentifier, SfaContributionPercentage = item.period.SfaContributionPercentage, DataLockEventId = source.EventId, CensusDate = item.onProgEarning.CensusDate, LearningStartDate = source.LearningAim.StartDate, DataLockEventNonPayablePeriodId = Guid.NewGuid(), Failures = item.period.DataLockFailures?.Select(failure => new DataLockEventNonPayablePeriodFailureModel { ApprenticeshipId = failure.ApprenticeshipId, DataLockFailure = failure.DataLockError, }).ToList() ?? new List <DataLockEventNonPayablePeriodFailureModel>(), }) ?? new List <DataLockEventNonPayablePeriodModel>() ); periods.AddRange(source.IncentiveEarnings? .SelectMany(incentiveEarning => incentiveEarning.Periods, (incentiveEarning, period) => new { incentiveEarning, period }) .Select(item => new DataLockEventNonPayablePeriodModel { TransactionType = (TransactionType)item.incentiveEarning.Type, DeliveryPeriod = item.period.Period, Amount = item.period.Amount, PriceEpisodeIdentifier = item.period.PriceEpisodeIdentifier, SfaContributionPercentage = item.period.SfaContributionPercentage, DataLockEventId = source.EventId, CensusDate = item.incentiveEarning.CensusDate, LearningStartDate = source.LearningAim.StartDate, DataLockEventNonPayablePeriodId = Guid.NewGuid(), Failures = item.period.DataLockFailures?.Select(failure => new DataLockEventNonPayablePeriodFailureModel { ApprenticeshipId = failure.ApprenticeshipId, DataLockFailure = failure.DataLockError }).ToList() ?? new List <DataLockEventNonPayablePeriodFailureModel>(), }) ?? new List <DataLockEventNonPayablePeriodModel>() ); periods.ForEach(period => period.Failures.ForEach(failure => failure.DataLockEventNonPayablePeriodId = period.DataLockEventNonPayablePeriodId)); return(periods); }
public void AssertSingleDataLockEventForPeriod(DataLockEventModel actual, byte collectionPeriod, short academicYear) { actual.Ukprn.Should().Be(_ukprn); actual.ContractType.Should().Be(ContractType.Act1); actual.CollectionPeriod.Should().Be(collectionPeriod); actual.AcademicYear.Should().Be(academicYear); actual.LearnerReferenceNumber.Should().Be("ref#"); actual.LearnerUln.Should().Be(_learnerUln); actual.LearningAimReference.Should().Be("ZPROG001"); actual.LearningAimProgrammeType.Should().Be(100); actual.LearningAimStandardCode.Should().Be(200); actual.LearningAimFrameworkCode.Should().Be(300); actual.LearningAimPathwayCode.Should().Be(400); actual.LearningAimFundingLineType.Should().Be("funding"); actual.IlrSubmissionDateTime.Should().Be(new DateTime(2020, 10, 10)); actual.IsPayable.Should().Be(false); actual.JobId.Should().Be(123); actual.EventTime.Date.Should().Be(DateTimeOffset.Now.Date); actual.LearningStartDate.Should().Be(new DateTime(2020, 10, 09)); //(DataLockEventId, PriceEpisodeIdentifier, SfaContributionPercentage, TotalNegotiatedPrice1, TotalNegotiatedPrice2, TotalNegotiatedPrice3, TotalNegotiatedPrice4, StartDate, EffectiveTotalNegotiatedPriceStartDate, PlannedEndDate, ActualEndDate, NumberOfInstalments, InstalmentAmount, CompletionAmount, Completed) //VALUES (@dataLockEventId2, '25-104-01/08/2020', 1, _ukprn, _learnerUln, 0, 0, '2020-10-07', '2021-01-01', '2020-10-11', '2020-10-12', 12, 50, 550, 0) actual.PriceEpisodes.Count.Should().Be(1); var actualPriceEpisodes = actual.PriceEpisodes.First(); actualPriceEpisodes.DataLockEventId.Should().Be(actual.EventId); actualPriceEpisodes.PriceEpisodeIdentifier.Should().Be("25-104-01/08/2020"); actualPriceEpisodes.SfaContributionPercentage.Should().Be(1); actualPriceEpisodes.TotalNegotiatedPrice1.Should().Be(1000); actualPriceEpisodes.TotalNegotiatedPrice2.Should().Be(2000); actualPriceEpisodes.TotalNegotiatedPrice3.Should().Be(0); actualPriceEpisodes.TotalNegotiatedPrice4.Should().Be(0); actualPriceEpisodes.StartDate.Should().Be(new DateTime(2020, 10, 07)); actualPriceEpisodes.EffectiveTotalNegotiatedPriceStartDate.Should().Be(new DateTime(2021, 01, 01)); actualPriceEpisodes.PlannedEndDate.Should().Be(new DateTime(2020, 10, 11)); actualPriceEpisodes.ActualEndDate.Should().Be(new DateTime(2020, 10, 12)); actualPriceEpisodes.NumberOfInstalments.Should().Be(12); actualPriceEpisodes.InstalmentAmount.Should().Be(50); actualPriceEpisodes.CompletionAmount.Should().Be(550); actualPriceEpisodes.Completed.Should().Be(false); //INSERT INTO Payments2.DataLockEventPayablePeriod (DataLockEventId, PriceEpisodeIdentifier, TransactionType, DeliveryPeriod, Amount, SfaContributionPercentage, LearningStartDate, ApprenticeshipId) //VALUES (@dataLockEventId2, '25-104-01/08/2020', 1, 1, 100, 1, @testDateTime, _apprenticeshipId), // (@dataLockEventId2, '25-104-01/08/2020', 1, 2, 200, 1, @testDateTime, _apprenticeshipId), // (@dataLockEventId2, '25-104-01/08/2020', 1, 3, 300, 1, @testDateTime, _apprenticeshipId) actual.PayablePeriods.Count.Should().Be(3); actual.PayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 1, Amount = 100M, SfaContributionPercentage = 1M, ApprenticeshipId = _apprenticeshipId }); actual.PayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 2, Amount = 200M, SfaContributionPercentage = 1, ApprenticeshipId = _apprenticeshipId }); actual.PayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 3, Amount = 300M, SfaContributionPercentage = 1, ApprenticeshipId = _apprenticeshipId }); //INSERT INTO Payments2.DataLockEventNonPayablePeriod (DataLockEventId, DataLockEventNonPayablePeriodId, PriceEpisodeIdentifier, TransactionType, DeliveryPeriod, Amount, SfaContributionPercentage) //VALUES (@dataLockEventId2, @dataLockEventFailureId1, '25-104-01/08/2020', 1, 3, 400, 1), // (@dataLockEventId2, @dataLockEventFailureId2, '25-104-01/08/2020', 1, 4, 500, 1), // (@dataLockEventId2, @dataLockEventFailureId3, '25-104-01/08/2020', 1, 5, 600, 1), // (@dataLockEventId2, @dataLockEventFailureId4, '25-104-01/08/2020', 1, 6, 600, 1) actual.NonPayablePeriods.Count.Should().Be(4); actual.NonPayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 3, Amount = 400, SfaContributionPercentage = 1, }); actual.NonPayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 4, Amount = 500, SfaContributionPercentage = 1, }); actual.NonPayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 5, Amount = 600, SfaContributionPercentage = 1, }); actual.NonPayablePeriods.Should().ContainEquivalentOf(new { DataLockEventId = actual.EventId, PriceEpisodeIdentifier = "25-104-01/08/2020", TransactionType = 1, DeliveryPeriod = 6, Amount = 600, SfaContributionPercentage = 1, }); //INSERT INTO Payments2.DataLockEventNonPayablePeriodFailures (DataLockEventNonPayablePeriodId, DataLockFailureId, ApprenticeshipId) //VALUES (@dataLockEventFailureId1, 1, _apprenticeshipId), // (@dataLockEventFailureId1, 2, _apprenticeshipId), // (@dataLockEventFailureId1, 3, _apprenticeshipId), // (@dataLockEventFailureId2, 7, _apprenticeshipId), // (@dataLockEventFailureId3, 9, _apprenticeshipId), // (@dataLockEventFailureId4, 1, 9876500) var actualNonPayablePeriodFailures = actual.NonPayablePeriods.SelectMany(np => np.Failures).ToList(); actualNonPayablePeriodFailures.Count.Should().Be(6); actualNonPayablePeriodFailures.Should().ContainEquivalentOf(new { DataLockFailureId = 1, ApprenticeshipId = _apprenticeshipId }); actualNonPayablePeriodFailures.Should().ContainEquivalentOf(new { DataLockFailureId = 2, ApprenticeshipId = _apprenticeshipId }); actualNonPayablePeriodFailures.Should().ContainEquivalentOf(new { DataLockFailureId = 3, ApprenticeshipId = _apprenticeshipId }); actualNonPayablePeriodFailures.Should().ContainEquivalentOf(new { DataLockFailureId = 7, ApprenticeshipId = _apprenticeshipId }); actualNonPayablePeriodFailures.Should().ContainEquivalentOf(new { DataLockFailureId = 9, ApprenticeshipId = _apprenticeshipId }); actualNonPayablePeriodFailures.Should().ContainEquivalentOf(new { DataLockFailureId = 1, ApprenticeshipId = 9876500 }); }
public DataLockEventModel Map(DataLockEventModel dataLockEventModel) { return(mapper.Map <DataLockEventModel, DataLockEventModel>(dataLockEventModel)); }