Ninject.MockingKernel 0

Extension for Ninject aiding testability in Moq, NSubstitute, RhinoMocks and FakeItEasy

3 years after

Ninject.MockingKernel NuGet Version NuGet Downloads

This extension provides integration between Ninject and Moq/NSubstitute/RhinoMocks/FakeItEasy, creating a "lightweight" auto-mocking container.

Getting started

In your tests, you should use the MockingKernel instead of the StandardKernel. It adds the following features to Ninject:

  1. The following syntax will bind a service to the mocked object of a Mock<T>.

    Bind<IService>().ToMock();

    You can add additional interfaces to the mock:

    Bind<IService>().ToMock(typeof(IInterface1), typeof(IInterface2));
  2. If you request a service that has no binding, instead of creating an implicit self-binding, the MockingKernel will create an instance of Mock<T> and return the mocked object associated with it.

  3. A Reset() method is available, which clears the Ninject cache of any activated instances, regardless of whether they remain in scope. You can call this method after each test to ensure that instances are reactivated, without having to dispose and re-initialize the kernel each time.

Hat tip to Scott Reynolds for the idea, and to Sean Chambers for dogfooding.

Documentation

https://github.com/ninject/Ninject.MockingKernel/wiki

CI build status

Build Status

Related Repositories

EntityFramework.Testing

EntityFramework.Testing

EntityFramework Testing ...

EntityFramework.Testing

EntityFramework.Testing

EntityFramework Testing ...


Top Contributors

remogloor scott-xu iappert aloker bnordli

Releases

-   InitialVersion zip tar
-   3.2.2 zip tar
-   3.2.2-final zip tar
-   3.2.1-final zip tar
-   3.2.0-final zip tar
-   3.0.2 zip tar
-   3.0.0 zip tar
-   3.0.0-rc2 zip tar
-   3.0.0-rc1 zip tar
-   2.3.0.0 zip tar
-   2.2.0.0 zip tar