I think I'm running into this same issue, and I have a little additional information that might help track it down. In my case at least, this appears to be related to lambda and linq expressions combined with a static method.
My code and errors are at the bottom. Notice that the non-static calls all work with Isolate.NonPublic with and without Linq (tests 1-3). Test 4 also works (static without linq/lambda). Tests 5 and 6 both fail with a very similar error message to the original post.
I'm using Isolator 5.4.5, VS2008 and the VS Unit Testing framework.
Code:
public class Processing
{
public void BeginWithLinq()
{
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int[] subset = (from int i in numbers
where i <5> n % 2 == 1);
More();
}
public void BeginWithoutLinq()
{
More();
}
private void More()
{}
}
public static class ProcessingStatic
{
public static void BeginWithLinq()
{
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int[] subset = (from int i in numbers
where i <5> n % 2 == 1);
More();
}
public static void BeginWithoutLinq()
{
More();
}
private static void More()
{}
}
[TestMethod]
public void TestMethod1()
{
Processing p = Isolate.Fake.Instance<Processing>();
Isolate.NonPublic.WhenCalled(p, "More").IgnoreCall();
p.BeginWithLinq();
}
[TestMethod]
public void TestMethod2()
{
Processing p = Isolate.Fake.Instance<Processing>();
Isolate.NonPublic.WhenCalled(p, "More").IgnoreCall();
p.BeginWithoutLinq();
}
[TestMethod]
public void TestMethod3()
{
Processing p = Isolate.Fake.Instance<Processing>();
Isolate.NonPublic.WhenCalled(p, "More").IgnoreCall();
p.BeginWithLambda();
}
[TestMethod]
public void TestMethod4()
{
Isolate.NonPublic.WhenCalled(typeof(ProcessingStatic), "More").IgnoreCall();
ProcessingStatic.BeginWithoutLinq();
}
[TestMethod]
public void TestMethod5()
{
Isolate.NonPublic.WhenCalled(typeof(ProcessingStatic), "More").IgnoreCall();
ProcessingStatic.BeginWithLinq();
}
[TestMethod]
public void TestMethod6()
{
Isolate.NonPublic.WhenCalled(typeof(ProcessingStatic), "More").IgnoreCall();
ProcessingStatic.BeginWithLambda();
}
TestMethod5 Results:
Test method TypeMockReproTest.UnitTest1.TestMethod5 threw exception: TypeMock.TypeMockException:
*** No method with name <BeginWithLinq in type TypeMockRepro.ProcessingStatic exists..
TestMethod5 Stack Trace:
at cn.b(Type A_0, String A_1)
at cn.c(Type A_0, String A_1)
at ce.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
at c8.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, ce A_6)
at c8.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMockRepro.ProcessingStatic.<BeginWithLinq>b__0(Int32 i) in C:ViperSPCRSrcUnit TestsTypeMockReproClass1.cs:line 49
at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at TypeMockRepro.ProcessingStatic.BeginWithLinq() in C:ViperSPCRSrcUnit TestsTypeMockReproClass1.cs:line 48
at TypeMockReproTest.UnitTest1.TestMethod5() in C:ViperSPCRSrcUnit TestsTypeMockReproTestUnitTest1.cs:line 103
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)
at TypeMockReproTest.UnitTest1.TestMethod5() in C:ViperSPCRSrcUnit TestsTypeMockReproTestUnitTest1.cs:line 101
TestMethod6 Results:
Test method TypeMockReproTest.UnitTest1.TestMethod6 threw exception: TypeMock.TypeMockException:
*** No method with name <BeginWithLambda in type TypeMockRepro.ProcessingStatic exists..
TestMethod6 StackTrace:
at cn.b(Type A_0, String A_1)
at cn.c(Type A_0, String A_1)
at ce.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
at c8.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, ce A_6)
at c8.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMockRepro.ProcessingStatic.<BeginWithLambda>b__2(Int32 n) in C:ViperSPCRSrcUnit TestsTypeMockReproClass1.cs:line 60
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source, Func`2 predicate)
at TypeMockRepro.ProcessingStatic.BeginWithLambda() in C:ViperSPCRSrcUnit TestsTypeMockReproClass1.cs:line 60
at TypeMockReproTest.UnitTest1.TestMethod6() in C:ViperSPCRSrcUnit TestsTypeMockReproTestUnitTest1.cs:line 111
at TypeMock.MockManager.a(String A_0, String A_1, Obj