public async Task NoRegressionInHistoricalData() { JHUCSSEServices jhucsseServices = _fixture.ServiceProvider.GetRequiredService <JHUCSSEServices>(); JHUCSSEDailyReportCollection dailyReportCollection = await jhucsseServices.GetAllDailyReportsAsync(CancellationToken.None); ImmutableList <JHUCSSEDailyReport> allDailyReports = dailyReportCollection.Keys .OrderBy(utcDate => utcDate) .Select(utcDate => dailyReportCollection[utcDate]) .ToImmutableList(); for (int i = 1; i < allDailyReports.Count; i++) { JHUCSSEDailyReport dailyReport = allDailyReports[i]; JHUCSSEDailyReport prevReport = allDailyReports[i - 1]; ImmutableList <Country> countries = dailyReport.GetCountries(); ImmutableList <Country> prevCountries = prevReport.GetCountries(); foreach (Country country in prevCountries) { countries .Should().ContainSingle(c => c.Name == country.Name, because: "\n{0} in {1}.csv should not be renamed or removed.", country.Name, prevReport.UtcDate.ToString("MM-dd-yyyy")); if (country.Admin1s != null) { foreach (Admin1 admin1 in country.Admin1s) { countries .Single(c => c.Name == country.Name) .Admin1s .Should().NotBeNull(because: "\nAdmin1s of {0} in {1}.csv should not be removed.", country.Name, prevReport.UtcDate.ToString("MM-dd-yyyy")); countries .Single(c => c.Name == country.Name) .Admin1s .Should().ContainSingle(a1 => a1.Name == admin1.Name, because: "\n{0}, {1} in {2}.csv should not be renamed or removed.", admin1.Name, country.Name, prevReport.UtcDate.ToString("MM-dd-yyyy")); if (admin1.Admin2s != null) { foreach (Admin2 admin2 in admin1.Admin2s) { countries .Single(c => c.Name == country.Name) .Admin1s .Single(a1 => a1.Name == admin1.Name) .Admin2s .Should().NotBeNull(because: "\nAdmin2s of {0}, {1} in {2}.csv should not be removed.", admin1.Name, country.Name, prevReport.UtcDate.ToString("MM-dd-yyyy")); countries .Single(c => c.Name == country.Name) .Admin1s .Single(a1 => a1.Name == admin1.Name) .Admin2s .Should().ContainSingle(a2 => a2.Name == admin2.Name, because: "\n{0}, {1}, {2} in {3}.csv should not be renamed or removed.", admin2.Name, admin1.Name, country.Name, prevReport.UtcDate.ToString("MM-dd-yyyy")); } } } } } } }
public async Task <JHUCSSEHistoricalReport> GetWorldHistoricalReportAsync(CancellationToken cancellationToken) { JHUCSSEDailyReportCollection allDailyReports = await GetAllDailyReportsAsync(cancellationToken).ConfigureAwait(false); return(allDailyReports.GetWorldHistoricalReport()); }
public async Task <JHUCSSEHistoricalReport> GetAdmin2HistoricalReportAsync(string country, string admin1, string admin2, CancellationToken cancellationToken) { JHUCSSEDailyReportCollection allDailyReports = await GetAllDailyReportsAsync(cancellationToken).ConfigureAwait(false); return(allDailyReports.GetHistoricalReportByKey($"{admin2}, {admin1}, {country}") ?? throw new KeyNotFoundException($"Historical report not found for {admin2}, {admin1}, {country}.")); }
public async Task <ImmutableList <Country> > GetAllCountriesAsync(CancellationToken cancellationToken) { JHUCSSEDailyReportCollection allDailyReports = await GetAllDailyReportsAsync(cancellationToken).ConfigureAwait(false); return(allDailyReports[allDailyReports.Keys.Max()].GetCountries()); }