Class ErrorHandlingPipelineTests
- Namespace
- ProjectTemplate.Web.Tests
- Assembly
- ProjectTemplate.Web.Tests.dll
Provides integration tests for the unhandled-exception path through the centralized error-handling pipeline.
public sealed class ErrorHandlingPipelineTests
- Inheritance
-
ErrorHandlingPipelineTests
- Inherited Members
Remarks
Error handling is registered once, by UseProblemDetails(). These tests exercise an unhandled exception end
to end through the pipeline, so a second environment-aware error-handling registration added alongside it would
have to keep these behaviors intact. Status-code responses are covered separately by
AdvertisedBehaviorTests; this file covers the thrown-exception path, which was otherwise only
tested at the handler level, below the middleware ordering.
Methods
DirectRequestToErrorRouteWithoutStatusCode_IsNotFound()
Verifies that a direct request to the error route with no status code is also treated as not found.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ErrorHandlingPipelineTests.cs", 132)]
public Task DirectRequestToErrorRouteWithoutStatusCode_IsNotFound()
Returns
- Task
A task that represents the asynchronous test operation.
DirectRequestToErrorRoute_DoesNotHonorTheRequestedStatusCode(int)
Verifies that a direct request to the error route does not receive the status code it asked for.
[Theory("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ErrorHandlingPipelineTests.cs", 110)]
[InlineData(new object?[] { 0 })]
[InlineData(new object?[] { 200 })]
[InlineData(new object?[] { 418 })]
[InlineData(new object?[] { 500 })]
[InlineData(new object?[] { 999 })]
public Task DirectRequestToErrorRoute_DoesNotHonorTheRequestedStatusCode(int requestedStatusCode)
Parameters
requestedStatusCodeintThe status code supplied in the route.
Returns
- Task
A task that represents the asynchronous test operation.
Remarks
The error route is anonymous because it serves errors for unauthenticated requests. Honoring its route value let any caller select the response status, including values outside the range the error page serves, and produce an error-page log entry per request.
GenuineMissingPage_StillReachesTheErrorPageWithItsRealStatusCode()
Verifies that a genuine missing page still reaches the error page with its real status code.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ErrorHandlingPipelineTests.cs", 149)]
public Task GenuineMissingPage_StillReachesTheErrorPageWithItsRealStatusCode()
Returns
- Task
A task that represents the asynchronous test operation.
UnhandledException_DoesNotLeakExceptionDetail()
Verifies that an unhandled exception does not leak exception detail outside Development.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ErrorHandlingPipelineTests.cs", 78)]
public Task UnhandledException_DoesNotLeakExceptionDetail()
Returns
- Task
A task that represents the asynchronous test operation.
UnhandledException_OnApiShapedRequest_ReturnsProblemDetails()
Verifies that an unhandled exception on an API-shaped request produces a Problem Details response.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ErrorHandlingPipelineTests.cs", 25)]
public Task UnhandledException_OnApiShapedRequest_ReturnsProblemDetails()
Returns
- Task
A task that represents the asynchronous test operation.
UnhandledException_OnBrowserShapedRequest_ReturnsErrorPage()
Verifies that an unhandled exception on a browser-shaped request produces the re-executed error page.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ErrorHandlingPipelineTests.cs", 54)]
public Task UnhandledException_OnBrowserShapedRequest_ReturnsErrorPage()
Returns
- Task
A task that represents the asynchronous test operation.