public void RemoveCarryOversRemovesFromInternalCollectionWhereFundingLineCodeMatches() { string fundingLineCode = NewRandomString(); ProfilingCarryOver customCarryOver = NewCarryOver(_ => _.WithFundingLineCode(fundingLineCode)); ProfilingCarryOver differentFundingLineCarryOver = NewCarryOver(); GivenTheCarryOver(customCarryOver); AndTheCarryOver(differentFundingLineCarryOver); WhenTheFundingLineCarryOverIsRemoved(fundingLineCode); _publishedProviderVersion .CarryOvers .Should() .BeEquivalentTo(differentFundingLineCarryOver); }
private bool HasNoCarryOverChanges(PublishedProviderVersion priorState, PublishedProviderVersion refreshState, ProviderVariationContext providerVariationContext) { bool hasNoCarryOverChanges = true; foreach (ProfilingCarryOver carryOver in priorState.CarryOvers ?? ArraySegment <ProfilingCarryOver> .Empty) { ProfilingCarryOver latestCustomProfile = refreshState.CarryOvers?.SingleOrDefault(_ => _.FundingLineCode == carryOver.FundingLineCode); if ((latestCustomProfile?.Amount).GetValueOrDefault() != carryOver.Amount) { providerVariationContext.AddAffectedFundingLineCode(carryOver.FundingLineCode); hasNoCarryOverChanges = false; } } return(hasNoCarryOverChanges); }
public void ThenTheUpsertedProviderVersionForHasTheFollowingFundingLineOverPayments(string providerId, IEnumerable <ExpectedFundingLineOverPayment> expectedFundingLineOverPayments) { PublishedProviderVersion publishedProviderVersion = GetUpsertedPublishedProviderVersion(providerId); IEnumerable <ProfilingCarryOver> carryOvers = publishedProviderVersion.CarryOvers ?? new List <ProfilingCarryOver>(); foreach (ExpectedFundingLineOverPayment expectedFundingLineOverPayment in expectedFundingLineOverPayments) { string fundingLineCode = expectedFundingLineOverPayment.FundingLineCode; ProfilingCarryOver carryOver = carryOvers.FirstOrDefault(_ => _.FundingLineCode == fundingLineCode); carryOver .Should() .BeEquivalentTo(new ProfilingCarryOver { FundingLineCode = fundingLineCode, Type = ProfilingCarryOverType.DSGReProfiling, Amount = expectedFundingLineOverPayment.OverPayment }); } }
private void AndTheFundingLineOverPaymentShouldBe(decimal?expectedOverPayment) { IEnumerable <ProfilingCarryOver> overPayments = VariationContext.RefreshState.CarryOvers; if (expectedOverPayment == null) { overPayments .Should() .BeNull(); } else { ProfilingCarryOver carryOver = overPayments.FirstOrDefault(_ => _.FundingLineCode == _fundingLineCode); carryOver .Should() .BeEquivalentTo(new ProfilingCarryOver { Type = ProfilingCarryOverType.DSGReProfiling, Amount = expectedOverPayment.GetValueOrDefault(), FundingLineCode = _fundingLineCode }); } }
private void AndTheCarryOver(ProfilingCarryOver carryOver) => GivenTheCarryOver(carryOver);
private void GivenTheCarryOver(ProfilingCarryOver carryOver) { _publishedProviderVersion.CarryOvers ??= new List <ProfilingCarryOver>(); _publishedProviderVersion.CarryOvers.Add(carryOver); }