CallOriginal causes unarranged generic methods to fail

2 posts, 0 answers
  1. Roland Vonk
    Roland Vonk avatar
    20 posts
    Member since:
    Jan 2004

    Posted 08 Jan 2013 Link to this post

    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):
    public class JustMockFixture
        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:

    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
  2. Kaloyan
    Kaloyan avatar
    880 posts

    Posted 10 Jan 2013 Link to this post

    Hello Roland,

    Thank you for reporting this issue.

    I`m satisfied to say that, this is now fixed

    To assist you on that matter, we would suggest you to open support ticket, so that we could send you a private build.

    I hope this helps.
    All the best,
    the Telerik team
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
Back to Top