Consider adding new DefaultHttpContext()
to Mock<DefaultHttpContext>
alternatives
#17321
Labels
doc-enhancement
Improve the current content [org][type][category]
https://docs.microsoft.com/en-us/dotnet/core/compatibility/2.2-3.0#http-defaulthttpcontext-extensibility-removed
After some research, it seems
new DefaultHttpContext()
is a valid way way to mockHttpContext
in unit tests. Should this be added to the above-quoted line? Otherwise, it could be questioned whether newing aDefaultHttpContext()
is a Microsoft-accepted practice orMock<HttpContext>
is the only recommended approach.Supporting comments:
@JamesNK (dotnet/aspnetcore#6504 (comment)):
@davidfowl (dotnet/aspnetcore#6504 (comment)):
@anurse (https://stackoverflow.com/questions/45959605/inspect-defaulthttpcontext-body-in-unit-test-situation#comment78887946_45960766)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: