You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marcus Hammarberg edited this page Jan 6, 2015
·
5 revisions
For tables with several rows a dynamic set can easily be created. It will produce a List for all the rows in the table.
Say that you have the following scenario:
Scenario: Create set of dynamic objectsWhen I create a set of dynamic instances from this table
| Name | Age | Birthdate | Lengthinmeters | | Marcus | 39 | 1972-10-09 | 1.96 | | Albert | 3 | 2008-01-24 | 1.03 | | Gustav | 1 | 2010-03-19 | 0.84 | | Arvid | 1 | 2010-03-19 | 0.85 |Then the 3 item should have Age equal to '1'
Then you can use this code to create a list of dynamic objects
privateIList<dynamic>_set;// holds state between steps for this example[When(@"I create a set of dynamic instances from this table")]publicvoidx(Tabletable){varset=table.CreateDynamicSet().ToList();}
And then use the elements in the same manner as for instances created from a table (see Table to dynamic instance):
[Then(@"the (\d+) item should have Age equal to '(\d+)'")]publicvoidy(intitemNumber,intexpectedAge){Assert.AreEqual(expectedAge,_set[itemNumber-1].Age);}