public Locktimer(Locker locker) { _locker = locker; _timeController = new RemainingTimeController(LastSessionSynchronizer.GetAllowedTime()); locker.LockStatusChanged += SessionSwitchEvent; locker.SystemShutdown += SaveData; _timeController.TimeOut += Lock; }
public void CulculateCorrectTime() { var expectedTime = TimeSpan.FromMinutes(1); // Запускать не позже, чем за минуту до полуночи!!! var remainingTimeController = new RemainingTimeController(expectedTime); remainingTimeController.StopTimer(); Assert.AreEqual(expectedTime, remainingTimeController.RemainingTimeToLock); }
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); }
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); }