public async Task InvokeAsync_ExecuteFaultsAndNoFallback_ThrowsCommandException() { var command = new FaultingExecuteWithoutFallbackCommand(); try { await command.InvokeAsync(); } catch (CommandFailedException) { return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_ExecuteFaultsAndNoFallback_ThrowsCommandException() { var command = new FaultingExecuteWithoutFallbackCommand(); try { await command.InvokeAsync(); } catch (CommandFailedException) { return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_GeneralExceptionFromExecute() { var mockStats = new Mock<IStats>(); var mockMetricEvents = new Mock<IMetricEvents>(); var command = new FaultingExecuteWithoutFallbackCommand { Stats = mockStats.Object, MetricEvents = mockMetricEvents.Object, }; await Assert.ThrowsAsync<CommandFailedException>(command.InvokeAsync); mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingExecuteWithoutFallback total", "Faulted", It.IsAny<TimeSpan>()), Times.Once); mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingExecuteWithoutFallback execute", "Faulted", It.IsAny<TimeSpan>()), Times.Once); mockMetricEvents.Verify(m => m.CommandInvoked("test.FaultingExecuteWithoutFallback", It.IsAny<double>(), It.IsAny<double>(), "Faulted", "throw")); mockMetricEvents.Verify(m => m.RejectedByBulkhead(It.IsAny<string>(), It.IsAny<string>()), Times.Never); }
public async Task InvokeAsync_GeneralExceptionFromExecute() { var mockStats = new Mock<IStats>(); var command = new FaultingExecuteWithoutFallbackCommand { Stats = mockStats.Object }; try { await command.InvokeAsync(); } catch (CommandFailedException) { mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingExecuteWithoutFallback total", "Faulted", It.IsAny<TimeSpan>()), Times.Once); mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingExecuteWithoutFallback execute", "Faulted", It.IsAny<TimeSpan>()), Times.Once); return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_GeneralExceptionFromExecute() { var mockStats = new Mock <IStats>(); var command = new FaultingExecuteWithoutFallbackCommand { Stats = mockStats.Object }; try { await command.InvokeAsync(); } catch (CommandFailedException) { mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingExecuteWithoutFallback total", "Faulted", It.IsAny <TimeSpan>()), Times.Once); mockStats.Verify(m => m.Elapsed("mjolnir command test.FaultingExecuteWithoutFallback execute", "Faulted", It.IsAny <TimeSpan>()), Times.Once); return; // Expected. } AssertX.FailExpectedException(); }
public async Task InvokeAsync_ExecuteFaultsAndNoFallback_ThrowsCommandException() { var command = new FaultingExecuteWithoutFallbackCommand(); await Assert.ThrowsAsync<CommandFailedException>(() => command.InvokeAsync()); }