Hello,
I have an exception when I mock a static class (with TypeMock 7.1.1 and VS 2012 RTM) like this:
var spListItem = Isolate.Fake.Instance<SPListItem>();
Isolate.Fake.StaticMethods<A>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => A.Method("1", "2"))
.WithExactArguments()
.WillReturnCollectionValuesOf(new[] { spListItem });
or like this
var spListItem = Isolate.Fake.Instance<SPListItem>();
Isolate.Fake.StaticMethods<A>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled((string s1, string s2) => A.Method(s1, s2))
.AndArgumentsMatch((s1, s2) => s1.Equals("1") && s2.Equals("2"))
.WillReturnCollectionValuesOf(new[] { spListItem });
The static class is:
public class A
{
public static SPListItemCollection Method(string string1, string string2)
{
return null;
}
}
When running the code, I get this exception:
TypeMock.TypeMockException
*** Can not fake methods defined in mscorlib, try faking the defining type
à ik.b(Object A_0)
à ik.d(Object A_0)
à TypeMock.ArrangeActAssert.ExpectationEngine`1.<>c__DisplayClass22.b()
à ik.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5, Boolean A_6)
à TypeMock.ArrangeActAssert.ExpectationEngine`1.a(IEnumerable A_0)