Skip to content

Faking authorization and injecting services #855

Answered by egil
friedice5467 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @friedice5467

You should only do one of those:

  1. Inherit from TestContext
  2. New TestContext up in your test

When you inherit it, your test class becomes a TestContext, and you do not need to new it up.

Your problem is likely that you are adding your services to your test classes Services collection but using the TestContext you new up to render your components, which means the services are missing from it and thus not available to your components.

I also suspect you don't need the AddAuthorizationCore call.

Hope this helps.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by friedice5467
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants