-
Notifications
You must be signed in to change notification settings - Fork 27
Conversion conventions
SpecFlow.Assist.Dynamic uses a few conventions, for conversion of Gherkin to code, that helps you keep your specification readable for non-technical team members and business users but still usable when translated to code:
When translating column names to properties spaces are removed and each new word is capitalised. The first word is left alone though. So for example:
-
Birth datetranslates toBirthDate -
Total scoreis translated toTotalScore -
ageis translated toage -
age averageis translated toageAverage
You can even use reserved chars like #$() etc in your column names. SpecFlow.Assist.Dynamic will simply take those away. Any thing that is not a-z, A-Z, 1-9 or an underscore is stripped out.
Here's some specs that show you how this works:
Scenario: Using reserved C# characters in column names
When I create a dynamic instance from this table
| C$harp n@me (with strange chars) |
| A value |
Then the CharpNmeWithStrangeChars property should equal 'A value'
Scenario: Only alpha-numeric characters, plus underscore is allowed in variable names
When I create a dynamic instance from this table
| My_Nice_Variable | My $$ Variable (needs clean up) |
| A value | Another value |
Then the My_Nice_Variable property should equal 'A value'
And the MyVariableNeedsCleanUp property should equal 'Another value'
Scenario: Using only reserved C# characters in column names
When I create a dynamic instance from this table
| $@() |
| A value |
Then an exception with a nice error message about the property only containing reserved chars should be thrownThere's some logging that shows how the conversions are made:
- converted 'Birth date' to property 'BirthDate'
- converted 'C$harp n@me (with strange chars)' to property 'CharpNmeWithStrangeChars'
SpecFlow.Assist.Dynamic will try to do a basic value conversion. Properties will be converted into DateTime, double, bool and int. It does a TryParse for each and falls back to ordinary strings if nothing fits.