public void GetAllowedTimeReturnSavedTimeWhenRemainingTimeLessThenMaxAllowedTime()
        {
            var expectedTime = TimeSpan.FromMilliseconds(Locktimer.GetMaxAllowedTime().TotalMilliseconds / 2);

            LastSessionSynchronizer.SaveSessionData(expectedTime);

            var allowedTime = LastSessionSynchronizer.GetAllowedTime();

            Assert.AreEqual(expectedTime, allowedTime);
        }
        public void GetAllowedTimeReturnMaxAllowedTimeWhenRemainingTimeLargerThenMaxAllowedTime()
        {
            TimeSpan savingTime = Locktimer.GetMaxAllowedTime() + TimeSpan.FromMinutes(30);

            LastSessionSynchronizer.SaveSessionData(savingTime);

            var allowedTime    = LastSessionSynchronizer.GetAllowedTime();
            var maxAllowedTime = Locktimer.GetMaxAllowedTime();

            Assert.AreEqual(maxAllowedTime, allowedTime);
        }
예제 #3
0
        public void RemainingTimeReturnTimeThatIsNotLargerThanMaxAllowedTime()
        {
            LastSessionSynchronizer.SaveSessionData(TimeSpan.FromHours(25));
            var windowsLocker = new WindowsLocker();
            var locktimer     = new Locktimer(windowsLocker);

            var remainingTime  = locktimer.GetRemainingTime();
            var maxAllowedTime = Locktimer.GetMaxAllowedTime();
            var remainingTimeIsNotLargerThanMaxAllowedTime = remainingTime <= maxAllowedTime;

            Assert.AreEqual(true, remainingTimeIsNotLargerThanMaxAllowedTime);
        }
        public void GetAllowedTimeReturnMaxAllowedTimeWhenFileNotExists()
        {
            if (File.Exists(LastSessionSynchronizer.LAST_SESSION_DATA_WAY))
            {
                File.Delete(LastSessionSynchronizer.LAST_SESSION_DATA_WAY);
            }

            var allowedTime    = LastSessionSynchronizer.GetAllowedTime();
            var maxAllowedTime = Locktimer.GetMaxAllowedTime();

            Assert.AreEqual(maxAllowedTime, allowedTime);
        }
예제 #5
0
        public void CorrectHandlingOfMidnight()
        {
            var time = TimeSpan.FromHours(25);
            var remainingTimeController = new RemainingTimeController(time);

            remainingTimeController.StopTimer();

            var maxAllowedTime = Locktimer.GetMaxAllowedTime();
            var expectedTime   = TimeSpan.FromSeconds((int)(TimeSpan.FromHours(24) - DateTime.Now.TimeOfDay).TotalSeconds) + maxAllowedTime;
            var actualTime     = TimeSpan.FromSeconds((int)(remainingTimeController.RemainingTimeToLock.TotalSeconds));

            Assert.AreEqual(expectedTime, actualTime);
        }
        public void GetAllowedTimeReturnMaxAllowedTimeWhenSavedDateLessThanCurrentDate()
        {
            var notExpectedTime = TimeSpan.FromMilliseconds(Locktimer.GetMaxAllowedTime().TotalMilliseconds / 2);

            using (var sessionData = new StreamWriter(LastSessionSynchronizer.LAST_SESSION_DATA_WAY, false))
            {
                sessionData.WriteLine(DateTime.Now.Subtract(TimeSpan.FromDays(1)).Date.ToString());
                sessionData.WriteLine(notExpectedTime.ToString(@"hh\:mm\:ss"));
            }

            var allowedTime    = LastSessionSynchronizer.GetAllowedTime();
            var maxAllowedTime = Locktimer.GetMaxAllowedTime();

            Assert.AreEqual(maxAllowedTime, allowedTime);
        }