コード例 #1
0
        public async Task FailsOnce()
        {
            await Endeavor.Go <PlayItAgainException>(async() => await Go(timesFailed == 0),
                                                     e => CountFails(), 3, 50);

            timesFailed.Should().Be(1);
        }
コード例 #2
0
        public async Task FailsAFewTimes()
        {
            await Endeavor.Go <PlayItAgainException>(async() => await Go(timesFailed <= 3),
                                                     async e => await CountFails(), 5, 50);

            timesFailed.Should().Be(4);
        }
コード例 #3
0
        public async Task AlwaysFails()
        {
            try
            {
                await Endeavor.Go <PlayItAgainException>(async() => await Bork(),
                                                         async e => await CountFails(), 3, 50);

                throw new Exception($"didn't catch an {nameof(PlayItAgainException)}");
            }
            catch (PlayItAgainException ex)
            {
                ex.Should().NotBeNull();
            }

            timesFailed.Should().Be(3);
        }
コード例 #4
0
 public void Success()
 {
     Endeavor.Go <PlayItAgainException>(() => Go(),
                                        e => throw new Exception("should not be here"));
     timesFailed.Should().Be(0);
 }