3 Comments

  • Hey, I have seen this some place not that long ago.... Hum where could that have been.

    Thanks for the help.

  • I don't get it.

    1. If your subject class is already configured for injection, then why would it need to use the injection framework itself? Wouldn't it just have its dependencies injected (via constructor or setter)?

    2. If you need to test a class that uses the DI framework, you're better off putting a layer of abstraction between the subject class and your DI framework anyway, in case you want to switch frameworks in the future. And in that case, you just mock your abstraction layer instead of injecting mocks into the DI config.

    Or am I missing something?

  • Roy,

    You need to do this:

    ObjectFactory.InjectStub(emailStub.MockedInstance);

    or

    ObjectFactory.Inject(logMock.MockedInstance);


    You have to inject an object against the desired "PluginType." By omitting the T in Inject() StructureMap plugs it into "object."

Comments have been disabled for this content.