I would be grateful for assistance with the following question. I would like to evaluate one or more data series with Xunit. For this I have programmed a simple example. Read the data series 10,20,30,40,80 and add 1 with a working method testAddValue.
public class TestDataRow
{
[Theory]
[MemberData(nameof(DataRowValue))]
[MemberData(nameof(ExpectedDataRowValue))]
public void TestDataRow_Method(List<int> TestValue, List<int> ExpectedValue)
{
// Init Method
Method testAddValue = new Method();
// Loop
for (int i = 0; i < TestValue.Count; i++)
{
var actual = testAddValue.TestDataRow_AddValue(TestValue[i], 1);
Assert.Equal(TestValue[i], ExpectedValue[i]);
}
}
public static IEnumerable<object[]> DataRowValue()
{
var testRow = new List<List<int>>
{
// TestValue
new List<int>{ 10, 20, 30, 40, 80},
};
yield return new object[] { testRow };
}
public static IEnumerable<object[]> ExpectedDataRowValue()
{
var expectedtestRow = new List<List<int>>
{
// ExpectedValue
new List<int>{ 11, 21, 31, 41, 81},
};
yield return new object[] { expectedtestRow };
}
}
The compiler gives no error message.
When I run the test with TestDataRow_Method(List TestValue), I get the message:
Object of type 'System.Collections.Generic.List1[System.Collections.Generic.List1[System.Int32]]' cannot be converted to type 'System.Collections.Generic.List`1[System.Int32]'.
I don't understand this error message....
When I run the test with TestDataRow_Method(List TestValue, List ExpectedValue), I get the message that ExpectedValue is not present. This is surely a consequential error that should be taken care of by solving the above problem. For a better understanding of my approach, I am posting the full code.
What am I doing wrong?