ninject / Ninject.MockingKernel

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

Dependency problems getting MockingKernel working #9

Closed mikebridge closed 12 years ago

mikebridge commented 12 years ago

The MockingKernel looks very promising, but I'm having problems getting a version working with Moq on .Net 4.0----I'm using the Ninject.MockingKernel-2.2.0.0-release-net-4.0.zip download from git but it is has a hard dependency on a particular version of Moq:

System.IO.FileLoadException : Could not load file or assembly 'Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

So I checked the source out from git, and downloaded these to compile with it as per the HowToBuild.txt instructions:

Ninject.Extensions.NamedScope-2.2.0.0-release-net-4.0.zip Ninject.Extensions.ContextPreservation-2.2.0.0-release-net-4.0.zip Ninject-2.2.1.0-release-net-4.0.zip

I run UnzipDependencies.cmd but it deletes the version of Ninject.dll in lib (is it supposed to do that?), and indeed when I run ninject I received errors saying Ninject could not be found:

[msbuild] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Ninject". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\Visual Studio 2010\Projects\ninject.mockingkernel\src\Ninject.MockingKernel\Ninject.MockingKernel.csproj]

I opened the project in Visual Studio 2010 and upgraded to .Net 4.0 and fixed the dependencies there, but I'm now getting the following error:

Error   1   'Ninject.Syntax.IBindingToSyntax<T>' does not contain a definition for 'BindingConfiguration' and no extension method 'BindingConfiguration' accepting a first argument of type 'Ninject.Syntax.IBindingToSyntax<T>' could be found (are you missing a using directive or an assembly reference?)   C:\Visual Studio 2010\Projects\ninject.mockingkernel\src\Ninject.MockingKernel\ExtensionsForBindingSyntax.cs    (line 39)

I assume it has a dependency on a different version of Ninject. At that point I started to wonder if recompiling was indeed the best route to go---it looks like something's out of date. Any advice on how to continue?

I'd much rather just download a precompiled version that will not introduce a hard dependency on an old Moq version (I'm using the current-release version of Moq: v4.0.20926).

Thanks!

-Mike

remogloor commented 12 years ago

do debug 2.2 versions you must checkout the Maintenance_2.2 branch and not the master. Or take the latest build from teamcity which uses moq 4.0.x.x