Hi,
The 5.3.0 release almost got generics right. I've found one bug that is triggered in case expectation is set multiple times on the same method. Here's the code:
public static class DataHelper
{
public static LT Fill<T>()
where LT : ICollection<T>, new()
{
return new LT();
}
}
[Test]
public void Test_Succeeds()
{
var fakeStrings = new List<string>();
fakeStrings.Add("abc");
Isolate.WhenCalled(() => DataHelper.Fill<string, List<string>>()).WillReturn(fakeStrings);
var strings = DataHelper.Fill<string, List<string>>();
Assert.IsNotNull(strings);
Assert.AreNotEqual(0, strings.Count);
}
[Test]
public void Test_Fails()
{
var fakeStrings = new List<string>();
fakeStrings.Add("abc");
Isolate.WhenCalled(() => DataHelper.Fill<string, List<string>>()).WillReturn(fakeStrings);
Isolate.WhenCalled(() => DataHelper.Fill<string, List<string>>()).WillReturn(fakeStrings);
var strings = DataHelper.Fill<string, List<string>>();
Assert.IsNotNull(strings);
Assert.AreNotEqual(0, strings.Count);
}
As you can see, the only difference between the successful and failed test is that DataHelper.Fill is faked twice in failed test. But this breaks the list that it returns: the return value is an empty list instead of a list containing string "abc".