public async Task HandleExceptionsTestWithHandlerButNoExceptionWritesResponse() { // Act await ExceptionMiddlewareExtensions.HandleExceptions(_httpContext, _mockLogger.Object) .ConfigureAwait(false); // Assert await VerifyResponse().ConfigureAwait(false); _mockLogger.VerifyExact(LogLevel.Error, "Request failed.", Times.Once()); }
public async Task HandleExceptionsTestNoExceptionHandlerWritesResponse() { // Arrange _httpContext.Features.Set <IExceptionHandlerFeature>(null); // Act await ExceptionMiddlewareExtensions.HandleExceptions(_httpContext, _mockLogger.Object) .ConfigureAwait(false); // Assert await VerifyResponse().ConfigureAwait(false); }
public async Task HandleExceptionsTestWithHandlerWithExceptionWritesResponse() { // Arrange var exMessage = "This is an exception"; var exception = new System.Exception(exMessage); _mockExHandlerFeature.SetupGet(x => x.Error).Returns(exception); // Act await ExceptionMiddlewareExtensions.HandleExceptions(_httpContext, _mockLogger.Object) .ConfigureAwait(false); // Assert await VerifyResponse(exMessage).ConfigureAwait(false); _mockLogger.VerifyContains(LogLevel.Error, "Request failed.", Times.Once()); }