public void WillFireEvent_WithPrevMinutesTickCount_WhenHomeOfficeActivityDetectedInNextMinuteOnly() { // it's morning, 6:47 min 10 sec now, // but it was 6:46 min 59 sec when we've logged in (and thus made the 1st home-office activity) Calculations.NowTime = new DateTime(2016, 6, 25, 6, 47, 10); var detector = new Fake_HomeOfficeDetector(); detector.ForcedEnvironmentTickCount = (uint)TimeSpan.FromHours(10).TotalMilliseconds; // system running for 10 hours detector.ForcedIsRemoteSession = true; detector.ForcedLastInputTime = (uint)detector.ForcedEnvironmentTickCount - (uint)TimeSpan.FromSeconds(11).TotalMilliseconds; // last input event 11 seconds earlier, thus in the previous minute Fake_HomeOfficeDetector.HomeOfficeActivityEventArgs firedArgs = null; detector.HomeOfficeActivityOfDayDetected += (sender, args) => firedArgs = args; detector.DetectNow(); Assert.AreEqual(detector.ForcedLastInputTime, detector.ForcedPublic_tickCountFromDateTime(firedArgs.EventTime)); }
public void WillFireEvent_WithTimeOfLogon_WhenTimeMergeStartedOnlyAfterUserLoggedOn() { int homeOfficeStarted = 0; var detector = new Fake_HomeOfficeDetector(); detector.HomeOfficeActivityOfDayDetected += (sender, args) => homeOfficeStarted++; // it's morning on a "home office" day, 7:05, when user starts TimeMerge app Calculations.NowTime = new DateTime(2016, 10, 31, 7, 5, 0); detector.ForcedEnvironmentTickCount = (uint)TimeSpan.FromHours(10).TotalMilliseconds; // system running for 10 hours detector.ForcedIsRemoteSession = true; detector.ForcedLastInputTime = (uint)(TimeSpan.FromHours(10).TotalMilliseconds - 1); // last input event just now detector.ForcedMostRecentLogonTime = detector.ForcedEnvironmentTickCount - (uint)TimeSpan.FromMinutes(5).TotalMilliseconds; // logged on 5 minutes before starting TimeMerge Fake_HomeOfficeDetector.HomeOfficeActivityEventArgs firedArgs = null; detector.HomeOfficeActivityOfDayDetected += (sender, args) => firedArgs = args; detector.DetectNow(); Assert.AreEqual(1, homeOfficeStarted); Assert.AreEqual(detector.ForcedMostRecentLogonTime, detector.ForcedPublic_tickCountFromDateTime(firedArgs.EventTime)); }