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 HasNotShownExposureNotificationForDate_ReturnsTrueIfTimeStampHasNotYetBeenSaved(string locale) { Thread.CurrentThread.CurrentCulture = new CultureInfo(locale); SystemTime.ResetDateTime(); List <DateTime> previouslySavedDates = new List <DateTime>(); previouslySavedDates.Add(SystemTime.Now().AddDays(0).Date); previouslySavedDates.Add(SystemTime.Now().AddDays(-1).Date); previouslySavedDates.Add(SystemTime.Now().AddDays(-2).Date); bool savedBefore = ExposureDetectedHelper.HasNotShownExposureNotificationForDate(SystemTime.Now().AddDays(-1), previouslySavedDates); bool neverSaved = ExposureDetectedHelper.HasNotShownExposureNotificationForDate(SystemTime.Now().AddDays(-3), previouslySavedDates); Assert.False(savedBefore); Assert.True(neverSaved); }