public void TimeoutMatchesInput() { TimeSpan timeout = TimeSpan.FromMilliseconds(1); TimerWheelTimerCore timer = new TimerWheelTimerCore(timeout, Mock.Of <TimerWheel>()); Assert.AreEqual(timeout, timer.Timeout); }
public void SubscribesToWheel() { Mock <TimerWheel> mockedWheel = new Mock <TimerWheel>(); TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.FromMilliseconds(10), mockedWheel.Object); Task task = timer.StartTimerAsync(); Mock.Get(mockedWheel.Object) .Verify(w => w.SubscribeForTimeouts(It.Is <TimerWheelTimer>(t => t == timer)), Times.Once); }
public void Cancel() { Mock <TimerWheel> mockedWheel = new Mock <TimerWheel>(); TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.FromMilliseconds(10), mockedWheel.Object); Task task = timer.StartTimerAsync(); Assert.AreEqual(TaskStatus.WaitingForActivation, task.Status); timer.CancelTimer(); Assert.AreEqual(TaskStatus.Canceled, task.Status); }
public async Task CannotStartTwice() { Mock <TimerWheel> mockedWheel = new Mock <TimerWheel>(); TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.FromMilliseconds(10), mockedWheel.Object); List <Task> tasks = new List <Task>() { timer.StartTimerAsync(), timer.StartTimerAsync() }; await Task.WhenAll(tasks); }
public void NullTimerWheel() { TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.FromMilliseconds(1), null); }
public void TimeSpanZero() { TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.Zero, Mock.Of <TimerWheel>()); }