Class ProblemDetailsExceptionHandlerTests
- Namespace
- ProjectTemplate.Web.Tests
- Assembly
- ProjectTemplate.Web.Tests.dll
Provides contract tests for centralized Problem Details exception handling.
public sealed class ProblemDetailsExceptionHandlerTests
- Inheritance
-
ProblemDetailsExceptionHandlerTests
- Inherited Members
Properties
ExceptionMappings
public static TheoryData<ProblemDetailsExceptionHandlerTests.ProblemDetailsExceptionCase, int, string> ExceptionMappings { get; }
Property Value
Methods
TryHandleAsync_DevelopmentEnvironment_IncludesExceptionMessage()
Verifies that development responses include the exception message for diagnostics.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 167)]
public Task TryHandleAsync_DevelopmentEnvironment_IncludesExceptionMessage()
Returns
TryHandleAsync_ExceptionMappings_WriteExpectedProblemDetails(ProblemDetailsExceptionCase, int, string)
Verifies that supported exception types are mapped to the expected status code and title.
[Theory("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 30)]
[MemberData("ExceptionMappings", new object?[] { })]
public Task TryHandleAsync_ExceptionMappings_WriteExpectedProblemDetails(ProblemDetailsExceptionHandlerTests.ProblemDetailsExceptionCase exceptionCase, int expectedStatusCode, string expectedTitle)
Parameters
exceptionCaseProblemDetailsExceptionHandlerTests.ProblemDetailsExceptionCaseexpectedStatusCodeintexpectedTitlestring
Returns
TryHandleAsync_NonProblemDetailsRequest_ReturnsFalse()
Verifies that non-Problem-Details requests are ignored by the handler.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 192)]
public Task TryHandleAsync_NonProblemDetailsRequest_ReturnsFalse()
Returns
TryHandleAsync_ProductionArgumentException_IsServerErrorAndDoesNotExposeRawExceptionDetail()
Verifies that production ArgumentException responses are treated as server errors and hide raw details.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 134)]
public Task TryHandleAsync_ProductionArgumentException_IsServerErrorAndDoesNotExposeRawExceptionDetail()
Returns
TryHandleAsync_ProductionBadHttpRequestException_DoesNotExposeRawExceptionDetail()
Verifies that production request-level client-error responses do not expose raw exception messages.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 101)]
public Task TryHandleAsync_ProductionBadHttpRequestException_DoesNotExposeRawExceptionDetail()
Returns
TryHandleAsync_ResponseAlreadyStarted_ReturnsFalse()
Verifies that the handler does not attempt to write after the response has started.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 215)]
public Task TryHandleAsync_ResponseAlreadyStarted_ReturnsFalse()
Returns
TryHandleAsync_UnknownProductionException_DoesNotExposeRawExceptionDetail()
Verifies that unknown production exceptions use a generic server-error detail.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/ProblemDetailsExceptionHandlerTests.cs", 68)]
public Task TryHandleAsync_UnknownProductionException_DoesNotExposeRawExceptionDetail()