I am trying to setup some unit tests for my project with uUnit. I have got the unit tests to work, but I would like to use a Mocking framework along with uUnit. However, all the mocking frameworks I have tried are giving me an internal compiler error.
Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in :0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in :0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in :0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in :0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in :0
at Mono.CSharp.Driver.Compile () [0x00000] in :0
at Mono.CSharp.Driver.Main (System.String args) [0x00000] in :0
I have tried Moq, Rhino Mocks, NMock and Simple.Mocking all with similar results. Is there any mocking framework that will work properly with Unity?
I tried creating a new project in Unity 4.0.1f2 from scratch and using moq and got the same error you are receiving. It looks like by default the Api Compatibilty Level in Player Settings is set to .NET 2.0 Subset. Changing this to .NET 2.0 and restarting Unity solved this problem for me. Doing this with Unity 3.5.7f6 also allowed me to get Moq working in Unity 3.5.
– thraxSTNow thankfully we have .Net 4.6 support, and i am trying to use Moq with unity project with Api compatibility 4.6 However, i have following compile error in my project:
– TheSmokingGnuerror CS0009: Metadata file does not contain valid metadata