I found that TypeMock is not able to verify arguments when my static method returns ReadOnlyCollection. When I change the type to List verification succeed.
Example:
Isolate.WhenCalled(() => FileLoader.GetFiles(null, null)).WillReturn(files);
ReadOnlyCollection<String> files = FileLoader.GetFiles("C:Temp", "*.dll");
Isolate.Verify.WasCalledWithExactArguments(() => FileLoader.GetFiles("C:Temp", "*.dll"));
If the FileLoader.GetFiles() returns
ReadOnlyCollection<String> I will get the error saying
"System.ArgumentNullException: Value cannot be null.
Parameter name: list
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.ObjectModel.ReadOnlyCollection`1..ctor(IList`1 list)
at b2.a(Object A_0, MethodBase A_1, Object A_2, Boolean A_3)
at f7.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
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, Object p1, Object p2)
at FileLoader.GetFiles(String path, String searchPattern) in FileLoader.cs: line 36"
but when it returns
List<String> it works.
I'm using TypeMock version 5.4.2.0