public async Task ExposureStateUpdatedAsync(IEnumerable <ExposureWindow> windows, IEnumerable <DailySummary>?summaries) { Debug.WriteLine("ExposureStateUpdatedAsync is called"); List <DateTime> validDates = ExposureDetectedHelper.DeleteDatesOfExposureOlderThan14DaysAndReturnNewList(); bool shouldSendMessage = false; List <DateTime> datesOfExposuresOverThreshold = new List <DateTime>(); foreach (DailySummary dailySummary in summaries) { if (ExposureDetectedHelper.RiskInDailySummaryAboveThreshold(dailySummary) && ExposureDetectedHelper.HasNotShownExposureNotificationForDate(dailySummary.Timestamp.Date, validDates)) { datesOfExposuresOverThreshold.Add(dailySummary.Timestamp.Date); shouldSendMessage = true; } } if (shouldSendMessage) { await MessageUtils.CreateMessage(this); await ExposureDetectedHelper.UpdateDatesOfExposures(datesOfExposuresOverThreshold); } ServiceLocator.Current.GetInstance <IDeveloperToolsService>().SaveExposureWindows(windows); ServiceLocator.Current.GetInstance <IDeveloperToolsService>().SaveLastDailySummaries(summaries); }
public void RiskInDailySummaryAboveThreshold_ReturnsFalseWhenBelowConfiguredLimit(string locale) { Thread.CurrentThread.CurrentCulture = new CultureInfo(locale); LocalPreferencesHelper.ScoreSumThreshold = 780; DailySummaryReport dailySummaryReport = new DailySummaryReport(0, 779, 0); DailySummary dailySummary = new DailySummary(SystemTime.Now(), dailySummaryReport, new Dictionary <ReportType, DailySummaryReport>()); bool isAboveThreshold = ExposureDetectedHelper.RiskInDailySummaryAboveThreshold(dailySummary); Assert.False(isAboveThreshold); }