chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi,

I've been trying to mock an event that looks like this:

public event EventHandler<SomethingEventArgs<TParam>> MyEvent.

with a line that looks like this as I want to fire the event during the test to trigger behaviour:

Isolate.WhenCalled(() => stubObject.MyEvent += null).CallOriginal();

But every time the above line is reached I get the following error message:

Test method MyTestMethod threw exception: System.IndexOutOfRangeException: Index was outside the bounds of the array..

And the stack trace:

gn.a(Type A_0, Type[] A_1, Type[] A_2)
gn.a(Type A_0, Int32 A_1, Type[] A_2, Type[] A_3)
gn.a(IList`1 A_0, Type[] A_1, Type[] A_2)
gn.a(Object A_0, MethodBase A_1, Object[] A_2)
gn.a(MethodBase A_0, Object A_1, Type A_2, Object[] A_3, Object A_4)
gn.a(MethodBase A_0, Object A_1, Object[] A_2, Object A_3)
fl.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
add_MyEvent(EventHandler`1 value)
b__1() in C:DevMyTests.cs: line 69
TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
MyTestMethod() in C:DevMyTests.cs: line 0

I've changed names to protect the innocent :)

We're still using 5.4.3 as upgrading breaks the majority of our tests which we're awaiting support on.

Thanks,
John
asked by Imaji (2.2k points)

2 Answers

0 votes
Imaji,

This is an old bug which has been fixed in version 6.0. I can confirm the performance bug which has been holding you back (according to earlier posts), and I've already tracked it down to its root cause. We'll issue a fixed version and post an update on this.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Excellent, thanks :)
answered by Imaji (2.2k points)
...