Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

Issues upgrading build server from 6.2.5 to 7.0.6

+3 votes
I've just installed Isolator 7.0.6 on our TeamCity build server. It previously had Isolator 6.2.5 and all tests were green. I also changed out MSBuild scripts to use the correct folder, so I changed:
<Import Project="C:\Program Files (x86)\Typemock\Isolator\6.2\TypeMock.MSBuild.Tasks" />
To this:
<Import Project="C:\Program Files (x86)\Typemock\Isolator\7\TypeMock.MSBuild.Tasks" />


After upgrading many tests started failing. Practically all the exceptions complain about SimpleBitVector32 and look like so:

Test method GRT.Core.Distributor.Test.MessageDistributorEntryPointTest.HandleMessage_NoAdapters_ReturnHandled threw exception: 
 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'GRT.Core.Distributor.Service.Adapter.AdapterManager' threw an exception. ---> TypeMock.TypeMockException: 
 *** Faking behavior on struct System.Configuration.SimpleBitVector32 is not supported in the following cases:
 1. Faking behavior on more than one struct of the same type.
 2. Faking behavior on more than one method on the same struct.
 
    at gk.a(Type A_0, Object A_1, MethodBase A_2, String A_3, TypeParams A_4)
    at gk.a(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
    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, Object p1)
    at System.Configuration.SimpleBitVector32.get_Item(Int32 bit)
    at System.Configuration.FactoryRecord.get_IsGroup()
    at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
    at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
    at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
    at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
    at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
    at System.Configuration.ConfigurationManager.GetSection(String sectionName)
    at System.Configuration.ConfigurationManager.get_ConnectionStrings()
    at GRT.Core.Distributor.Service.Adapter.AdapterManager.LoadAdapters() in e:\TeamCity\buildAgent\work\1d8b67c28b2b4cc5\BackEnd\GRT.Core\GRT.Core.Distributor\GRT.Core.Distributor.Service\Adapter\AdapterManager.cs:line 97
    at GRT.Core.Distributor.Service.Adapter.AdapterManager..ctor() in e:\TeamCity\buildAgent\work\1d8b67c28b2b4cc5\BackEnd\GRT.Core\GRT.Core.Distributor\GRT.Core.Distributor.Service\Adapter\AdapterManager.cs:line 87
    at GRT.Core.Distributor.Service.Adapter.AdapterManager..cctor() in e:\TeamCity\buildAgent\work\1d8b67c28b2b4cc5\BackEnd\GRT.Core\GRT.Core.Distributor\GRT.Core.Distributor.Service\Adapter\AdapterManager.cs:line 23
  --- End of inner exception stack trace ---
     at GRT.Core.Distributor.Service.Adapter.AdapterManager.GetInstance()
    at GRT.Core.Distributor.Test.MessageDistributorEntryPointTest.<HandleMessage_NoAdapters_ReturnHandled>b__2() in e:\TeamCity\buildAgent\work\1d8b67c28b2b4cc5\BackEnd\GRT.Core\GRT.Core.Distributor\GRT.Core.Distributor.UnitTests\MessageDistributorEntryPointTest.cs:line 81
  --- End of inner exception stack trace ---
     at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
    at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Delegate.DynamicInvokeImpl(Object[] args)
    at System.Delegate.DynamicInvoke(Object[] args)
    at gr.c()
    at be.a(Boolean A_0)
    at dr.b(Boolean A_0)
    at iz.b(Boolean A_0)
    at iz.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5, Boolean A_6)
    at iz.b(Object A_0)
    at TypeMock.ArrangeActAssert.ExpectationEngine`1.a(TResult A_0)
    at GRT.Core.Distributor.Test.MessageDistributorEntryPointTest.HandleMessage_NoAdapters_ReturnHandled() in e:\TeamCity\buildAgent\work\1d8b67c28b2b4cc5\BackEnd\GRT.Core\GRT.Core.Distributor\GRT.Core.Distributor.UnitTests\MessageDistributorEntryPointTest.cs:line 90


What is causing the tests to break?
asked Jun 11, 2012 by allon.guralnek (3,550 points)

5 Answers

+3 votes
Here's a simple repro:

[TestClass, Isolated]
public class UnitTest1
{
   [TestMethod]
   public void TestMethod1()
   {
      Isolate.WhenCalled(() => Foo.Bar()).IgnoreCall();
   }
}

public class Foo
{
   public static int Count = ConfigurationManager.ConnectionStrings.Count;
   public static void Bar() { }
}


Interestingly, on my computer I get a different error depending on whether I run or debug the test. If I run it, I get the following (oddly with no stack trace):

Unit Test Adapter threw exception: 
Object reference not set to an instance of an object..


If I debug it, I get the fimiliar exception regarding SimpleBitVector32:

Test method TestProject1.UnitTest1.TestMethod1 threw exception: 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'TestProject1.Foo' threw an exception. ---> TypeMock.TypeMockException: 
*** Faking behavior on struct System.Configuration.SimpleBitVector32 is not supported in the following cases:
1. Faking behavior on more than one struct of the same type.
2. Faking behavior on more than one method on the same struct.

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, Object p1)
at System.Configuration.SimpleBitVector32.get_Item(Int32 bit)
at System.Configuration.FactoryRecord.get_IsGroup()
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, ref Boolean isRootDeclaredHere)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, ref Object result, ref Object resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at TestProject1.Foo..cctor() in UnitTest1.cs: line 25
--- End of inner exception stack trace ---
at TestProject1.Foo.Bar()
at TestProject1.UnitTest1.<TestMethod1>b__0() in UnitTest1.cs: line 19
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, ref SignatureStruct sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at gr.c()
at be.a(Boolean A_0)
at dr.b(Boolean A_0)
at iz.b(Boolean A_0)
at iz.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5, Boolean A_6)
at iz.a(Object A_0, Boolean A_1, Action A_2, Action A_3)
at iz.n()
at TestProject1.UnitTest1.TestMethod1() in UnitTest1.cs: line 19


Do I need to roll back to 6.2.5?
answered Jun 12, 2012 by allon.guralnek (3,550 points)
0 votes
Hi Allon,

Thanks for the repro.
Please try this patch, it should solve this issue.

 

Alex Galin | Support Team

answered Jun 12, 2012 by alex (17,910 points)
+3 votes
Thanks for the quick patch, Alex. Unfortunately it doesn't seem to solve the issue. My repro still throws the same exception. The only difference is that now it throws the SimpleBitVector32 exception both when running and debugging tests (I no longer get "Unit Test Adapter threw exception").

"TypeMock >> Options... >> About" shows 7.0.7.0 and I even tried restarting the computer, but it didn't help. Maybe there was some problem with the installation (I didn't manually uninstall 7.0.6)?
answered Jun 12, 2012 by allon.guralnek (3,550 points)
+3 votes
My fault! The project had the following references:

<Reference Include="TypeMock, Version=7.0.6.0, Culture=neutral, PublicKeyToken=3dae460033b8d8e2, processorArchitecture=MSIL" />
<Reference Include="Typemock.ArrangeActAssert, Version=7.0.6.0, Culture=neutral, PublicKeyToken=3dae460033b8d8e2, processorArchitecture=MSIL" />


I changed them to:

<Reference Include="TypeMock" />
<Reference Include="Typemock.ArrangeActAssert" />


And now the repro test passes! I guess somehow the 7.0.6 version stayed alive somewhere. I'll try it on my build server and get back to you.
answered Jun 12, 2012 by allon.guralnek (3,550 points)
+3 votes
I've installed it on our build servers and all tests are green. Thanks again!
answered Jun 12, 2012 by allon.guralnek (3,550 points)
...