public void TestIncorrectRemove() { var evaluator = new SchedulingServiceImpl(new TimeSourceServiceImpl(), _container.Resolve <ILockManager>()); var callback = new SupportScheduleCallback(); evaluator.Remove(callback, 0); }
public void TestIncorrectRemove() { var evaluator = new SchedulingServiceImpl(new TimeSourceServiceImpl()); var callback = new SupportScheduleCallback(); evaluator.Remove(callback, 0); }
public void TestTrigger() { long startTime = 0; _service.Time = 0; // Add callbacks _service.Add(20, _callbacks[3], _slots[1][1]); _service.Add(20, _callbacks[2], _slots[1][0]); _service.Add(20, _callbacks[1], _slots[0][1]); _service.Add(21, _callbacks[0], _slots[0][0]); Assert.IsTrue(_service.IsScheduled(_callbacks[3])); Assert.IsTrue(_service.IsScheduled(_callbacks[0])); // Evaluate before the within time, expect not results startTime += 19; _service.Time = startTime; EvaluateSchedule(); CheckCallbacks(_callbacks, new[] { 0, 0, 0, 0, 0 }); Assert.IsTrue(_service.IsScheduled(_callbacks[3])); // Evaluate exactly on the within time, expect a result startTime += 1; _service.Time = startTime; EvaluateSchedule(); CheckCallbacks(_callbacks, new[] { 0, 1, 2, 3, 0 }); Assert.IsFalse(_service.IsScheduled(_callbacks[3])); // Evaluate after already evaluated once, no result startTime += 1; _service.Time = startTime; EvaluateSchedule(); CheckCallbacks(_callbacks, new[] { 4, 0, 0, 0, 0 }); Assert.IsFalse(_service.IsScheduled(_callbacks[3])); startTime += 1; _service.Time = startTime; EvaluateSchedule(); Assert.AreEqual(0, _callbacks[3].ClearAndGetOrderTriggered()); // Adding the same callback more than once should cause an exception _service.Add(20, _callbacks[0], _slots[0][0]); _service.Add(28, _callbacks[0], _slots[0][0]); _service.Remove(_callbacks[0], _slots[0][0]); _service.Add(20, _callbacks[2], _slots[1][0]); _service.Add(25, _callbacks[1], _slots[0][1]); _service.Remove(_callbacks[1], _slots[0][1]); _service.Add(21, _callbacks[0], _slots[0][0]); _service.Add(21, _callbacks[3], _slots[1][1]); _service.Add(20, _callbacks[1], _slots[0][1]); SupportScheduleCallback.SetCallbackOrderNum(0); startTime += 20; _service.Time = startTime; EvaluateSchedule(); CheckCallbacks(_callbacks, new[] { 0, 1, 2, 0, 0 }); startTime += 1; _service.Time = startTime; EvaluateSchedule(); CheckCallbacks(_callbacks, new[] { 3, 0, 0, 4, 0 }); _service.Time = startTime + int.MaxValue; EvaluateSchedule(); CheckCallbacks(_callbacks, new[] { 0, 0, 0, 0, 0 }); }