ninject / Ninject.MockingKernel

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

Could Not Load Type 'Ninject.MockingKernel.AdditionalInterfaceParameter' #25

Closed kabua closed 8 years ago

kabua commented 8 years ago

I just installed Ninject.MockingKernel.FakeItEasy 3.2.2 stable and I have the following simple test

        [TestMethod]
        public void TestMethod2()
        {
            using (FakeItEasyMockingKernel kernel = new FakeItEasyMockingKernel())
            {
                var cs = kernel.Get<CustomerService>();
                A.CallTo(() => cs.CreateAsync(CancellationToken.None, "a", "b", "c"))
                   .Returns(new Customer("Adam", "Bob", "Custard"));
                   ...
            }
        }

When to code tries to execute the kernel.Get<>() I get the following error:

Could not load type 'Ninject.MockingKernel.AdditionalInterfaceParameter' from assembly
'Ninject.MockingKernel, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7'.

I've opened up the Object Browser for Nigject.MockingKernel and sure enough the Ninject.MockingKernel.AdditionalInterfaceParameter is missing from ...\packages\Ninject.MockingKernel.3.2.0.0\lib\net45-full\Ninject.MockingKernel.dll

I've looked in the source code and found the file here.

Also, I noticed that the documentation stated to use ```kernel.GetMock<>() but the function is also missing or the documentation is out dated.

Am I missing something?

One last thing; the documentation for class FakeItEasyMockingKernel state "Mocking kernel for NSubstitute" I think it should read "Mocking kernel for FakeItEasy".

scott-xu commented 8 years ago

Please make sure all packages are up to date.

skrysmanski commented 8 years ago

@scott-xu The problem is that (at least for Ninject.MockingKernel.Moq) the dependency of version 3.2.2.0 to Ninject.MockingKernel says it requires at least 3.2.0.0 - which is wrong. It requires 3.2.2.0.

dependencies

Not sure whether this is the cause, but when you directly install Ninject.MockingKernel.Moq without having Ninject.MockingKernel installed manually before, NuGet installs Ninject.MockingKernel version 3.2.0.0 (rather than 3.2.2.0).

However, the newer version is available on NuGet. So, as soon as you close the "Manage NuGet Packages" window and reopen it, there will be an update for Ninject.MockingKernel available.

The same problem exists for NInject itself, also. If it was not installed previously, NuGet will install version 3.2.0.0 instead of 3.2.2.0.

If it matters, I'm seeing this problem on Visual Studio 2013.

iamyojimbo commented 7 years ago

This isn't fixed because when I directly installed the Moq package, I wound up at this issue. The resolution was to manually go and update the NuGet package. Works fine after that. See also #24.