0

Suppose I have a code module which accepts a variable number of DataRows:

Public sub Process(Dt As DataTable)
End Sub

I want to pass one or more test DataRows to my MbUnit test module:

Test 1:

DataRow 1: Green, 23
DataRow 2: Green, 24

Test 2:

DataRow 1: Green, 23
DataRow 2: Green, 24
DataRow 3: Blue, 44
DataRow 4: Red, 55

How would I setup an XML data file with these tests in MbUnit?

Question 2:

Suppose I want to pass meta data about the test data? For example "Color Name" or "Distance". How would I add this meta data to the XML file?

Thanks,

Ed

Yann Trevin
  • 3,823
  • 1
  • 30
  • 32
Eddy
  • 11
  • 2

1 Answers1

0

There is some documentation in the Gallio Wiki which explains how to use an XML data source for your test parameters and how to bind them with metadata. But unfortunately, the built-in XML data source attribute is not that much flexible.

I guess that the best solution is to create your own data factory. Something like this maybe:

[TestFixture]
public class MyFixture
{
  [Test, Factory("GetSampleDataTables")]
  public void MyTest(DataTable dataTable)
  {
     var foo = new Foo();
     foo.Process(dataTable);
     // Make assertions...
  }

  public static IEnumerable<object> GetSampleDataTables()
  {
    foreach (...) // Read your XML data file...
    {
      var sampleDataTable = new DataTable();
      // Populate your sample data table from XML...
      yield return sampleDataTable;
    }
  }
}
Yann Trevin
  • 3,823
  • 1
  • 30
  • 32