ninject / Ninject.MockingKernel

Extension for Ninject aiding testability in Moq, NSubstitute, and FakeItEasy
http://ninject.org/
Other
62 stars 25 forks source link

Using with nsubstitute ? #14

Closed iangregsondev closed 9 years ago

iangregsondev commented 11 years ago

HI there,

I looked at the example on the wiki but the nsubstitute doesn't seem to work.

I have tried the following, any ideas ?

this.kernel = new NSubstituteMockingKernel();

var summaryService = this.kernel.GetMock(); // GetMock not available Anybody using it ?

Thanks

kevinkuszyk commented 10 years ago

Are you still having a problem with this?

The correct method call is:

var summaryService = kernel.Get<SummaryService>()
Roemer commented 8 years ago

I'm struggling here as well. Am I right that the only benefit of Ninject.MockingKernel for NSubstitute is that it will automatically generate mocks if I do not bind to something specific?

kevinkuszyk commented 8 years ago

@Roemer what api are you using and what issue are you hitting?

Am I right that the only benefit of Ninject.MockingKernel for NSubstitute is that it will automatically generate mocks if I do not bind to something specific?

Yes, it's an auto mocking container. You ask it to resolve the dependencies for a class you want to test, and it will inject substitutes / mocks for you.

My test framework wraps the Ninject mocking kernel and makes it easier to write tests. Have a look at the TestsFor base class and tests for example usage.