Exemple #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);
            }
        }
Exemple #2
0
 public async Task MyExecuteAsync(string arg1, StubProbe probe, CancellationToken cancellationToken)
 {
     await Task.Run(() =>
     {
         this.probe.Count++;
         probe.Count++;
         System.Diagnostics.Trace.WriteLine($"+++ hello from custom job {DateTime.UtcNow.ToString("o")} " + arg1);
     });
 }
Exemple #3
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);
        }
Exemple #4
0
 public StubCustomJob(StubProbe probe)
 {
     this.probe = probe;
 }
Exemple #5
0
 public StubJob(StubProbe probe)
 {
     this.probe = probe;
 }