Closed p1971 closed 5 months ago
If you want the service collection to return your previously constructed mock from its GetService, you need to register the function to retrieve it, not the mock type which the container doesn't know how to instantiate:
subject.TryAddSingleton(typeof(ITestInterface<TestClass>), sp => mockInterface.Object);
Describe the Bug
I have a test that asserts that an extension method correctly registers all required dependencies such that clients should have everything fully registered. On dotnet8 this throws an exception. I've included a cut-down example.
Steps to Reproduce
Execute the code below - net6 works - net8 fails
Expected Behavior
Should also pass on dotnet8
Exception with Stack Trace
Version Info
Moq - 4.20.70