public async Task InvokeAsync_TimesOutAndNoFallback_ThrowsCommandException() { var command = new TimingOutWithoutFallbackCommand(TimeSpan.FromMilliseconds(100)); try { await command.InvokeAsync(); } catch (CommandFailedException) { return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_WithTimeout_TimesOutAndThrowsCommandException() { var command = new TimingOutWithoutFallbackCommand(Timeout); try { await command.InvokeAsync(); } catch (CommandFailedException e) { Assert.True(e.GetBaseException() is OperationCanceledException); return; } AssertX.FailExpectedException(); }
public async Task InvokeAsync_OperationCanceledException() { var mockStats = new Mock <IStats>(); var command = new TimingOutWithoutFallbackCommand(TimeSpan.FromMilliseconds(100)) { Stats = mockStats.Object, }; try { await command.InvokeAsync(); } catch (CommandFailedException e) { Assert.True(e.GetBaseException() is OperationCanceledException); mockStats.Verify(m => m.Elapsed("mjolnir command test.TimingOutWithoutFallback total", "Canceled", It.IsAny <TimeSpan>()), Times.Once); mockStats.Verify(m => m.Elapsed("mjolnir command test.TimingOutWithoutFallback execute", "Canceled", It.IsAny <TimeSpan>()), Times.Once); return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_OperationCanceledException() { var mockStats = new Mock<IStats>(); var command = new TimingOutWithoutFallbackCommand(TimeSpan.FromMilliseconds(100)) { Stats = mockStats.Object, }; try { await command.InvokeAsync(); } catch (CommandFailedException e) { Assert.True(e.GetBaseException() is OperationCanceledException); mockStats.Verify(m => m.Elapsed("mjolnir command test.TimingOutWithoutFallback total", "Canceled", It.IsAny<TimeSpan>()), Times.Once); mockStats.Verify(m => m.Elapsed("mjolnir command test.TimingOutWithoutFallback execute", "Canceled", It.IsAny<TimeSpan>()), Times.Once); return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_TimesOutAndNoFallback_ThrowsCommandException() { var command = new TimingOutWithoutFallbackCommand(TimeSpan.FromMilliseconds(100)); await Assert.ThrowsAsync<CommandTimeoutException>(() => command.InvokeAsync()); }