Integration test mediatr handlers BUT populate HttpContext #836
Answered
by
svrooij
thatdotnetguy
asked this question in
Q&A
-
I'm setting up some integration tests for mediatr handlers using xunit, respawn, and webapplicationfactory.... One of classes ultimately called by the mediatr handler that is being tested.. has a dependency on IHttpContextAccessor as you can see below thought I could do AddSingleton for the webapplicationfactory.... But when the integration test runs.. the httpContextAccessor is not null but the HttpContext is ALWAYS null. Surely there is something I can do? |
Beta Was this translation helpful? Give feedback.
Answered by
svrooij
Feb 14, 2023
Replies: 1 comment
-
I thing you need to create a new class that implements the IHttpContextAccessor and allows you to return the http context. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
thatdotnetguy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I thing you need to create a new class that implements the IHttpContextAccessor and allows you to return the http context.