Since the 2012 Q3 release of JustMock, generic methods called on mocks created with CallOriginal fail if they are not arranged.
Here's a test to prove the failure (using xUnit):
The exception is as follows:
System.NotSupportedException
Cannot create arrays of TypedReference, ArgIterator, ByRef, or RuntimeArgumentHandle Objects.
at System.Array.InternalCreate(Void* elementType, Int32 rank, Int32* pLengths, Int32* pLowerBounds)
at System.Array.CreateInstance(Type elementType, Int32 length)
at Telerik.JustMock.Utility.GetDefaultValue(Type target)
at Telerik.JustMock.Weaver.WeaverInvocation.SetReturn(Object value)
at TestClass_Interceptor_cdc31f27c78a442fbc59c6faf3dfdb68.Intercept<T>(String[], TestClass, ref Boolean)
at JustMockFail.TestClass.Load(String[] ids) in TestClass.cs: line 15
at JustMockFail.JustMockFixture.CallOriginal_UnmockedMethod_ThrowsException() in JustMockFixture.cs: line 15
Here's a test to prove the failure (using xUnit):
public class JustMockFixture{ [Fact] public void CallOriginal_UnmockedGenericMethod_CallOriginalMock_ThrowsException() { var obj = Mock.Create<TestClass>(Behavior.CallOriginal); Should.NotThrow(() => obj.Load<string>(new[] { "1", "2", "3" })); }}internal class TestClass{ public T[] Load<T>(string[] ids) { throw new NotImplementedException(); }}The exception is as follows:
System.NotSupportedException
Cannot create arrays of TypedReference, ArgIterator, ByRef, or RuntimeArgumentHandle Objects.
at System.Array.InternalCreate(Void* elementType, Int32 rank, Int32* pLengths, Int32* pLowerBounds)
at System.Array.CreateInstance(Type elementType, Int32 length)
at Telerik.JustMock.Utility.GetDefaultValue(Type target)
at Telerik.JustMock.Weaver.WeaverInvocation.SetReturn(Object value)
at TestClass_Interceptor_cdc31f27c78a442fbc59c6faf3dfdb68.Intercept<T>(String[], TestClass, ref Boolean)
at JustMockFail.TestClass.Load(String[] ids) in TestClass.cs: line 15
at JustMockFail.JustMockFixture.CallOriginal_UnmockedMethod_ThrowsException() in JustMockFixture.cs: line 15
