-
Take this very simple example.
The test will throw a NullReferenceException at line 22 StatusMessage.OnInitialized() because HttpContext is null. How do you work around any code that relies on HttpContext being instantiated? |
Beta Was this translation helpful? Give feedback.
Answered by
TimMurphy
Apr 12, 2024
Replies: 1 comment 1 reply
-
Here's the answer :-) var externalLoginInfo = new ExternalLoginInfo(
new ClaimsPrincipal(),
"login provider",
"provider key",
"provider display name"
);
var component = testContext.RenderComponent<ExternalLogin>(parameters => parameters
.Add(p => p.HttpContext, new DefaultHttpContext())
.Add(p => p.ExternalLoginInfo, externalLoginInfo)
); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
TimMurphy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the answer :-)