I am struggling to understand if there is something I could do or not to have unique names with xUnit and ClassData. After trying different things for hours; I now have this very small setup:
The test:
[Theory]
[ClassData(typeof(MyTestCase))]
public void FigureItOut(MyTestCase testCase)
{
Assert.Equal(7, testCase.MyProperty);
}
The MyTestCase class:
public class MyTestCase : IEnumerable<object[]>
{
public override string ToString() {
return "Hello " + MyProperty.ToString();
}
public int MyProperty { get; set; }
public IEnumerator<object[]> GetEnumerator()
{
yield return new object[]
{
new MyTestCase{ MyProperty = 7}
};
yield return new object[]
{
new MyTestCase{ MyProperty = 8}
};
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
You mentioned something about overriding ToString() on this page
http://www.ncrunch.net/d...aints_unique-test-names but in this small example that don't make any difference. Is there a way to have the two tests show up as two tests in nCrunch or is that simply not possible?
Thank you very much for any kind of reply :-)