Exemple #1
0
        public void RunAsyncWithoutTokenWhenNextSucceedsHasExpectedResult()
        {
            var callCount = 0;
            var logger    = new Action <Exception>(_ => callCount++);
            var next      = new FlawlessTaskRunner();
            var sut       = SutFactory(next, logger);

            sut.RunAsync().Wait();
            Assert.That(callCount, Is.EqualTo(0));
        }
Exemple #2
0
        public void RunAsyncWithCancelledTokenWhenNextSucceedsHasExpectedResult()
        {
            var callCount = 0;
            var logger    = new Action <Exception>(_ => callCount++);
            var next      = new FlawlessTaskRunner();
            var sut       = SutFactory(next, logger);
            var source    = new CancellationTokenSource();

            source.Cancel();
            Assert.Throws <OperationCanceledException>(() => sut.RunAsync(source.Token).Wait(source.Token));
            Assert.That(callCount, Is.EqualTo(0));
        }