public async Task ToLogMessageAsync_UsingNullHttpResponse_MustThrowException() { // Arrange var loggerMock = new Mock <ILogger <HttpLoggingService> >(); var loggingService = new HttpLoggingService(loggerMock.Object); HttpResponse httpResponse = null; // Act // ReSharper disable once ExpressionIsAlwaysNull Func <Task> toLogMessageAsyncCall = async() => await loggingService.ToLogMessageAsync(httpResponse); // Assert await toLogMessageAsyncCall .Should() .ThrowExactlyAsync <ArgumentNullException>() .WithParameterName(nameof(httpResponse)); }
public void ShouldLog_UsingNullHttpContext_MustThrowException() { // Arrange var loggerMock = new Mock <ILogger <HttpLoggingService> >(); var loggingService = new HttpLoggingService(loggerMock.Object); HttpContext httpContext = null; // Act // ReSharper disable once ExpressionIsAlwaysNull Action shouldLogAction = () => loggingService.ShouldLog(httpContext); // Assert shouldLogAction .Should() .ThrowExactly <ArgumentNullException>("HTTP context is null") .WithParameterName(nameof(httpContext)); }