Closed troydai closed 9 years ago
@troydai Can you show a code sample of what the test would look like and what doesn't work? A unit test would generally not use DI at all - it would just create the fake/mock services it needs and pass them to the appropriate constructors. For functional tests this is largely the same story. And for other types of tests the particular DI system being used is set up with all the services that it needs, so the rest of the system just uses the test services as if they are real services (because, well, they are real services).
Add a reference to Microsoft.Framework.Runtime.Interfaces
and use:
var serviceProvider = CallContextServiceLocator.Locator.ServiceProvider;
@troydai It would be great to wrap this inside of a test fixture or something.
Not needed.
Right now there is no obvious way for test class to consume a IServiceProvider instance. That breaks the scenario which a test case needs to start a self-host web service. The KRunner does have change to obtain a IServiceProvider instance, we needs a mean to inject it to the test case.