public void Summarise_FundingStreams() { List <FundingStream> fundingStreams = GetFundingTypes() .Where(w => w.SummarisationType == "ESF_SuppData") .SelectMany(ft => ft.FundingStreams).ToList(); int ukprn = GetProviders().First(); var allocation = GetContractAllocation(ukprn); var task = new SummarisationDeliverableProcess(); var result = task.Summarise(fundingStreams, GetTestProvider(ukprn), allocation, GetCollectionPeriods()); result.Count(w => w.DeliverableCode == 5).Should().Be(67); result.Count(w => w.DeliverableCode == 6).Should().Be(67); result.Count(w => w.DeliverableCode == 7).Should().Be(67); foreach (var item in result) { item.ActualValue.Should().Be(2 * periodValue); var fl = fundingStreams.Where(s => s.DeliverableLineCode == item.DeliverableCode).Select(s => s.DeliverableLines).FirstOrDefault(); item.ActualVolume.Should().Be(fl.FirstOrDefault()?.CalculateVolume == true ? 2 : 0); } }
public void Summarise_FundingStream() { FundingStream fundingStream = GetFundingTypes() .SelectMany(ft => ft.FundingStreams) .Where(fs => fs.PeriodCode == "ESF1420" && fs.DeliverableLineCode == 5).FirstOrDefault(); int ukprn = GetProviders().First(); var allocation = GetContractAllocation(ukprn); var task = new SummarisationDeliverableProcess(); var result = task.Summarise(fundingStream, GetTestProvider(ukprn), allocation, GetCollectionPeriods()); result.Count.Should().Be(67); foreach (var item in result) { item.ActualValue.Should().Be(2 * periodValue); var fl = fundingStream.DeliverableLines.FirstOrDefault(); item.ActualVolume.Should().Be(fl?.CalculateVolume == true ? 2 : 0); } }
public void Summarise_CheckRounding(decimal value1, decimal value2, decimal result) { FundingStream fundingStream = GetFundingTypes() .SelectMany(ft => ft.FundingStreams) .Single(fs => fs.PeriodCode == "ESF1420" && fs.DeliverableLineCode == 1); int ukprn = GetProviders().First(); var allocation = GetContractAllocation(ukprn); var periods = new List <Period>() { new Period() { PeriodId = 1, CalendarMonth = 8, CalendarYear = 2018, Value = value1, }, new Period() { PeriodId = 1, CalendarMonth = 8, CalendarYear = 2018, Value = value2, }, }; List <PeriodisedData> periodisedDatas = new List <PeriodisedData>() { new PeriodisedData() { AttributeName = "StartEarnings", DeliverableCode = "ST01", Periods = periods, }, }; List <LearningDelivery> learningDeliveries = new List <LearningDelivery>() { new LearningDelivery() { ConRefNumber = "All10000001-1", PeriodisedData = periodisedDatas, }, }; LearningProvider testProvider = new LearningProvider() { UKPRN = ukprn, LearningDeliveries = learningDeliveries, }; var task = new SummarisationDeliverableProcess(); var results = task.Summarise(fundingStream, testProvider, allocation, GetCollectionPeriods()); results.Count.Should().Be(12); results.FirstOrDefault(w => w.ActualValue > 0).ActualValue.Should().Be(result); }
public void Summarise_Providers() { List <FundingStream> fundingStreams = GetFundingTypes() .Where(w => w.SummarisationType == "ESF_ILR_And_Supp") .SelectMany(ft => ft.FundingStreams).ToList(); foreach (var ukprn in GetProviders()) { ICollection <FcsContractAllocation> fcsContractAllocations = new List <FcsContractAllocation>(); for (int i = 1; i <= Contracts; i++) { FcsContractAllocation allocation = new FcsContractAllocation() { ContractAllocationNumber = $"All{ukprn}-{i}", FundingStreamPeriodCode = "ESF1420", DeliveryUkprn = ukprn, DeliveryOrganisation = $"Org{ukprn}", ActualsSchemaPeriodStart = 201808, ActualsSchemaPeriodEnd = 201907, }; fcsContractAllocations.Add(allocation); } var summarisationMessageMock = new Mock <ISummarisationMessage>(); var task = new SummarisationDeliverableProcess(); var result = task.Summarise(fundingStreams, GetTestProvider(ukprn), fcsContractAllocations, GetCollectionPeriods(), summarisationMessageMock.Object); foreach (var allocation in fcsContractAllocations) { result.Count(w => w.ContractAllocationNumber == allocation.ContractAllocationNumber && w.DeliverableCode == 1).Should().Be(12); result.Count(w => w.ContractAllocationNumber == allocation.ContractAllocationNumber && w.DeliverableCode == 4).Should().Be(12); result.Count(w => w.ContractAllocationNumber == allocation.ContractAllocationNumber && w.DeliverableCode == 18).Should().Be(12); foreach (var item in result.Where(w => w.DeliverableCode == 1 || w.DeliverableCode == 4 || w.DeliverableCode == 18)) { item.ActualValue.Should().Be(100); var fl = fundingStreams.Where(s => s.DeliverableLineCode == item.DeliverableCode).Select(s => s.DeliverableLines).FirstOrDefault(); item.ActualVolume.Should().Be(fl?.FirstOrDefault()?.CalculateVolume == true ? 100 : 0); } } } }
public void Summarise_withMissingPeriods() { var task = new SummarisationDeliverableProcess(); DeliverableLine fundLine = new DeliverableLine() { CalculateVolume = true }; var result = task.SummarisePeriods(GetPeriodsData(1).Take(10).ToList(), fundLine, GetCollectionPeriods(), GetContractAllocation(GetProviders().First())); result.Count.Should().Be(67); result.Count(w => w.ActualValue == 0 && w.ActualVolume == 0).Should().Be(57); }
public void SummarisePeriodsTest_NoVolume() { var task = new SummarisationDeliverableProcess(); DeliverableLine fundLine = new DeliverableLine() { CalculateVolume = false }; var result = task.SummarisePeriods(GetPeriodsData(5), fundLine, GetCollectionPeriods(), GetContractAllocation(GetProviders().First())); result.Count.Should().Be(67); foreach (var item in result) { item.ActualValue.Should().Be(5 * periodValue); item.ActualVolume.Should().Be(0); } }