Last active
August 29, 2015 14:07
-
-
Save joebuschmann/76c20ca025b6f3bd469c to your computer and use it in GitHub Desktop.
Implementation of Specflow's default calculator feature using private members to maintain state
This file contains 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
[Binding] | |
public class CalculatorSteps | |
{ | |
private readonly List<int> _values = new List<int>(); | |
private int _result; | |
[Given(@"I have entered (.*) into the calculator")] | |
public void GivenIHaveEnteredIntoTheCalculator(int num) | |
{ | |
_values.Add(num); | |
} | |
[When(@"I press add")] | |
public void WhenIPressAdd() | |
{ | |
var calculatorService = new CalculatorService(); | |
_result = calculatorService.Add(_values); | |
} | |
[Then(@"the result should be (.*) on the screen")] | |
public void ThenTheResultShouldBeOnTheScreen(int expectedResult) | |
{ | |
Assert.That(_result, Is.EqualTo(expectedResult)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment