public void TestPurgeInterval() { var scheduler = new SchedulingServiceImpl(new TimeSourceServiceImpl()); _cache = new DataCacheExpiringImpl(10, 20, ConfigurationCacheReferenceType.HARD, scheduler, new ScheduleSlot(1, 2), null); // age 10 sec, purge 1000 seconds // test single entry in cache scheduler.Time = 5000; _cache.PutCached(Make("a"), new EventTable[] { _lists[0] }); // a at 5 sec Assert.AreSame(_lists[0], _cache.GetCached(Make("a"))[0]); scheduler.Time = 26000; SupportSchedulingServiceImpl.EvaluateSchedule(scheduler); Assert.AreEqual(0, _cache.Count); // test 4 entries in cache scheduler.Time = 30000; _cache.PutCached(Make("b"), new EventTable[] { _lists[1] }); // b at 30 sec scheduler.Time = 35000; _cache.PutCached(Make("c"), new EventTable[] { _lists[2] }); // c at 35 sec scheduler.Time = 40000; _cache.PutCached(Make("d"), new EventTable[] { _lists[3] }); // d at 40 sec scheduler.Time = 45000; _cache.PutCached(Make("e"), new EventTable[] { _lists[4] }); // d at 40 sec scheduler.Time = 50000; SupportSchedulingServiceImpl.EvaluateSchedule(scheduler); Assert.AreEqual(2, _cache.Count); // only d and e Assert.AreSame(_lists[3], _cache.GetCached(Make("d"))[0]); Assert.AreSame(_lists[4], _cache.GetCached(Make("e"))[0]); }
public void TestImmediateTrigger() { // Should fireStatementStopped right away, wait time set to zero _observer = new TimerIntervalObserver(0, _beginState, _evaluator); _scheduleService.Time = 0; _observer.StartObserve(); Assert.AreEqual(_beginState, _evaluator.GetAndClearMatchEvents()[0]); _scheduleService.Time = 10000000; SupportSchedulingServiceImpl.EvaluateSchedule(_scheduleService); Assert.AreEqual(0, _evaluator.GetAndClearMatchEvents().Count); }
public void TestStartAndStop() { _scheduleService.Time = 0; _guard.StartGuard(); _guard.StopGuard(); _scheduleService.Time = 1001; SupportSchedulingServiceImpl.EvaluateSchedule(_scheduleService); Assert.AreEqual(0, _quitable.GetAndResetQuitCounter()); }
public void TestStartAndTrigger_time() { scheduleService.Time = 0; guard.StartGuard(); Assert.AreEqual(0, quitable.GetAndResetQuitCounter()); scheduleService.Time = 1000; SupportSchedulingServiceImpl.EvaluateSchedule(scheduleService); Assert.AreEqual(1, quitable.GetAndResetQuitCounter()); }
public void TestStartAndTrigger_time_and_count() { _scheduleService.Time = 0; _guard.StartGuard(); Assert.AreEqual(0, _quitable.GetAndResetQuitCounter()); _guard.Inspect(null); _guard.Inspect(null); _guard.Inspect(null); _scheduleService.Time = 1000; SupportSchedulingServiceImpl.EvaluateSchedule(_scheduleService); Assert.AreEqual(1, _quitable.GetAndResetQuitCounter()); }
public void TestStartAndObserve() { _scheduleService.Time = 0; _observer.StartObserve(); _scheduleService.Time = 1000; SupportSchedulingServiceImpl.EvaluateSchedule(_scheduleService); Assert.AreEqual(_beginState, _evaluator.GetAndClearMatchEvents()[0]); // Test start again _observer.StartObserve(); _scheduleService.Time = 1999; SupportSchedulingServiceImpl.EvaluateSchedule(_scheduleService); Assert.AreEqual(0, _evaluator.MatchEvents.Count); _scheduleService.Time = 2000; SupportSchedulingServiceImpl.EvaluateSchedule(_scheduleService); Assert.AreEqual(_beginState, _evaluator.GetAndClearMatchEvents()[0]); }