Пример #1
0
        public void CulculateCorrectTime()
        {
            var expectedTime = TimeSpan.FromMinutes(1);
            // Запускать не позже, чем за минуту до полуночи!!!
            var remainingTimeController = new RemainingTimeController(expectedTime);

            remainingTimeController.StopTimer();

            Assert.AreEqual(expectedTime, remainingTimeController.RemainingTimeToLock);
        }
Пример #2
0
        public void StopTimerWorks()
        {
            var remainingTimeController = new RemainingTimeController(TimeSpan.FromMinutes(30));

            remainingTimeController.StopTimer();
            var firstRemainingTime = remainingTimeController.RemainingTimeToLock;

            Thread.Sleep(3000);
            var secondRemainingTime = remainingTimeController.RemainingTimeToLock;

            Assert.AreEqual(firstRemainingTime, secondRemainingTime);
        }
Пример #3
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);
        }