public void TestActivityThenForceLogThenIdleThenActivityThenIdleLoggingInEmptyLog()
        {
            // | Activity, Force Log, Idle, Activity, Idle
            var settings = GetActivityTrackingSettingsFake();
            var activitiesRepository = GetActivitiesRepositoryFake();
            var userInputTracker = GetUserInputTrackerFake();

            var records = new List<ActivityRecord>();
            var activityRecordsRepository = GetActivityRecordsRepositoryFake(records);

            var tracker = new UserActivityTracker(
                activityRecordsRepository,
                activitiesRepository,
                settings,
                userInputTracker);

            tracker.Start();

            DateTime timeStamp = DateTime.Now;
            userInputTracker.RaiseUserInputDetectedEvent(timeStamp);
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.MinimumActivityDuration);

            tracker.LogUserActivity(false, true, timeStamp);

            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.MinimumIdleDuration);
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.MinimumActivityDuration);
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.MinimumIdleDuration);

            records.Should().HaveCount(4);

            ActivityRecord activityRecord = records[0];
            activityRecord.Idle.Should().Be(false);
            activityRecord.Duration.Should().Be(settings.MinimumActivityDuration);
            activityRecord.Activity.Should().Be(WorkActivity);

            ActivityRecord idleRecord = records[1];
            idleRecord.Idle.Should().Be(true);
            idleRecord.Duration.Should().Be(settings.MinimumIdleDuration);
            idleRecord.Activity.Should().Be(BreakActivity);
            idleRecord.StartTime.Should().Be(activityRecord.EndTime);

            activityRecord = records[2];
            activityRecord.Idle.Should().Be(false);
            activityRecord.Duration.Should().Be(settings.MinimumActivityDuration);
            activityRecord.Activity.Should().Be(WorkActivity);
            activityRecord.StartTime.Should().Be(idleRecord.EndTime);

            idleRecord = records[3];
            idleRecord.Idle.Should().Be(true);
            idleRecord.Duration.Should().Be(settings.MinimumIdleDuration);
            idleRecord.Activity.Should().Be(BreakActivity);
            idleRecord.StartTime.Should().Be(activityRecord.EndTime);

            tracker.Stop();
        }
        public void TestShortIdleThenShortActivityThenIdleLoggingWithLastRecordIndicatingInactivityInLog()
        {
            // Idle | Short Idle, Short Activity, Idle
            var settings = GetActivityTrackingSettingsFake();
            var activitiesRepository = GetActivitiesRepositoryFake();
            var userInputTracker = GetUserInputTrackerFake();

            var records = new List<ActivityRecord>();
            var activityRecordsRepository = GetActivityRecordsRepositoryFake(records);

            var tracker = new UserActivityTracker(
                activityRecordsRepository,
                activitiesRepository,
                settings,
                userInputTracker);

            tracker.Start();

            DateTime timeStamp = DateTime.Now;
            records.Add(
                new ActivityRecord(1)
                {
                    Activity = WorkActivity,
                    Idle = true,
                    StartTime = timeStamp - settings.MinimumIdleDuration,
                    EndTime = timeStamp
                });

            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.GetShortIdleDuration());
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.GetShortActivityDuration());
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.MinimumIdleDuration);

            records.Should().HaveCount(1);

            ActivityRecord initialRecord = records[0];
            initialRecord.Idle.Should().Be(true);
            initialRecord.Duration.Should()
                .Be(
                    settings.MinimumIdleDuration + settings.GetShortIdleDuration() + settings.GetShortActivityDuration()
                    + settings.MinimumIdleDuration);

            tracker.Stop();
        }
        public void TestShortActivityThenIdleLoggingInEmptyLog()
        {
            // | Short Activity, Idle
            var settings = GetActivityTrackingSettingsFake();
            var activitiesRepository = GetActivitiesRepositoryFake();
            var userInputTracker = GetUserInputTrackerFake();

            var records = new List<ActivityRecord>();
            var activityRecordsRepository = GetActivityRecordsRepositoryFake(records);

            var tracker = new UserActivityTracker(
                activityRecordsRepository,
                activitiesRepository,
                settings,
                userInputTracker);

            tracker.Start();

            DateTime timeStamp = DateTime.Now;
            userInputTracker.RaiseUserInputDetectedEvent(timeStamp);
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.GetShortActivityDuration());
            userInputTracker.RaiseUserInputDetectedEvent(ref timeStamp, settings.MinimumIdleDuration);

            records.Should().HaveCount(1);

            ActivityRecord idleRecord = records[0];
            idleRecord.Idle.Should().Be(true);
            idleRecord.Duration.Should().Be(settings.MinimumIdleDuration + settings.GetShortActivityDuration());
            idleRecord.Activity.Should().Be(BreakActivity);

            tracker.Stop();
        }