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
public class CalculatorService | |
{ | |
public int Add(IEnumerable<int> numbers) | |
{ | |
return numbers.Sum(); | |
} | |
} |
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
public static void CompareToInstance<T>(this Table table, T instance) | |
{ | |
AssertThatTheInstanceExists(instance); | |
var instanceTable = TEHelpers.GetTheProperInstanceTable(table, typeof(T)); | |
var differences = FindAnyDifferences(instanceTable, instance); | |
if (ThereAreAnyDifferences(differences)) | |
ThrowAnExceptionThatDescribesThoseDifferences(differences); |
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
public static void CompareToInstance(this Table table, object instance) | |
{ | |
AssertThatTheInstanceExists(instance); | |
var instanceTable = TEHelpers.GetTheProperInstanceTable(table, instance.GetType()); | |
var differences = FindAnyDifferences(instanceTable, instance); | |
if (ThereAreAnyDifferences(differences)) | |
ThrowAnExceptionThatDescribesThoseDifferences(differences); |
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: Limit argument options to enum values | |
Given the following devices | |
| Product Name | | |
| Galaxy IV | | |
| iPhone | | |
| Windows Phone | | |
| Note | | |
| Kindle | | |
When I sort by product name ascending | |
Then they should be in the following order |
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
[When(@"I sort by product name (ascending|descending)")] | |
public void WhenISortByProductName(SortOrder sortOrder) | |
{ | |
_products.Sort((s1, s2) => | |
{ | |
if (sortOrder == SortOrder.Descending) | |
return s1.ProductName.CompareTo(s2.ProductName) * (-1); | |
return s1.ProductName.CompareTo(s2.ProductName); | |
}); |
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
[StepArgumentTransformation(@"from (A-Z|Z-A)")] | |
public SortOrder SortOrderTransform(string sortOrderPhrase) | |
{ | |
if (sortOrderPhrase == "Z-A") | |
return SortOrder.Descending; | |
return SortOrder.Ascending; | |
} | |
[When(@"I sort by product name (.*)")] |
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: Convert 1st, 2nd, etc to integral values | |
Given the following devices | |
| Product Name | | |
| Galaxy IV | | |
| iPhone | | |
| Windows Phone | | |
| Note | | |
| Kindle | | |
| Blackberry Storm | | |
| iPad | |
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
[When(@"I remove the (\d+)(?:st|nd|rd|th) item")] | |
public void WhenIRemoveTheItem(int index) | |
{ | |
_products.RemoveAt(--index); | |
} |
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: Support singular and plural wording | |
Given the following devices | |
| Product Name | | |
| Galaxy IV | | |
| iPhone | | |
And the following device | |
| Product Name | | |
| Windows Phone | |
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(@"the following devices?")] | |
public void GivenTheFollowingDevices(Table table) | |
{ | |
_products = table.CreateSet<Product>().ToList(); | |
} |