-
Notifications
You must be signed in to change notification settings - Fork 763
Description
Currently the deduction of type arguments in NUnit is somewhat limited.
For example the following will work:
public static ITestCaseData[] TestCasesForEqualitiy =
{
new TestCaseData(1, 1).Returns(true),
new TestCaseData(1, 2).Returns(false),
};
[Test]
[TestCaseSource("TestCasesForEqualitiy")]
public bool Equality<TElement>(TElement left, TElement right)
{
return left.Equals(right);
}While the following won't work:
public static ITestCaseData[] TestCasesForEqualitiy =
{
new TestCaseData(1, 1).Returns(true),
new TestCaseData(1, 2).Returns(false),
};
[Test]
[TestCaseSource("TestCasesForEqualitiy")]
public bool Equality<TElement>(TElement? left, TElement? right)
{
return left.Equals(right);
}As far as I can see the modification would be local to NUnit.Framework.Internal.Builders.NUnitTestCaseBuilder.GetTypeArgumentsForMethod(...).
I have coded a somewhat complex type inference logic for another project. I'll check into it and will happily supply it to NUnit project.
Reactions are currently unavailable