예제 #1
0
        public async Task TypeExecuteWithCancellationAsync_Test()
        {
            // arrange
            var probe = new StubProbe();

            using (var cts = new CancellationTokenSource())
            {
                var sut    = new StubJob(probe);
                var thrown = false;

                // act
                try
                {
                    cts.CancelAfter(TimeSpan.FromMilliseconds(10));
                    await sut.ExecuteAsync("token", cts.Token, new[] { "a" }).AnyContext();
                }
                catch (OperationCanceledException)
                {
                    thrown = true;
                }

                // assert
                probe.Count.ShouldBe(1);
                thrown.ShouldBe(true);
            }
        }
예제 #2
0
        public async Task TypeExecuteAsync_Test()
        {
            // arrange
            var probe = new StubProbe();
            var sut   = new StubJob(probe);

            // act
            await sut.ExecuteAsync(new[] { "a" }).AnyContext();

            await sut.ExecuteAsync(new[] { "a" }).AnyContext();

            // assert
            probe.Count.ShouldBe(2);
        }