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 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); }