Hi
I have an abstract object that have an ObservableCollection<T> in it. The private field set to new at declaration.
A lot of tests depend on that object.
In the TestInitialize method I construct an object using isolator and pass it Members.CallOriginal.
If I'm running all the test in sln I'm getting 5 failed tests.
If I'm running those tests they pass.
If I'm running all test in that TestClass they pass.
There is no using in global variables in those test methods.
Every test method is completely independent from other.
I've tried to debug the tests and find out that there is an exception at every call to the Fake.Instance method.
The error is:
System.ArgumentOutOfRangeException was unhandled by user code
Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source=TypeMock
ParamName=index
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at h1.b(gy A_0)
at h1.a(String A_0, gy A_1, Int32 A_2, Mock& A_3)
at h1.a(String A_0, Object A_1, Object A_2, Type& A_3, String A_4)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4)
at TypeMock.InternalMockManager.isMocked(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
at System.Collections.ObjectModel.ObservableCollection`1..ctor()
at AM5Client.Controller..ctor() in C:UsersAdielAM5ClientController.cs:line 20
at Mock0000Controller..ctor()
at TypeMock.MockManager.b(Type A_0, Object[] A_1)
at TypeMock.MockManager.a(Type A_0, Constructor A_1, Object[] A_2, Boolean A_3)
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
at TypeMock.MockManager.MockObject[TMockedType](Constructor mockConstructors)
at TypeMock.ArrangeActAssert.InstanceFaker`1.e()
at TypeMock.ArrangeActAssert.InstanceFaker`1.c()
at if.CreateFakeInstance[T](Members behavior, Constructor constructorFlag, Constructor baseConstructorFlag, Type baseType, Object[] ctorArgs)
at if.Instance[T](Members behavior)
at AM5Client.UnitTests.ControllerTest.Init() in C:UsersAdielAM5Client.UnitTestsControllerTest.cs:line 23
InnerException:
at line 20 there is:
private ObservableCollection<IReader> _readers = new ObservableCollection<IReader>();
any idea?
Thanks
Adiel