Hi,
I'm getting the following exception using TypeMock 3.7.1 and .Net 2.0 when I try to use natural mocks with my code which uses generics:
Test method TestProject1.MyClassTest.method1Test threw exception: System.Reflection.AmbiguousMatchException: Ambiguous match found..
Here's a small testcase to reproduce it. The code being tested is:
public interface intC<T>
{
void blah(T myInt);
}
public class classB<T>
{
public intC<T> Selected(IEnumerable foo)
{
return null;
}
public intC<T> Selected(intC<T> bar)
{
return null;
}
}
public class classA<T>
{
public classB<T> B
{
get
{
return null;
}
}
}
public class MyClass
{
public static void method1()
{
classA<int> a = new classA<int>();
a.B.Selected((IEnumerable) null).blah(4);
}
}
And here is the unit test code:
[TestMethod()]
public void method1Test()
{
classA<int> a = new classA<int>();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
a.B.Selected((IEnumerable) null).blah(4);
}
MyClass.method1();
}
Also, if you change classA to be static you then get a NullReferenceException from TypeMock when creating the natural mock. That might actually be a different bug.