コード例 #1
0
        public void TimeoutMatchesInput()
        {
            TimeSpan            timeout = TimeSpan.FromMilliseconds(1);
            TimerWheelTimerCore timer   = new TimerWheelTimerCore(timeout, Mock.Of <TimerWheel>());

            Assert.AreEqual(timeout, timer.Timeout);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void NullTimerWheel()
 {
     TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.FromMilliseconds(1), null);
 }
コード例 #6
0
 public void TimeSpanZero()
 {
     TimerWheelTimerCore timer = new TimerWheelTimerCore(TimeSpan.Zero, Mock.Of <TimerWheel>());
 }