public void shouldNotifyWhenBeforeActiveThereIsLongIdlePeriod() { // arrange var idlePeriodLength = IDLE_TIMEOUT + 2.secs(); var periodIdleLong = PeriodBuilder.New(MIDDAY).Length(idlePeriodLength).Idle(); var periodActive = PeriodBuilder.NewAfter(periodIdleLong).Length(1.secs()).Active(); // act timeTableSUT.PeriodPassed(periodIdleLong); timeTableSUT.PeriodPassed(periodActive); // assert A.CallTo(() => listenerActivityListnerMock.NotifyActiveAfterBreak(idlePeriodLength)) .MustHaveHappened(Repeated.Exactly.Once); }
private void NotifyUserActivityListener(ActivityPeriod activityPeriod, ActivityPeriod mergedPeriod) { if (userActivityListner == null) { log.Debug("listener is null"); return; } if (activityPeriod is IdlePeriod) { log.Debug("period is idle"); return; } var periodMerged = !mergedPeriod.Equals(activityPeriod); if (periodMerged) { log.Debug("period merged"); return; } var periodBefore = periodStorage.GetPeriodBefore(activityPeriod.Start); if (!(periodBefore is IdlePeriod)) { log.Debug("period before was not idle"); return; } if (periodBefore.Length < policies.IdleTimeout) { log.Debug("period before too short " + periodBefore.Length + " expected " + policies.IdleTimeout); return; } if (!periodBefore.IsDirectlyBefore(activityPeriod)) { log.Debug("period before is not directly before, before " + periodBefore + ", added" + activityPeriod); return; } userActivityListner.NotifyActiveAfterBreak(periodBefore.Length); }