chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes

I have a test that uses a c++ managed wrapper (which has unmanaged members)

Now, I would like to Isolate the c++ managed wrapper and run my test.

 

I mytest, I have the following lines, I want to mock the GetReaderInfo of ManagedWrapper

            var fakeReader = Isolate.Fake.Instance<Reader>(Members.ReturnRecursiveFakes);
            Isolate.Swap.AllInstances<Reader>().With(fakeReader);
            Isolate.WhenCalled(() => fakeReader.GetReaderInfo()).WillReturn(myreaderinfo);
 
I get the following error 
 
----------------------------------------------------------------------------8<--------------------------------------------------------------------------------
Test Name: TestMethod
Test FullName: UnitTests.namespace1.TestClass.TestMethod
Test Source: j:ilepath : line xx
Test Outcome: Failed
Test Duration: 0:00:xx.xx
 
Result Message:
Test method namespace.TestMethod threw exception: 
System.BadImageFormatException: Could not load file or assembly 'ManagedWrapper, Version=x.x.x.x, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
TestCleanup method Product.UnitTests.namespace1.TestClass.TestCleanup threw exception. System.TypeInitializationException: System.TypeInitializationException: The type initializer for 'namespace2.WrapperManager' threw an exception. ---> System.BadImageFormatException: Could not load file or assembly 'ManagedWrapper, Version=x.x.x.x, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format..
Result StackTrace:
at UnitTests.namespace1.TestClass.TestMethod()
 
TestCleanup Stack Trace
   at TypeMock.MockManager.getReturn(Object context, String typeName, String methodName, Object methodGenericParams, Boolean isDecorated, Boolean isInterceptedType, Object[] methodArguments)
   at Typemock.Interceptors.Profiler.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
   at UnitTests.namespace1.TestClass.TestCleanup() in j:ilepath.cs:line xx
---------------------------------------------------------------------------->8--------------------------------------------------------------------------------

 

asked by tsgd84 (600 points)

Please log in or register to answer this question.

...