Beispiel #1
0
        public void Add_WhenDatetimesRemoved_ThenStorageDecreaseExpected()
        {
            var d = DateTime.Now;

            shutdownHistoryStorage.Add(d.AddDays(2));
            shutdownHistoryStorage.Add(d.AddDays(12));
            shutdownHistoryStorage.Add(d.AddDays(3));
            IEnumerable <DateTime> times = shutdownHistoryStorage.GetAll();

            shutdownHistoryStorage.Remove(d.AddDays(2));
            shutdownHistoryStorage.Remove(d.AddDays(12));
            Assert.Equal(4, times.Count());
        }
Beispiel #2
0
        public void UpdateShutdownHistory()
        {
            DateTime lastSystemShutdown = systemInformation.GetLastSystemShutdown();

            if (!IsHourOfNight(lastSystemShutdown))
            {
                return;
            }

            shutdownHistoryStorage.Add(lastSystemShutdown);

            IEnumerable <DateTime> times = shutdownHistoryStorage.GetAll(IsHourOfNight);

            if (times.Count() > HISTORY_MAX_SIZE)
            {
                shutdownHistoryStorage.Remove(times.Min());
            }
        }