Replies: 1 comment
-
You can't shared the same scoped instance from the test. Each request creates a new scope. The test needs to get the instance during the request. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use the same service instance in the integration test code and the server code, but it happens that the service is constructed twice.
I created this test code to illustrate what is happening. In the constructor is created the
TestServer
using the same Startup as the server (which is right bellow).The test method is getting a
INumberGenerator
instance using theGetService
method and I am expecting that this instance that I got would be the same that the instance used in the controller, but it isn't.Is there any way to share the same scoped instance between server and test code?
This is the Startup code
And this is the code for the controller
Beta Was this translation helpful? Give feedback.
All reactions