Beispiel #1
0
        public async void SystemDateTimeIsIncorrect_NtpIsEqualToPersisted_ShouldUseDefault()
        {
            SystemTime.ResetDateTime();
            DateTime currentTime = DateTime.UtcNow.AddYears(-3);

            SystemTime.SetDateTime(currentTime);

            NTPUtcDateTime ntpUtcDateTime =
                Mock.Of <NTPUtcDateTime>(ntp =>
                                         ntp.GetNTPUtcDateTime() == Task.FromResult(LocalPreferencesHelper.LastNTPUtcDateTime));

            try
            {
                new FetchExposureKeysHelper().UpdateLastNTPDateTime(ntpUtcDateTime);
            }
            catch
            {
                // ignore as ZipDownloader is not mocked in this test
            }
            LogDeviceDetails logModel =
                new LogDeviceDetails(
                    LogSeverity.WARNING,
                    "message",
                    "additionalInfo");

            Assert.Equal(Conf.DATE_TIME_REPLACEMENT, logModel.ReportedTime);

            SystemTime.ResetDateTime();
        }
Beispiel #2
0
        public async void UpdateLastNTPDateTime(NTPUtcDateTime mock = null)
        {
            DateTime ntpDateTime = await(mock ?? new NTPUtcDateTime()).GetNTPUtcDateTime();

            if (ntpDateTime != null && ntpDateTime > LocalPreferencesHelper.LastNTPUtcDateTime)
            {
                LocalPreferencesHelper.LastNTPUtcDateTime = ntpDateTime;
            }
        }