Extension for Ninject aiding testability in Moq, NSubstitute, RhinoMocks and FakeItEasy
C# Batchfile
Latest commit 774e7c9 Jul 1, 2015 @scott-xu scott-xu Upgrade Moq
Permalink
Failed to load latest commit information.
lib/Ninject Upgrade Moq Jul 1, 2015
nuget-FakeItEasy Update Ninject.MockingKernel.FakeItEasy.nuspec Jan 4, 2015
nuget-NSubstitute Update nuspec, readme and sln Nov 5, 2014
nuget-RhinoMocks Update nuspec, readme and sln Nov 5, 2014
nuget-moq Add support for mock of delegates. (Supported as of Moq 4.1.) Jun 15, 2015
nuget Update nuspec, readme and sln Nov 5, 2014
packages Upgrade Moq Jul 1, 2015
src Upgrade Moq Jul 1, 2015
tools Add support for mock of delegates. (Supported as of Moq 4.1.) Jun 15, 2015
.gitignore Upgrade Moq Jul 1, 2015
HowToBuild.txt Updated How to Build - Reference teamcity.bbv.ch instead of codebetter Jan 10, 2014
LICENSE.txt Added license file Feb 18, 2011
Ninject.MockingKernel with Silverlight Unittesting.sln Add support for FakeItEasy Jan 4, 2015
Ninject.MockingKernel.FakeItEasy.build Update Ninject.MockingKernel.FakeItEasy.build Jan 4, 2015
Ninject.MockingKernel.Moq.build Upgrade Moq Jul 1, 2015
Ninject.MockingKernel.NSubstitute.build Removed mono-2.0 target. Apr 26, 2014
Ninject.MockingKernel.RhinoMocks.build Removed mono-2.0 target. Apr 26, 2014
Ninject.MockingKernel.build Upgrade Moq Jul 1, 2015
Ninject.MockingKernel.sln Add support for FakeItEasy Jan 4, 2015
Ninject.build Revert "Changed the build scripts that WP7 Uni Tests are not executed… Mar 20, 2014
Ninject.include Upgrade Moq Jul 1, 2015
README.md Add support for FakeItEasy Jan 4, 2015
ReleaseNotes.md Add support for FakeItEasy Jan 4, 2015
UnzipDependencies.cmd Improved Build scripts to allow the creation of zip files with a spec… Dec 6, 2010
build-alpha.cmd Updated to nuget 1.6 and added support for pre release packages Dec 22, 2011
build-beta.cmd Updated to nuget 1.6 and added support for pre release packages Dec 22, 2011
build-rc1.cmd Updated to nuget 1.6 and added support for pre release packages Dec 22, 2011
build-release.cmd Updated to NuGet 1.3 May 3, 2011
build.cmd Added build scripts (no SL Tests at the moment) Oct 21, 2010
nuget.cmd Updated to nuget 1.6 and added support for pre release packages Dec 22, 2011

README.md

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));
  1. 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.

  2. 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