public async Task InvokeAsync_TaskFaultsAndFallbackRethrowsInstigator()
        {
            var mockStats = new Mock<IStats>();
            var command = new FaultingTaskWithInstigatorRethrowingFallbackCommand
            {
                Stats = mockStats.Object,
            };

            try
            {
                await command.InvokeAsync();
            }
            catch (CommandFailedException e)
            {
                Assert.True(e.IsFallbackImplemented);
                mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingTaskWithInstigatorRethrowingFallback fallback", "Failure", It.IsAny<TimeSpan>()), Times.Once);
                return; // Expected.
            }

            AssertX.FailExpectedException();
        }
Beispiel #2
0
        public async Task InvokeAsync_TaskFaultsAndFallbackRethrowsInstigator()
        {
            var mockStats = new Mock<IStats>();
            var command = new FaultingTaskWithInstigatorRethrowingFallbackCommand
            {
                Stats = mockStats.Object,
            };

            var e = await Assert.ThrowsAsync<CommandFailedException>(command.InvokeAsync);

            Assert.True(e.IsFallbackImplemented);
            mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingTaskWithInstigatorRethrowingFallback fallback", "Failure", It.IsAny<TimeSpan>()), Times.Once);
        }