public void IsTaskReadyToExecute() { MultiAttemptTaskQueue q = new MultiAttemptTaskQueue(1, 5, TimeSpan.FromSeconds(5)); TaskQueue.TaskItem item = new TaskQueue.TaskItem(o => true, null); item.SystemData = new MultiAttemptTaskQueue.TaskRequest() { LastAttempt = DateTime.Now }; Assert.IsFalse(q.IsTaskReadyToExecute(item)); item.SystemData = new MultiAttemptTaskQueue.TaskRequest() { LastAttempt = DateTime.Now - TimeSpan.FromSeconds(6) }; Assert.IsTrue(q.IsTaskReadyToExecute(item)); }
public void NeedWaitTask() { MultiAttemptTaskQueue q = new MultiAttemptTaskQueue(1, 5, TimeSpan.FromSeconds(5)); TaskQueue.TaskItem item = new TaskQueue.TaskItem(o => true, null); item.SystemData = new MultiAttemptTaskQueue.TaskRequest() { LastAttempt = DateTime.Now }; Trace.WriteLine(q.NeedWaitTask(item).TotalMilliseconds); Assert.Greater(q.NeedWaitTask(item), TimeSpan.Zero); item.SystemData = new MultiAttemptTaskQueue.TaskRequest() { LastAttempt = DateTime.Now - TimeSpan.FromSeconds(6) }; Trace.WriteLine(q.NeedWaitTask(item).TotalMilliseconds); Assert.Less(q.NeedWaitTask(item), TimeSpan.Zero); }