Created
September 16, 2010 21:19
-
-
Save MarkBorcherding/583190 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Supplying invalid data for a provisioning job | |
Given there is a form to collect provisioning information | |
When I consider a form to be valid | |
Then the following fields are required | |
| field | | |
| admin first name | | |
| admin last name | | |
| admin email address | | |
| url | | |
| server | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Given(@"there is a form to collect provisioning information")] | |
[When(@"I consider a form to be valid")] | |
public void nothing_to_do() {} | |
[Then(@"the following field(?:s)? (?:are|is) required")] | |
public void the_following_fields_are_required(Table table) { | |
foreach (var row in table.Rows) { | |
ModelProperty(LookupFieldName(row["field"])).ShouldBeRequired(); | |
} | |
} | |
private static string LookupFieldName(string fieldname) { | |
switch(fieldname) { | |
case "admin first name": return "AdminFirstName"; | |
case "admin last name": return "AdminLastName"; | |
case "plan name": return "PlanName"; | |
case "server" : return "Server"; | |
case "admin e-mail ": | |
case "admin email address": return "AdminEmail"; | |
case "url" : | |
case "URL" : return "Url"; | |
} | |
return fieldname; | |
} | |
private static PropertyInfo ModelProperty(string propertyName) { | |
var prop = typeof(ProvisioningViewModel).GetProperty(LookupFieldName(propertyName)) ; | |
if(prop == null) throw new ApplicationException("No model parameter of " + propertyName + " found."); | |
return prop; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment