private static ProviderVariation CreateProviderVariationFromAllocationNotificationFeedIndexItem( AllocationNotificationFeedIndex firstEntry) { ProviderVariation providerVariation = new ProviderVariation(); if (!firstEntry.VariationReasons.IsNullOrEmpty()) { providerVariation.VariationReasons = new Collection <string>(firstEntry.VariationReasons); } if (!firstEntry.Successors.IsNullOrEmpty()) { List <ProviderInformationModel> providerInformationModels = firstEntry.Successors.Select(fi => new ProviderInformationModel() { Ukprn = fi }).ToList(); providerVariation.Successors = new Collection <ProviderInformationModel>(providerInformationModels); } if (!firstEntry.Predecessors.IsNullOrEmpty()) { List <ProviderInformationModel> providerInformationModels = firstEntry.Predecessors.Select(fi => new ProviderInformationModel() { Ukprn = fi }).ToList(); providerVariation.Predecessors = new Collection <ProviderInformationModel>(providerInformationModels); } providerVariation.OpenReason = firstEntry.OpenReason; providerVariation.CloseReason = firstEntry.CloseReason; return(providerVariation); }
private ProviderResultSummary CreateProviderResultSummary(IEnumerable <AllocationNotificationFeedIndex> entries, HttpRequest request) { ///TODO: Require permanent fix if (entries.First().ProviderUkPrn == "10080459") { entries = entries.Where(m => m.ProviderStatus == "Closed"); } IEnumerable <IGrouping <string, AllocationNotificationFeedIndex> > fundingPeriodResultSummaryGroups = entries.GroupBy(m => m.FundingPeriodId); AllocationNotificationFeedIndex firstEntry = entries.First(); ProviderResultSummary providerResutSummary = new ProviderResultSummary { Provider = new AllocationProviderModel { Name = firstEntry.ProviderName, LegalName = firstEntry.ProviderLegalName, UkPrn = firstEntry.ProviderUkPrn, Upin = firstEntry.ProviderUpin, Urn = firstEntry.ProviderUrn, DfeEstablishmentNumber = firstEntry.DfeEstablishmentNumber, EstablishmentNumber = firstEntry.EstablishmentNumber, LaCode = firstEntry.LaCode, LocalAuthority = firstEntry.Authority, Type = firstEntry.ProviderType, SubType = firstEntry.SubProviderType, OpenDate = firstEntry.ProviderOpenDate, CloseDate = firstEntry.ProviderClosedDate, CrmAccountId = firstEntry.CrmAccountId, NavVendorNo = firstEntry.NavVendorNo, Status = firstEntry.ProviderStatus } }; foreach (IGrouping <string, AllocationNotificationFeedIndex> fundingPeriodResultSummaryGroup in fundingPeriodResultSummaryGroups) { AllocationNotificationFeedIndex firstPeriodEntry = fundingPeriodResultSummaryGroup.First(); ProviderPeriodResultSummary providerPeriodResultSummary = new ProviderPeriodResultSummary { Period = new Period { Id = firstPeriodEntry.FundingPeriodId, Name = firstPeriodEntry.FundingStreamPeriodName, StartYear = firstPeriodEntry.FundingPeriodStartYear, EndYear = firstPeriodEntry.FundingPeriodEndYear } }; IEnumerable <IGrouping <string, AllocationNotificationFeedIndex> > fundingStreamResultSummaryGroups = fundingPeriodResultSummaryGroup.GroupBy(m => m.FundingStreamId); foreach (IGrouping <string, AllocationNotificationFeedIndex> fundingStreamResultSummaryGroup in fundingStreamResultSummaryGroups) { AllocationNotificationFeedIndex feedIndex = fundingStreamResultSummaryGroup.First(); FundingStreamResultSummary fundingStreamResultSummary = new FundingStreamResultSummary { FundingStream = new AllocationFundingStreamModel { Id = feedIndex.FundingStreamId, Name = feedIndex.FundingStreamName, ShortName = feedIndex.FundingStreamShortName, PeriodType = new AllocationFundingStreamPeriodTypeModel { Id = feedIndex.FundingStreamPeriodId, Name = feedIndex.FundingStreamPeriodName, StartDay = feedIndex.FundingStreamStartDay, StartMonth = feedIndex.FundingStreamStartMonth, EndDay = feedIndex.FundingStreamEndDay, EndMonth = feedIndex.FundingStreamEndMonth } } }; foreach (AllocationNotificationFeedIndex allocationFeedIndex in fundingStreamResultSummaryGroup) { fundingStreamResultSummary.Allocations.Add(new AllocationResult { AllocationLine = new AllocationLine { Id = allocationFeedIndex.AllocationLineId, Name = allocationFeedIndex.AllocationLineName, ShortName = allocationFeedIndex.AllocationLineShortName, FundingRoute = allocationFeedIndex.AllocationLineFundingRoute, ContractRequired = allocationFeedIndex.AllocationLineContractRequired ? "Y" : "N" }, AllocationVersionNumber = (ushort)allocationFeedIndex.AllocationVersionNumber, AllocationStatus = allocationFeedIndex.AllocationStatus, AllocationAmount = Convert.ToDecimal(allocationFeedIndex.AllocationAmount), ProfilePeriods = JsonConvert.DeserializeObject <IEnumerable <ProfilingPeriod> >(allocationFeedIndex.ProviderProfiling).Select( m => new ProfilePeriod(m.Period, m.Occurrence, m.Year.ToString(), m.Type, m.Value, m.DistributionPeriod)).ToArraySafe() }); } fundingStreamResultSummary.TotalAmount = fundingStreamResultSummary.Allocations.Sum(m => m.AllocationAmount); if (!string.IsNullOrWhiteSpace(feedIndex.PolicySummaries)) { IEnumerable <PublishedProviderResultsPolicySummary> policySummaries = JsonConvert.DeserializeObject <IEnumerable <PublishedProviderResultsPolicySummary> >(feedIndex.PolicySummaries); foreach (PublishedProviderResultsPolicySummary publishedPolicySummaryResult in policySummaries) { PolicyResult policyResult = new PolicyResult { Policy = new Policy { PolicyId = publishedPolicySummaryResult.Policy.Id, PolicyName = publishedPolicySummaryResult.Policy.Name, PolicyDescription = publishedPolicySummaryResult.Policy.Description } }; foreach (PublishedProviderResultsCalculationSummary publishedCalculationSummary in publishedPolicySummaryResult.Calculations) { policyResult.Calculations.Add(new Models.CalculationResult { CalculationName = publishedCalculationSummary.Name, CalculationVersionNumber = (ushort)publishedCalculationSummary.Version, CalculationType = publishedCalculationSummary.CalculationType.ToString(), CalculationAmount = publishedCalculationSummary.Amount }); } if (!publishedPolicySummaryResult.Policies.IsNullOrEmpty()) { foreach (PublishedProviderResultsPolicySummary subPolicy in publishedPolicySummaryResult.Policies) { PolicyResult subPolicyResult = new PolicyResult { Policy = new Policy { PolicyId = subPolicy.Policy.Id, PolicyName = subPolicy.Policy.Name, PolicyDescription = subPolicy.Policy.Description } }; foreach (PublishedProviderResultsCalculationSummary publishedCalculationSummary in subPolicy.Calculations) { subPolicyResult.Calculations.Add(new Models.CalculationResult { CalculationName = publishedCalculationSummary.Name, CalculationVersionNumber = (ushort)publishedCalculationSummary.Version, CalculationType = publishedCalculationSummary.CalculationType.ToString(), CalculationAmount = publishedCalculationSummary.Amount }); } subPolicyResult.TotalAmount = subPolicyResult.Calculations.Where(m => m.CalculationType == "Funding").Sum(m => m.CalculationAmount); policyResult.SubPolicyResults.Add(subPolicyResult); } } policyResult.TotalAmount = policyResult.Calculations.Where(m => m.CalculationType == "Funding").Sum(m => m.CalculationAmount); foreach (PolicyResult subPolicyResult in policyResult.SubPolicyResults) { policyResult.TotalAmount = policyResult.TotalAmount + subPolicyResult.Calculations.Where(m => m.CalculationType == "Funding").Sum(m => m.CalculationAmount); } fundingStreamResultSummary.Policies.Add(policyResult); } } providerResutSummary.TotalAmount += fundingStreamResultSummary.TotalAmount; providerPeriodResultSummary.FundingStreamResults.Add(fundingStreamResultSummary); } providerResutSummary.FundingPeriodResults = providerResutSummary.FundingPeriodResults.Concat(new[] { providerPeriodResultSummary }).ToArraySafe(); } return(providerResutSummary); }
private LocalAuthorityResultsSummary CreateLocalAuthorityResultsSummary(IEnumerable <AllocationNotificationFeedIndex> entries, HttpRequest request) { ///TODO: Require permanent fix entries = entries.Where(m => m.ProviderUkPrn != "10080459"); IEnumerable <IGrouping <string, AllocationNotificationFeedIndex> > localAuthorityResultSummaryGroups = entries.GroupBy(m => m.LaCode); AllocationNotificationFeedIndex firstEntry = entries.First(); LocalAuthorityResultsSummary localAuthorityResultsSummary = new LocalAuthorityResultsSummary { FundingPeriod = $"{firstEntry.FundingPeriodStartYear}-{firstEntry.FundingPeriodEndYear}" }; foreach (IGrouping <string, AllocationNotificationFeedIndex> localAuthorityResultSummaryGroup in localAuthorityResultSummaryGroups) { AllocationNotificationFeedIndex firstFeedIndex = localAuthorityResultSummaryGroup.First(); LocalAuthorityResultSummary localAuthorityResultSummary = new LocalAuthorityResultSummary { LANo = firstFeedIndex.LaCode, LAName = firstFeedIndex.Authority }; foreach (AllocationNotificationFeedIndex feedIndex in localAuthorityResultSummaryGroup) { LocalAuthorityProviderResultSummary resultSummary = new LocalAuthorityProviderResultSummary { Provider = new AllocationProviderModel { ProviderId = feedIndex.ProviderId, Name = feedIndex.ProviderName, LegalName = feedIndex.ProviderLegalName, UkPrn = feedIndex.ProviderUkPrn, Upin = feedIndex.ProviderUpin, Urn = feedIndex.ProviderUrn, DfeEstablishmentNumber = feedIndex.DfeEstablishmentNumber, EstablishmentNumber = feedIndex.EstablishmentNumber, LaCode = feedIndex.LaCode, LocalAuthority = feedIndex.Authority, Type = feedIndex.ProviderType, SubType = feedIndex.SubProviderType, OpenDate = feedIndex.ProviderOpenDate, CloseDate = feedIndex.ProviderClosedDate, CrmAccountId = feedIndex.CrmAccountId, NavVendorNo = feedIndex.NavVendorNo, Status = feedIndex.ProviderStatus } }; IEnumerable <IGrouping <string, AllocationNotificationFeedIndex> > fundingPeriodResultSummaryGroups = localAuthorityResultSummaryGroup.GroupBy(m => m.FundingPeriodId); foreach (IGrouping <string, AllocationNotificationFeedIndex> fundingPeriodResultSummaryGroup in fundingPeriodResultSummaryGroups) { AllocationNotificationFeedIndex fundingPeriodFeedIndex = fundingPeriodResultSummaryGroup.First(); FundingPeriodResultSummary fundingPeriodResultSummary = new FundingPeriodResultSummary { Period = new Period { Id = fundingPeriodFeedIndex.FundingPeriodId, Name = fundingPeriodFeedIndex.FundingStreamPeriodName, StartYear = fundingPeriodFeedIndex.FundingPeriodStartYear, EndYear = fundingPeriodFeedIndex.FundingPeriodEndYear }, FundingStream = new AllocationFundingStreamModel { Id = feedIndex.FundingStreamId, Name = feedIndex.FundingStreamName, ShortName = feedIndex.FundingStreamShortName, PeriodType = new AllocationFundingStreamPeriodTypeModel { Id = feedIndex.FundingStreamPeriodId, Name = feedIndex.FundingStreamPeriodName, StartDay = feedIndex.FundingStreamStartDay, StartMonth = feedIndex.FundingStreamStartMonth, EndDay = feedIndex.FundingStreamEndDay, EndMonth = feedIndex.FundingStreamEndMonth } } }; foreach (AllocationNotificationFeedIndex allocationFeedIndex in fundingPeriodResultSummaryGroup) { if (allocationFeedIndex.ProviderId != resultSummary.Provider.ProviderId) { continue; } AllocationResultWIthProfilePeriod allocationResultWIthProfilePeriod = new AllocationResultWIthProfilePeriod { AllocationLine = new AllocationLine { Id = allocationFeedIndex.AllocationLineId, Name = allocationFeedIndex.AllocationLineName, ShortName = allocationFeedIndex.AllocationLineShortName, FundingRoute = allocationFeedIndex.AllocationLineFundingRoute, ContractRequired = allocationFeedIndex.AllocationLineContractRequired ? "Y" : "N" }, AllocationStatus = allocationFeedIndex.AllocationStatus, AllocationVersionNumber = (ushort)allocationFeedIndex.AllocationVersionNumber, AllocationAmount = Convert.ToDecimal(allocationFeedIndex.AllocationAmount) }; resultSummary.AllocationValue += allocationResultWIthProfilePeriod.AllocationAmount; ProfilingPeriod[] profilingPeriods = JsonConvert.DeserializeObject <ProfilingPeriod[]>(allocationFeedIndex.ProviderProfiling); foreach (ProfilingPeriod profilingPeriod in profilingPeriods) { allocationResultWIthProfilePeriod.ProfilePeriods = allocationResultWIthProfilePeriod.ProfilePeriods.Concat(new[] { new ProfilePeriod { Period = profilingPeriod.Period, Occurrence = profilingPeriod.Occurrence, PeriodYear = profilingPeriod.Year.ToString(), PeriodType = profilingPeriod.Type, ProfileValue = profilingPeriod.Value, DistributionPeriod = profilingPeriod.DistributionPeriod } }).ToArraySafe(); } fundingPeriodResultSummary.Allocations = fundingPeriodResultSummary.Allocations.Concat(new[] { allocationResultWIthProfilePeriod }).ToArraySafe(); } resultSummary.FundingPeriods = resultSummary.FundingPeriods.Concat(new[] { fundingPeriodResultSummary }).ToArraySafe(); } localAuthorityResultSummary.Providers = localAuthorityResultSummary.Providers.Concat(new[] { resultSummary }).ToArraySafe(); } localAuthorityResultSummary.TotalAllocation = localAuthorityResultSummary.Providers.Sum(m => m.AllocationValue); localAuthorityResultsSummary.LocalAuthorities = localAuthorityResultsSummary.LocalAuthorities.Concat(new[] { localAuthorityResultSummary }).ToArraySafe(); } localAuthorityResultsSummary.TotalAllocation = localAuthorityResultsSummary.LocalAuthorities.Sum(m => m.TotalAllocation); return(localAuthorityResultsSummary); }
public async Task ReIndexAllocationNotificationFeeds_GivenPublishedProviderFoundAndMajorMinorFeatureToggleIsEnabledAndIsAllAllocationResultsVersionsInFeedIndexEnabled_IndexesAndReturnsNoContentResult() { //Arrange int major = 2; int minor = 7; Message message = new Message(); const string specificationId = "spec-1"; IEnumerable <PublishedProviderResult> results = CreatePublishedProviderResultsWithDifferentProviders(); foreach (PublishedProviderResult result in results) { result.FundingStreamResult.AllocationLineResult.Current.Status = AllocationLineStatus.Approved; result.FundingStreamResult.AllocationLineResult.Current.ProfilingPeriods = new[] { new ProfilingPeriod() }; result.FundingStreamResult.AllocationLineResult.Current.Major = major; result.FundingStreamResult.AllocationLineResult.Current.Minor = minor; result.FundingStreamResult.AllocationLineResult.Current.FeedIndexId = "feed-index-id"; } IPublishedProviderResultsRepository repository = CreatePublishedProviderResultsRepository(); repository .GetAllNonHeldPublishedProviderResults() .Returns(results); ILogger logger = CreateLogger(); IEnumerable <PublishedAllocationLineResultVersion> history = results.Select(m => m.FundingStreamResult.AllocationLineResult.Current); history.ElementAt(0).Status = AllocationLineStatus.Approved; foreach (var providerVersion in history.GroupBy(c => c.PublishedProviderResultId)) { if (providerVersion.Any()) { IEnumerable <PublishedAllocationLineResultVersion> providerHistory = providerVersion.AsEnumerable(); string providerId = providerHistory.First().ProviderId; providerId .Should() .NotBeNullOrWhiteSpace(); repository .GetAllNonHeldPublishedProviderResultVersions(Arg.Is(providerVersion.Key), Arg.Is(providerId)) .Returns(providerHistory); } } ISearchRepository <AllocationNotificationFeedIndex> searchRepository = CreateAllocationNotificationFeedSearchRepository(); SpecificationCurrentVersion specification = CreateSpecification(specificationId); ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository .GetCurrentSpecificationById(Arg.Is("spec-1")) .Returns(specification); IEnumerable <AllocationNotificationFeedIndex> resultsBeingSaved = null; await searchRepository.Index(Arg.Do <IEnumerable <AllocationNotificationFeedIndex> >(r => resultsBeingSaved = r)); PublishedResultsService resultsService = CreateResultsService( logger, publishedProviderResultsRepository: repository, allocationNotificationFeedSearchRepository: searchRepository, specificationsRepository: specificationsRepository); //Act await resultsService.ReIndexAllocationNotificationFeeds(message); //Assert await searchRepository .Received(1) .Index(Arg.Is <IEnumerable <AllocationNotificationFeedIndex> >(m => m.Count() == 3)); AllocationNotificationFeedIndex feedResult = resultsBeingSaved.FirstOrDefault(m => m.ProviderId == "1111"); feedResult.ProviderId.Should().Be("1111"); feedResult.Title.Should().Be("Allocation test allocation line 1 was Approved"); feedResult.Summary.Should().Be($"UKPRN: 1111, version {major}.{minor}"); feedResult.DatePublished.HasValue.Should().Be(false); feedResult.FundingStreamId.Should().Be("fs-1"); feedResult.FundingStreamName.Should().Be("funding stream 1"); feedResult.FundingPeriodId.Should().Be("1819"); feedResult.ProviderUkPrn.Should().Be("1111"); feedResult.ProviderUpin.Should().Be("2222"); feedResult.AllocationLineId.Should().Be("AAAAA"); feedResult.AllocationLineName.Should().Be("test allocation line 1"); feedResult.AllocationVersionNumber.Should().Be(1); feedResult.AllocationAmount.Should().Be(50.0); feedResult.ProviderProfiling.Should().Be("[{\"period\":null,\"occurrence\":0,\"periodYear\":0,\"periodType\":null,\"profileValue\":0.0,\"distributionPeriod\":null}]"); feedResult.ProviderName.Should().Be("test provider name 1"); feedResult.LaCode.Should().Be("77777"); feedResult.Authority.Should().Be("London"); feedResult.ProviderType.Should().Be("test type"); feedResult.SubProviderType.Should().Be("test sub type"); feedResult.EstablishmentNumber.Should().Be("es123"); feedResult.FundingPeriodStartYear.Should().Be(DateTime.Now.Year); feedResult.FundingPeriodEndYear.Should().Be(DateTime.Now.Year + 1); feedResult.FundingStreamStartDay.Should().Be(1); feedResult.FundingStreamStartMonth.Should().Be(8); feedResult.FundingStreamEndDay.Should().Be(31); feedResult.FundingStreamEndMonth.Should().Be(7); feedResult.FundingStreamPeriodName.Should().Be("period-type 1"); feedResult.FundingStreamPeriodId.Should().Be("pt1"); feedResult.AllocationLineContractRequired.Should().Be(true); feedResult.AllocationLineFundingRoute.Should().Be("LA"); feedResult.MajorVersion.Should().Be(major); feedResult.MinorVersion.Should().Be(minor); }
public async Task ReIndexAllocationNotificationFeeds_GivenResultHasProviderDataChange_AndHasNotBeenVariedInAnyOtherWay_IndexesAndReturnsNoContentResult() { //Arrange Message message = new Message(); const string specificationId = "spec-1"; IEnumerable <PublishedProviderResult> results = CreatePublishedProviderResultsWithDifferentProviders(); foreach (PublishedProviderResult result in results) { result.FundingStreamResult.AllocationLineResult.Current.Status = AllocationLineStatus.Approved; result.FundingStreamResult.AllocationLineResult.Current.ProfilingPeriods = new[] { new ProfilingPeriod() }; result.FundingStreamResult.AllocationLineResult.Current.FinancialEnvelopes = new[] { new FinancialEnvelope() }; result.FundingStreamResult.AllocationLineResult.Current.Calculations = new[] { new PublishedProviderCalculationResult { CalculationSpecification = new Common.Models.Reference("calc-id-1", "calc1"), Policy = new PolicySummary("policy-id-1", "policy1", "desc") }, new PublishedProviderCalculationResult { CalculationSpecification = new Common.Models.Reference("calc-id-2", "calc2"), Policy = new PolicySummary("policy-id-1", "policy1", "desc") }, new PublishedProviderCalculationResult { CalculationSpecification = new Common.Models.Reference("calc-id-3", "calc3"), Policy = new PolicySummary("policy-id-2", "policy2", "desc") }, }; } PublishedAllocationLineResult publishedAllocationLineResult = results.First().FundingStreamResult.AllocationLineResult; publishedAllocationLineResult.HasResultBeenVaried = false; publishedAllocationLineResult.Current.VariationReasons = new[] { VariationReason.AuthorityFieldUpdated, VariationReason.NameFieldUpdated }; IPublishedProviderResultsRepository repository = CreatePublishedProviderResultsRepository(); repository .GetAllNonHeldPublishedProviderResults() .Returns(results); IEnumerable <PublishedAllocationLineResultVersion> history = results.Select(m => m.FundingStreamResult.AllocationLineResult.Current); history.ElementAt(0).Status = AllocationLineStatus.Approved; history.ElementAt(1).Status = AllocationLineStatus.Approved; history.ElementAt(2).Status = AllocationLineStatus.Published; foreach (var providerVersion in history.GroupBy(c => c.PublishedProviderResultId)) { if (providerVersion.Any()) { IEnumerable <PublishedAllocationLineResultVersion> providerHistory = providerVersion.AsEnumerable(); string providerId = providerHistory.First().ProviderId; providerId .Should() .NotBeNullOrWhiteSpace(); repository .GetAllNonHeldPublishedProviderResultVersions(Arg.Is(providerVersion.Key), Arg.Is(providerId)) .Returns(providerHistory); } } ILogger logger = CreateLogger(); ISearchRepository <AllocationNotificationFeedIndex> searchRepository = CreateAllocationNotificationFeedSearchRepository(); SpecificationCurrentVersion specification = CreateSpecification(specificationId); ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository .GetCurrentSpecificationById(Arg.Is(specificationId)) .Returns(specification); IEnumerable <AllocationNotificationFeedIndex> resultsBeingSaved = null; await searchRepository .Index(Arg.Do <IEnumerable <AllocationNotificationFeedIndex> >(r => resultsBeingSaved = r)); PublishedResultsService resultsService = CreateResultsService( logger, publishedProviderResultsRepository: repository, allocationNotificationFeedSearchRepository: searchRepository, specificationsRepository: specificationsRepository); //Act await resultsService.ReIndexAllocationNotificationFeeds(message); //Assert await searchRepository .Received(1) .Index(Arg.Is <IEnumerable <AllocationNotificationFeedIndex> >(m => m.Count() == 3)); AllocationNotificationFeedIndex feedResult = resultsBeingSaved.FirstOrDefault(m => m.ProviderId == "1111"); feedResult.ProviderId.Should().Be("1111"); feedResult.Title.Should().Be("Allocation test allocation line 1 was Approved"); feedResult.Summary.Should().Be("UKPRN: 1111, version 0.1"); feedResult.DatePublished.HasValue.Should().Be(false); feedResult.FundingStreamId.Should().Be("fs-1"); feedResult.FundingStreamName.Should().Be("funding stream 1"); feedResult.FundingPeriodId.Should().Be("1819"); feedResult.ProviderUkPrn.Should().Be("1111"); feedResult.ProviderUpin.Should().Be("2222"); feedResult.AllocationLineId.Should().Be("AAAAA"); feedResult.AllocationLineName.Should().Be("test allocation line 1"); feedResult.AllocationVersionNumber.Should().Be(1); feedResult.AllocationAmount.Should().Be(50.0); feedResult.ProviderProfiling.Should().Be("[{\"period\":null,\"occurrence\":0,\"periodYear\":0,\"periodType\":null,\"profileValue\":0.0,\"distributionPeriod\":null}]"); feedResult.ProviderName.Should().Be("test provider name 1"); feedResult.LaCode.Should().Be("77777"); feedResult.Authority.Should().Be("London"); feedResult.ProviderType.Should().Be("test type"); feedResult.SubProviderType.Should().Be("test sub type"); feedResult.EstablishmentNumber.Should().Be("es123"); feedResult.FundingPeriodStartYear.Should().Be(DateTime.Now.Year); feedResult.FundingPeriodEndYear.Should().Be(DateTime.Now.Year + 1); feedResult.FundingStreamStartDay.Should().Be(1); feedResult.FundingStreamStartMonth.Should().Be(8); feedResult.FundingStreamEndDay.Should().Be(31); feedResult.FundingStreamEndMonth.Should().Be(7); feedResult.FundingStreamPeriodName.Should().Be("period-type 1"); feedResult.FundingStreamPeriodId.Should().Be("pt1"); feedResult.AllocationLineContractRequired.Should().Be(true); feedResult.AllocationLineFundingRoute.Should().Be("LA"); feedResult.AllocationLineShortName.Should().Be("tal1"); feedResult.PolicySummaries.Should().Be("[{\"policy\":{\"description\":\"test decscription\",\"parentPolicyId\":null,\"id\":\"policy-1\",\"name\":\"policy one\"},\"policies\":[{\"policy\":{\"description\":\"test decscription\",\"parentPolicyId\":null,\"id\":\"subpolicy-1\",\"name\":\"sub policy one\"},\"policies\":[],\"calculations\":[]}],\"calculations\":[]}]"); feedResult.Calculations.Should().Be("[{\"calculationName\":\"calc1\",\"calculationDisplayName\":\"calc1\",\"calculationVersion\":0,\"calculationType\":\"Number\",\"calculationAmount\":null,\"allocationLineId\":\"AAAAA\",\"policyId\":\"policy-id-1\",\"policyName\":\"policy1\"},{\"calculationName\":\"calc2\",\"calculationDisplayName\":\"calc2\",\"calculationVersion\":0,\"calculationType\":\"Number\",\"calculationAmount\":null,\"allocationLineId\":\"AAAAA\",\"policyId\":\"policy-id-1\",\"policyName\":\"policy1\"},{\"calculationName\":\"calc3\",\"calculationDisplayName\":\"calc3\",\"calculationVersion\":0,\"calculationType\":\"Number\",\"calculationAmount\":null,\"allocationLineId\":\"AAAAA\",\"policyId\":\"policy-id-2\",\"policyName\":\"policy2\"}]"); feedResult.OpenReason.Should().BeNull(); feedResult.CloseReason.Should().BeNull(); feedResult.Predecessors.Should().BeNull(); feedResult.Successors.Should().BeNull(); }
private ProviderResultSummary CreateProviderResultSummary(IEnumerable <AllocationNotificationFeedIndex> entries, HttpRequest request) { IEnumerable <IGrouping <string, AllocationNotificationFeedIndex> > fundingPeriodResultSummaryGroups = entries.GroupBy(m => m.FundingPeriodId); AllocationNotificationFeedIndex firstEntry = entries.First(); ProviderVariation providerVariation = CreateProviderVariationFromAllocationNotificationFeedIndexItem(firstEntry); ProviderResultSummary providerResutSummary = new ProviderResultSummary { Provider = new AllocationProviderModel { Name = firstEntry.ProviderName, LegalName = firstEntry.ProviderLegalName, UkPrn = firstEntry.ProviderUkPrn, Upin = firstEntry.ProviderUpin, Urn = firstEntry.ProviderUrn, DfeEstablishmentNumber = firstEntry.DfeEstablishmentNumber, EstablishmentNumber = firstEntry.EstablishmentNumber, LaCode = firstEntry.LaCode, LocalAuthority = firstEntry.Authority, Type = firstEntry.ProviderType, SubType = firstEntry.SubProviderType, OpenDate = firstEntry.ProviderOpenDate, CloseDate = firstEntry.ProviderClosedDate, CrmAccountId = firstEntry.CrmAccountId, NavVendorNo = firstEntry.NavVendorNo, Status = firstEntry.ProviderStatus, ProviderVariation = providerVariation } }; foreach (IGrouping <string, AllocationNotificationFeedIndex> fundingPeriodResultSummaryGroup in fundingPeriodResultSummaryGroups) { AllocationNotificationFeedIndex firstPeriodEntry = fundingPeriodResultSummaryGroup.First(); ProviderPeriodResultSummary providerPeriodResultSummary = new ProviderPeriodResultSummary { Period = new Period { Id = firstPeriodEntry.FundingPeriodId, Name = firstPeriodEntry.FundingStreamPeriodName, StartYear = firstPeriodEntry.FundingPeriodStartYear, EndYear = firstPeriodEntry.FundingPeriodEndYear } }; IEnumerable <IGrouping <string, AllocationNotificationFeedIndex> > fundingStreamResultSummaryGroups = fundingPeriodResultSummaryGroup.GroupBy(m => m.FundingStreamId); foreach (IGrouping <string, AllocationNotificationFeedIndex> fundingStreamResultSummaryGroup in fundingStreamResultSummaryGroups) { AllocationNotificationFeedIndex feedIndex = fundingStreamResultSummaryGroup.First(); FundingStreamResultSummary fundingStreamResultSummary = new FundingStreamResultSummary { FundingStream = new AllocationFundingStreamModel { Id = feedIndex.FundingStreamId, Name = feedIndex.FundingStreamName, ShortName = feedIndex.FundingStreamShortName, PeriodType = new AllocationFundingStreamPeriodTypeModel { Id = feedIndex.FundingStreamPeriodId, Name = feedIndex.FundingStreamPeriodName, StartDay = feedIndex.FundingStreamStartDay, StartMonth = feedIndex.FundingStreamStartMonth, EndDay = feedIndex.FundingStreamEndDay, EndMonth = feedIndex.FundingStreamEndMonth }, //todo Version = feedIndex.FundingStreamVersionNumber //todo Version = feedIndex.FundingStreamVersion } }; foreach (AllocationNotificationFeedIndex allocationFeedIndex in fundingStreamResultSummaryGroup) { IEnumerable <PublishedProviderResultsPolicySummary> policySummaries = JsonConvert.DeserializeObject <IEnumerable <PublishedProviderResultsPolicySummary> >(feedIndex.PolicySummaries); IList <CalculationResult> calculations = new List <CalculationResult>(); if (!string.IsNullOrWhiteSpace(feedIndex.PolicySummaries)) { foreach (PublishedProviderResultsPolicySummary publishedPolicySummaryResult in policySummaries) { foreach (PublishedProviderResultsCalculationSummary publishedCalculationSummary in publishedPolicySummaryResult.Calculations) { calculations.Add(new Models.CalculationResult { CalculationName = publishedCalculationSummary.Name, CalculationVersionNumber = (ushort)publishedCalculationSummary.Version, CalculationType = publishedCalculationSummary.CalculationType.ToString(), CalculationValue = publishedCalculationSummary.Amount, PolicyId = publishedPolicySummaryResult.Policy.Id, //todo CalculationDisplayName = publishedCalculationSummary.DisplayName, //todo AssociatedWithAllocation = publishedCalculationSummary.AssociatedWithAllocation ? true }); } } } fundingStreamResultSummary.Allocations.Add(new AllocationResult { AllocationLine = new AllocationLine { Id = allocationFeedIndex.AllocationLineId, Name = allocationFeedIndex.AllocationLineName, ShortName = allocationFeedIndex.AllocationLineShortName, FundingRoute = allocationFeedIndex.AllocationLineFundingRoute, ContractRequired = allocationFeedIndex.AllocationLineContractRequired ? "Y" : "N" }, AllocationMajorVersion = feedIndex.MajorVersion ?? 0, AllocationMinorVersion = feedIndex.MinorVersion ?? 0, AllocationStatus = allocationFeedIndex.AllocationStatus, AllocationAmount = Convert.ToDecimal(allocationFeedIndex.AllocationAmount), ProfilePeriods = new Collection <ProfilePeriod>(JsonConvert.DeserializeObject <IEnumerable <ProfilingPeriod> >(allocationFeedIndex.ProviderProfiling) .Select(m => new ProfilePeriod(m.Period, m.Occurrence, m.Year.ToString(), m.Type, m.Value, m.DistributionPeriod)) .ToArraySafe()), Calculations = new Collection <CalculationResult>(calculations) }); } fundingStreamResultSummary.FundingStreamTotalAmount = fundingStreamResultSummary.Allocations.Sum(m => m.AllocationAmount); providerResutSummary.FundingStreamTotalAmount += fundingStreamResultSummary.FundingStreamTotalAmount; providerPeriodResultSummary.FundingStreamResults.Add(fundingStreamResultSummary); } providerResutSummary.FundingPeriodResults = new Collection <ProviderPeriodResultSummary>( providerResutSummary.FundingPeriodResults.Concat(new[] { providerPeriodResultSummary }).ToArraySafe()); } return(providerResutSummary); }
public async Task GetNotifications_GivenAQueryStringForWhichThereAreResults_ReturnsAtomFeedWithCorrectLinks() { //Arrange SearchFeedV2 <AllocationNotificationFeedIndex> feeds = new SearchFeedV2 <AllocationNotificationFeedIndex> { PageRef = 2, Top = 2, TotalCount = 8, Entries = CreateFeedIndexes() }; AllocationNotificationFeedIndex firstFeedItem = feeds.Entries.ElementAt(0); firstFeedItem.VariationReasons = new[] { "LegalNameFieldUpdated", "LACodeFieldUpdated" }; firstFeedItem.Successors = new[] { "provider4" }; firstFeedItem.Predecessors = new[] { "provider1", "provider2" }; firstFeedItem.OpenReason = "Fresh Start"; firstFeedItem.CloseReason = "Closure"; IAllocationNotificationsFeedsSearchService feedsSearchService = CreateSearchService(); feedsSearchService .GetFeedsV2(Arg.Is(2), Arg.Is(2)) .ReturnsForAnyArgs(feeds); AllocationNotificationFeedsService service = CreateService(feedsSearchService); IHeaderDictionary headerDictionary = new HeaderDictionary(); headerDictionary.Add("Accept", new StringValues("application/json")); IQueryCollection queryStringValues = new QueryCollection(new Dictionary <string, StringValues> { { "pageRef", new StringValues("2") }, { "allocationStatuses", new StringValues("Published,Approved") }, { "pageSize", new StringValues("2") } }); HttpRequest request = Substitute.For <HttpRequest>(); request.Scheme.Returns("https"); request.Path.Returns(new PathString("/api/v2/allocations/notifications")); request.Host.Returns(new HostString("wherever.naf:12345")); request.QueryString.Returns(new QueryString("?pageSize=2&allocationStatuses=Published&allocationStatuses=Approved")); request.Headers.Returns(headerDictionary); request.Query.Returns(queryStringValues); //Act IActionResult result = await service.GetNotifications(request, pageRef : 2, pageSize : 2, allocationStatuses : new[] { "Published", "Approved" }); //Assert result .Should() .BeOfType <ContentResult>(); ContentResult contentResult = result as ContentResult; AtomFeed <AllocationModel> atomFeed = JsonConvert.DeserializeObject <AtomFeed <AllocationModel> >(contentResult.Content); atomFeed .Should() .NotBeNull(); atomFeed.Id.Should().NotBeEmpty(); atomFeed.Title.Should().Be("Calculate Funding Service Allocation Feed"); atomFeed.Author.Name.Should().Be("Calculate Funding Service"); atomFeed.Link.First(m => m.Rel == "next-archive").Href.Should().Be("https://wherever.naf:12345/api/v2/allocations/notifications/3?pageSize=2&allocationStatuses=Published&allocationStatuses=Approved"); atomFeed.Link.First(m => m.Rel == "prev-archive").Href.Should().Be("https://wherever.naf:12345/api/v2/allocations/notifications/1?pageSize=2&allocationStatuses=Published&allocationStatuses=Approved"); atomFeed.Link.First(m => m.Rel == "self").Href.Should().Be("https://wherever.naf:12345/api/v2/allocations/notifications?pageSize=2&allocationStatuses=Published&allocationStatuses=Approved"); atomFeed.Link.First(m => m.Rel == "current").Href.Should().Be("https://wherever.naf:12345/api/v2/allocations/notifications/2?pageSize=2&allocationStatuses=Published&allocationStatuses=Approved"); atomFeed.AtomEntry.Count.Should().Be(3); atomFeed.AtomEntry.ElementAt(0).Id.Should().Be("https://wherever.naf:12345/api/v2/allocations/id-1"); atomFeed.AtomEntry.ElementAt(0).Title.Should().Be("test title 1"); atomFeed.AtomEntry.ElementAt(0).Summary.Should().Be("test summary 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.Id.Should().Be("fs-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.Name.Should().Be("fs 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Period.Id.Should().Be("fp-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.UkPrn.Should().Be("1111"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.Upin.Should().Be("0001"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationLine.Id.Should().Be("al-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationLine.Name.Should().Be("al 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationStatus.Should().Be("Published"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationAmount.Should().Be(10); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.ProfilePeriods.Should().HaveCount(0); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.ShortName.Should().Be("fs-short-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.PeriodType.Id.Should().Be("fspi-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.PeriodType.Name.Should().Be("fspi1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.PeriodType.StartDay.Should().Be(1); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.PeriodType.StartMonth.Should().Be(8); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.PeriodType.EndDay.Should().Be(31); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.FundingStream.PeriodType.EndMonth.Should().Be(7); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Period.Name.Should().Be("fspi1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Period.StartYear.Should().Be(2018); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Period.EndYear.Should().Be(2019); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.Name.Should().Be("provider 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.LegalName.Should().Be("legal 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.Urn.Should().Be("01"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.DfeEstablishmentNumber.Should().Be("dfe-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.EstablishmentNumber.Should().Be("e-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.LaCode.Should().Be("la-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.LocalAuthority.Should().Be("authority"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.Type.Should().Be("type 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.SubType.Should().Be("sub type 1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.OpenDate.Should().NotBeNull(); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.CloseDate.Should().NotBeNull(); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.CrmAccountId.Should().Be("crm-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.NavVendorNo.Should().Be("nv-1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.Status.Should().Be("Active"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationLine.ShortName.Should().Be("short-al1"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationLine.FundingRoute.Should().Be("LA"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationLine.ContractRequired.Should().Be("Y"); atomFeed.AtomEntry.ElementAt(0).Content.Allocation.AllocationResultTitle.Should().Be("test title 1"); ProviderVariation providerVariation1 = atomFeed.AtomEntry.ElementAt(0).Content.Allocation.Provider.ProviderVariation; providerVariation1.Should().NotBeNull(); providerVariation1.VariationReasons.Should().BeEquivalentTo("LegalNameFieldUpdated", "LACodeFieldUpdated"); providerVariation1.Successors.First().Ukprn.Should().Be("provider4"); providerVariation1.Predecessors.First().Ukprn.Should().Be("provider1"); providerVariation1.Predecessors[1].Ukprn.Should().Be("provider2"); providerVariation1.OpenReason.Should().Be("Fresh Start"); providerVariation1.CloseReason.Should().Be("Closure"); atomFeed.AtomEntry.ElementAt(1).Id.Should().Be("https://wherever.naf:12345/api/v2/allocations/id-2"); atomFeed.AtomEntry.ElementAt(1).Title.Should().Be("test title 2"); atomFeed.AtomEntry.ElementAt(1).Summary.Should().Be("test summary 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.Id.Should().Be("fs-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.Name.Should().Be("fs 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Period.Id.Should().Be("fp-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.UkPrn.Should().Be("2222"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.Upin.Should().Be("0002"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationLine.Id.Should().Be("al-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationLine.Name.Should().Be("al 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationStatus.Should().Be("Published"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationAmount.Should().Be(100); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.ProfilePeriods.Should().HaveCount(2); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.ShortName.Should().Be("fs-short-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.PeriodType.Id.Should().Be("fspi-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.PeriodType.Name.Should().Be("fspi2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.PeriodType.StartDay.Should().Be(1); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.PeriodType.StartMonth.Should().Be(8); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.PeriodType.EndDay.Should().Be(31); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.FundingStream.PeriodType.EndMonth.Should().Be(7); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Period.Name.Should().Be("fspi2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Period.StartYear.Should().Be(2018); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Period.EndYear.Should().Be(2019); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.Name.Should().Be("provider 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.LegalName.Should().Be("legal 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.Urn.Should().Be("02"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.DfeEstablishmentNumber.Should().Be("dfe-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.EstablishmentNumber.Should().Be("e-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.LaCode.Should().Be("la-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.LocalAuthority.Should().Be("authority"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.Type.Should().Be("type 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.SubType.Should().Be("sub type 2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.OpenDate.Should().NotBeNull(); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.CloseDate.Should().NotBeNull(); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.CrmAccountId.Should().Be("crm-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.NavVendorNo.Should().Be("nv-2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.Status.Should().Be("Active"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationLine.ShortName.Should().Be("short-al2"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationLine.FundingRoute.Should().Be("LA"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationLine.ContractRequired.Should().Be("Y"); atomFeed.AtomEntry.ElementAt(1).Content.Allocation.AllocationResultTitle.Should().Be("test title 2"); ProviderVariation providerVariation2 = atomFeed.AtomEntry.ElementAt(1).Content.Allocation.Provider.ProviderVariation; AssertProviderVariationValuesNotSet(providerVariation2); atomFeed.AtomEntry.ElementAt(2).Id.Should().Be("https://wherever.naf:12345/api/v2/allocations/id-3"); atomFeed.AtomEntry.ElementAt(2).Title.Should().Be("test title 3"); atomFeed.AtomEntry.ElementAt(2).Summary.Should().Be("test summary 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.Id.Should().Be("fs-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.Name.Should().Be("fs 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Period.Id.Should().Be("fp-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.UkPrn.Should().Be("3333"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.Upin.Should().Be("0003"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationLine.Id.Should().Be("al-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationLine.Name.Should().Be("al 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationStatus.Should().Be("Approved"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationAmount.Should().Be(20); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.ProfilePeriods.Should().HaveCount(0); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.ShortName.Should().Be("fs-short-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.PeriodType.Id.Should().Be("fspi-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.PeriodType.StartDay.Should().Be(1); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.PeriodType.StartMonth.Should().Be(8); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.PeriodType.EndDay.Should().Be(31); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.FundingStream.PeriodType.EndMonth.Should().Be(7); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Period.Name.Should().Be("fspi3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Period.StartYear.Should().Be(2018); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Period.EndYear.Should().Be(2019); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.Name.Should().Be("provider 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.LegalName.Should().Be("legal 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.Urn.Should().Be("03"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.DfeEstablishmentNumber.Should().Be("dfe-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.EstablishmentNumber.Should().Be("e-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.LaCode.Should().Be("la-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.LocalAuthority.Should().Be("authority"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.Type.Should().Be("type 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.SubType.Should().Be("sub type 3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.OpenDate.Should().NotBeNull(); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.CloseDate.Should().NotBeNull(); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.CrmAccountId.Should().Be("crm-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.NavVendorNo.Should().Be("nv-3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.Status.Should().Be("Active"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationLine.ShortName.Should().Be("short-al3"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationLine.FundingRoute.Should().Be("LA"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationLine.ContractRequired.Should().Be("Y"); atomFeed.AtomEntry.ElementAt(2).Content.Allocation.AllocationResultTitle.Should().Be("test title 3"); ProviderVariation providerVariation3 = atomFeed.AtomEntry.ElementAt(2).Content.Allocation.Provider.ProviderVariation; AssertProviderVariationValuesNotSet(providerVariation2); }