My aim is to have 'nested' data in each of my unit test Iterations. I want to do this so I can have a set of Data to call upon, as well as a list of Actions (described by strings) that are then interpreted and performed in my tests. I currently have tests running in VS2013 via Test Explorer utilising non-nested data (eg. no Data/Actions sub item groups) correctly.
For example, my data could be:
<TestData>
<Iteration>
<Data>
<LoginName>admin</LoginName>
<Password>admin</Password>
</Data>
<Actions>
<Action>EnterText_LoginName</Action>
<Action>EnterText_Password</Action>
<Action>ClickButton_Login</Action>
</Actions>
</Iteration>
</TestData>
I would like to access the elements in Data as per a normal non-nested test (dataElements["element"]
), however, I would like to have the Actions elements in a list. I have tried the following with no success:
var data = TestContext.DataRow.GetChildRows("Iteration_Data");
var actions = TestContext.DataRow.GetChildRows("Iteration_Actions");
GetChildRows seems the correct method, but I am unable to see any data in the returned object that resembles my XML elements - I only get 1 DataRow
object that has an ItemArray
of 3 values (0, {}, 0). How do I retrieve a list of my Action elements so I can access the text:
- "EnterText_LoginName"
- "EnterText_Password"
- "ClickButton_Login"