コード例 #1
0
ファイル: Locktimer.cs プロジェクト: taler0n/Students
        public Locktimer(Locker locker)
        {
            _locker         = locker;
            _timeController = new RemainingTimeController(LastSessionSynchronizer.GetAllowedTime());

            locker.LockStatusChanged += SessionSwitchEvent;
            locker.SystemShutdown    += SaveData;
            _timeController.TimeOut  += Lock;
        }
コード例 #2
0
        public void CulculateCorrectTime()
        {
            var expectedTime = TimeSpan.FromMinutes(1);
            // Запускать не позже, чем за минуту до полуночи!!!
            var remainingTimeController = new RemainingTimeController(expectedTime);
            remainingTimeController.StopTimer();

            Assert.AreEqual(expectedTime, remainingTimeController.RemainingTimeToLock);
        }
コード例 #3
0
ファイル: Locktimer.cs プロジェクト: Confirmit/Students
        public Locktimer(Locker locker)
        {
            _locker = locker;
            _timeController = new RemainingTimeController(LastSessionSynchronizer.GetAllowedTime());

            locker.LockStatusChanged += SessionSwitchEvent;
            locker.SystemShutdown += SaveData;
            _timeController.TimeOut += Lock;
        }
コード例 #4
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);
        }
コード例 #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);
        }