I have a unit test like so:
[Test]
public void DataIn_NoOfRowsReached_CreatesSequentialData()
{
//Assert
MyLogic logic = SetupLogic();
logic.NoOfRows = 3;
logic.DataIn(1, "1,4,7");
logic.DataIn(2, "2,5,8");
logic.DataIn(3, "3,6,9");
CollectionAssert.AreEqual(new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" }, logic.ExpectedValues);
}
Each DataIn call adds the passed in data to a separate list depending on ID (1st param). When the NoOfRows number equals the DataIn input Id it merges the data to be sequential. I then test to check this.
I now want to use test cases but I cannot see any easy way to do this without putting if statements and various optional parameters in the test method. I don’t really want to duplicate the tests for various scenarios.
The NoOfRows maximum is 6.
I believe this is what you are looking for. Leverage the params keyword to allow passing in an arbitrary amount of strings.
This just does string sorting… if you have numbers that are bigger than 9, you’ll want to add your own compare function to the Sort() method.