tonerdo / pose

Replace any .NET method (including static and non-virtual) with a delegate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Isolation Enums fail

Tarig0 opened this issue · comments

The following test will not be able to pass due to the Enum.IsDefined function

shims.Add(Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 4, 4, 11, 50, 0)));

            //act
            string actual = null;
            PoseContext.Isolate(() => {
                Enum.IsDefined(typeof(DayOfWeek), 4); // error
                actual = DateTime.Now.ToString();
            }, shims.ToArray());
Result Message:	
Test method TestMethod1 threw exception: 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.

Result StackTrace:	
at dynamic_System.Runtime.CompilerServices.JitHelpers_UnsafeCastToStackPointer(RuntimeType& )
   at stub_System.Runtime.CompilerServices.JitHelpers_UnsafeCastToStackPointer(RuntimeType& , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Runtime.CompilerServices.JitHelpers_GetObjectHandleOnStack(RuntimeType& )
   at stub_System.Runtime.CompilerServices.JitHelpers_GetObjectHandleOnStack(RuntimeType& , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.ModuleHandle_GetModuleType(RuntimeModule )
   at stub_System.ModuleHandle_GetModuleType(RuntimeModule , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Reflection.RuntimeModule_get_RuntimeType(RuntimeModule )
   at stub_virt_System.Reflection.RuntimeModule_get_RuntimeType(RuntimeModule , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType+RuntimeTypeCache_.ctor(RuntimeTypeCache , RuntimeType )
   at stub_ctor_System.RuntimeType+RuntimeTypeCache_.ctor(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType_get_Cache(RuntimeType )
   at stub_System.RuntimeType_get_Cache(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType_get_GenericCache(RuntimeType )
   at stub_virt_System.RuntimeType_get_GenericCache(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Enum_GetCachedValuesAndNames(RuntimeType , Boolean )
   at stub_System.Enum_GetCachedValuesAndNames(RuntimeType , Boolean , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Enum_InternalGetValues(RuntimeType )
   at stub_System.Enum_InternalGetValues(RuntimeType , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.RuntimeType_IsEnumDefined(RuntimeType , Object )
   at stub_virt_System.Type_IsEnumDefined(Type , Object , RuntimeMethodHandle , RuntimeTypeHandle )
   at dynamic_System.Enum_IsDefined(Type , Object )
   at stub_System.Enum_IsDefined(Type , Object , RuntimeMethodHandle , RuntimeTypeHandle )
   ~~redact~~
--- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at Pose.PoseContext.Isolate(Action entryPoint, Shim[] shims)
~~redact~~