Created
September 4, 2013 07:28
-
-
Save hatelove/6433774 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
Feature: Score Calculation | |
As a player | |
I want the system to calculate my total score | |
So that I know my performance | |
Scenario: Homework scenario 1 | |
Given a new bowling game | |
When I roll the following series: 10,1,5,2,8,4,6,10,3,2,1,2,1,0,1,1,2,8,6 | |
Then my total score should be 98 | |
Scenario: Homework scenario 2 | |
Given a new bowling game | |
When I roll the following series: 10,1,5,2,8,4,6,10,3,2,1,2,1,0,1,1,10,10,6 | |
Then my total score should be 108 | |
Scenario: Homework scenario 3 - All Strikes | |
Given a new bowling game | |
When I roll the following series: 10,10,10,10,10,10,10,10,10,10,10,10 | |
Then my total score should be 300 | |
Scenario: Homework scenario 4 - All Spares | |
Given a new bowling game | |
When I roll the following series: 1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1 | |
Then my total score should be 110 | |
Scenario: Homework scenario 5 - parial record with strike | |
Given a new bowling game | |
When I roll the following series: 10,1,5 | |
Then my total score should be 22 | |
Scenario: Homework scenario 6 - 全部洗溝 | |
Given a new bowling game | |
When 全都洗溝 | |
Then my total score should be 0 | |
Scenario: Homework scenario 7 - parial record with spare | |
Given a new bowling game | |
When I roll the following series: 1,9,2,5 | |
Then my total score should be 19 |
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
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using TechTalk.SpecFlow; | |
namespace Bowling.Specflow | |
{ | |
[Binding] | |
public class BowlingSteps | |
{ | |
private Game _game; | |
[Given(@"a new bowling game")] | |
public void GivenANewBowlingGame() | |
{ | |
_game = new Game(); | |
} | |
[Then(@"my total score should be (\d+)")] | |
public void ThenMyTotalScoreShouldBe(int score) | |
{ | |
Assert.AreEqual(score, _game.Score); | |
} | |
[When(@"I roll the following series:(.*)")] | |
public void WhenIRollTheFollowingSeries(string series) | |
{ | |
foreach (var roll in series.Trim().Split(',')) | |
{ | |
_game.Roll(int.Parse(roll)); | |
} | |
} | |
[When(@"全都洗溝")] | |
public void When全都洗溝() | |
{ | |
for (int i = 0; i < 20; i++) | |
{ | |
_game.Roll(0); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment