ninject / Ninject.MockingKernel

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

Is able mocking a concrete class? #32

Closed jeusdi closed 5 years ago

jeusdi commented 7 years ago

I've tried this:

//Setup Mocks
Mock<Core.Configuration.ICoreConfiguration> mockedConfiguration = this.IoCKernel.GetMock<Core.Configuration.ICoreConfiguration>();
mockedConfiguration.Setup(c => c.UserIdentities).Returns(configurationUsers);

Mock<Core.Kernel> kernel = this.IoCKernel.GetMock<Core.Kernel>();  <<<<

on <<<<< it throws an System.ArgumentException with this message:

Object instance was not created by Moq.

The stack trace is:

   at Moq.Mock.Get[T](T mocked)
   at Ninject.MockingKernel.Moq.MoqMockingKernel.GetMock[T]()
   at Tests.Kernel.Users.Moq.UsersManagementTests.InitializationWithUsersTest() in D:\projects\living\clients\NetCore\Tests.Kernel\Users\UsersTestsMoq.cs:line 41

Which is the difference between MockingKernel.Get<T> and MockingKernel.GetMock()?

jeusdi commented 7 years ago

Could you help me using this repository? I've also created a gitter room.

scott-xu commented 6 years ago

You are using both Moq and Nsubstitute. Please choose one of them.