Hi,
I'm trying to create a mock object of a struct that has methods on it. I am not sure if this is supported by typemock, but there are cases where it might be needed. Below is a test case that reproduces the problem. Any work arounds/fixes are appreciated.
Thanks,
- Wael
Note: We are using a struct instead of a class because we want the objects to be created on the stack (instead of the heap) for performance reasons...
Unit Under Test:
public struct A
{
private long a;
private long b;
public long getA()
{
return a;
}
} // struct A
Test Code:
MockObject mockA = MockManager.MockObject(typeof(A));
Error Message:
Test method IndexedObjectUnitTest.IndexedObjectTest.GTest threw exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index.
Error Stack Trace:
at System.Collections.ArrayList.get_Item(Int32 index)
at ar.a()
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
at TypeMock.MockManager.MockObject(Type type, Object[] args)
at IndexedObjectUnitTest.IndexedObjectTest.GTest()