private void ResetData() { SystemTime.ResetDateTime(); MessageUtils.RemoveAll(); Permissions.BluetoothEnabled = true; Permissions.LocationEnabled = true; LocalNotificationsManager.ResetHasBeenCalledMap(); foreach (string key in SecureStorageKeys.GetAllKeysForCleaningDevice()) { _secureStorageService.Delete(key); } }
public static void CleanDataFromDevice() { // Clear the stored data in the singleton ServiceLocator.Current.GetInstance <IDeveloperToolsService>().ClearAllFields(); // Needed to reset authorization header HttpClientManager.MakeNewInstance(); ServiceLocator.Current.GetInstance <IPreferences>().Clear(); MessageUtils.RemoveAll(); OnboardingStatusHelper.Status = OnboardingStatus.NoConsentsGiven; foreach (string key in SecureStorageKeys.GetAllKeysForCleaningDevice()) { ServiceLocator.Current.GetInstance <SecureStorageService>().Delete(key); } }
[InlineData(14, 0, false)] // Equal 9PM public async void ShouldUpdateLastMessageDate(int daysOfTimeShift, int minutesOfTimeShift, bool shouldBeCalled) { await ServiceLocator.Current.GetInstance <IMessagesManager>().DeleteAll(); foreach (string key in SecureStorageKeys.GetAllKeysForCleaningDevice()) { _secureStorageService.Delete(key); } SystemTime.SetDateTime(DateTime.Now.Date.AddHours(12).ToUniversalTime()); await ServiceLocator.Current.GetInstance <IMessagesManager>().SaveNewMessage(new MessageSQLiteModel() { TimeStamp = SystemTime.Now(), ID = 1, MessageLink = "", Title = "" }); LocalNotificationsManager.GenerateLocalNotification(new NotificationViewModel(), 0); LocalNotificationsManager.HasBeenCalled = false; DateTime preFetchDateTime = MessageUtils.GetDateTimeFromSecureStorageForKey(SecureStorageKeys.LAST_SENT_NOTIFICATION_UTC_KEY, ""); SystemTime.SetDateTime(DateTime.Now.Date.AddDays(daysOfTimeShift).AddHours(21).AddMinutes(minutesOfTimeShift).ToUniversalTime()); try { await new FetchExposureKeysHelper().FetchExposureKeyBatchFilesFromServerAsync(null, CancellationToken.None); } catch { // ignore as ZipDownloader is not mocked in this test } Assert.Equal(shouldBeCalled, preFetchDateTime < MessageUtils.GetDateTimeFromSecureStorageForKey(SecureStorageKeys.LAST_SENT_NOTIFICATION_UTC_KEY, "")); Assert.Equal(shouldBeCalled, LocalNotificationsManager.HasBeenCalled); SystemTime.ResetDateTime(); }