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
0 votes
Try the below code:
    public interface IDrawView
    {
        
    }


[Test, Isolated]
public void WhatThis
{
     IDrawView   viewFake = Isolate.Fake.Instance<IDrawView>(Members.ReturnRecursiveFakes);
 Isolate.WhenCalled(() => viewFake).WillReturn(viewFake);
}


I will get the below exception:
TestCase 'IsometricAppTest.Presenter.CutPresenterTest.MouseMoveClick'
failed: System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at TypeMock.ArrangeActAssert.Recorder`1.a(T A_0)
   D:C#WorldMapIsometricAppIsometricAppTestPresenterCutPresenterTest.cs(34,0): at IsometricAppTest.Presenter.CutPresenterTest.Init()
   at TypeMock.MethodDecorator.CallRealMethod()
   at TypeMock.MethodDecorator.a()
   at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
   at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)


Although this is not a correct mock, but still, the exception return is a bit weird.
________
vapor tower vaporizer
asked by nsoonhui (59.1k points)

1 Answer

0 votes
Hi Soon Hui,

You are right (as always... :oops:), the exception is confusing and will be fixed. I think what happens here is not directly related to trying to fake the fake object, but rather because the lambda expression in WhenCalled() does not contain any call at all. This is obviously not handled properly - we will correct this and release it in an upcoming version.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
...