public async Task ReturningFalseCancelsTimerWithCancellationToken()
{
// Arrange
Mock<IAsynchronousDelay> delay = new Mock<IAsynchronousDelay>();
AsynchronousIntervalTimer timer = new AsynchronousIntervalTimer(delay.Object, TimeSpan.FromMilliseconds(PretendDelayInMilliseconds), false);
CancellationTokenSource source = new CancellationTokenSource();
int repeatCount = 0;
// Act
await timer.ExecuteAsync(ct =>
{
repeatCount++;
return Task.FromResult(false);
}, source.Token);
// Assert
Assert.AreEqual(1, repeatCount);
source.Dispose();
}