This is a migrated thread and some comments may be shown as answers.

CallOriginal causes unarranged generic methods to fail

1 Answer 20 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Roland Vonk
Top achievements
Rank 1
Roland Vonk asked on 08 Jan 2013, 04:01 PM
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
{
    [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

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 10 Jan 2013, 09:04 AM
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,
Kaloyan
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.
Tags
General Discussions
Asked by
Roland Vonk
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or