@@ -5,6 +5,9 @@ interface
5
5
DUnitX.TestFramework,
6
6
uBowling;
7
7
8
+ const
9
+ CanonicalVersion = ' 1.2.0' ;
10
+
8
11
type
9
12
10
13
[TestFixture]
@@ -13,7 +16,7 @@ BowlingTests = class(TObject)
13
16
class function RollMany (pins: array of integer; game: IBowlingGame): IBowlingGame; static;
14
17
public
15
18
[Test]
16
- // [Ignore('Comment the "[Ignore]" statement to run the test')]
19
+ // [Ignore('Comment the "[Ignore]" statement to run the test')]
17
20
procedure Should_be_able_to_score_a_game_with_all_zeros ;
18
21
19
22
[Test]
@@ -80,10 +83,26 @@ BowlingTests = class(TObject)
80
83
[Ignore]
81
84
procedure Two_rolls_in_a_frame_cannot_score_more_than_10_points ;
82
85
86
+ [Test]
87
+ [Ignore]
88
+ procedure Bonus_roll_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points ;
89
+
83
90
[Test]
84
91
[Ignore]
85
92
procedure Two_bonus_rolls_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points ;
86
93
94
+ [Test]
95
+ [Ignore]
96
+ procedure Two_bonus_rolls_after_a_strike_in_the_last_frame_can_score_more_than_10_points_if_one_is_a_strike ;
97
+
98
+ [Test]
99
+ [Ignore]
100
+ procedure The_second_bonus_rolls_after_a_strike_in_the_last_frame_cannot_be_a_strike_if_the_first_one_is_not_a_strike ;
101
+
102
+ [Test]
103
+ [Ignore]
104
+ procedure Second_bonus_roll_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points ;
105
+
87
106
[Test]
88
107
[Ignore]
89
108
procedure An_unstarted_game_cannot_be_scored ;
@@ -94,7 +113,7 @@ BowlingTests = class(TObject)
94
113
95
114
[Test]
96
115
[Ignore]
97
- procedure A_game_with_more_than_ten_frames_cannot_be_scored ;
116
+ procedure Cannot_roll_if_game_already_has_ten_frames ;
98
117
99
118
[Test]
100
119
[Ignore]
@@ -107,11 +126,26 @@ BowlingTests = class(TObject)
107
126
[Test]
108
127
[Ignore]
109
128
procedure Bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated ;
129
+
130
+ [Test]
131
+ [Ignore]
132
+ procedure Cannot_roll_after_bonus_roll_for_spare ;
133
+
134
+ [Test]
135
+ [Ignore]
136
+ procedure Cannot_roll_after_bonus_rolls_for_strike ;
110
137
end ;
111
138
112
139
implementation
113
140
uses System.SysUtils;
114
141
142
+ procedure BowlingTests.Second_bonus_roll_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points ;
143
+ var game: IBowlingGame;
144
+ begin
145
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 10 ], NewBowlingGame);
146
+ Assert.IsFalse(game.Roll(11 ));
147
+ end ;
148
+
115
149
procedure BowlingTests.Should_be_able_to_score_a_game_with_all_zeros ;
116
150
var game: IBowlingGame;
117
151
begin
@@ -231,13 +265,27 @@ procedure BowlingTests.Two_rolls_in_a_frame_cannot_score_more_than_10_points;
231
265
Assert.AreEqual(-1 , game.Score);
232
266
end ;
233
267
268
+ procedure BowlingTests.The_second_bonus_rolls_after_a_strike_in_the_last_frame_cannot_be_a_strike_if_the_first_one_is_not_a_strike ;
269
+ var game: IBowlingGame;
270
+ begin
271
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 6 ], NewBowlingGame);
272
+ Assert.IsFalse(game.Roll(10 ));
273
+ end ;
274
+
234
275
procedure BowlingTests.Two_bonus_rolls_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points ;
235
276
var game: IBowlingGame;
236
277
begin
237
278
game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 5 , 6 ], NewBowlingGame);
238
279
Assert.AreEqual(-1 , game.Score);
239
280
end ;
240
281
282
+ procedure BowlingTests.Two_bonus_rolls_after_a_strike_in_the_last_frame_can_score_more_than_10_points_if_one_is_a_strike ;
283
+ var game: IBowlingGame;
284
+ begin
285
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 10 , 6 ], NewBowlingGame);
286
+ Assert.AreEqual(26 , game.Score);
287
+ end ;
288
+
241
289
procedure BowlingTests.An_unstarted_game_cannot_be_scored ;
242
290
var game: IBowlingGame;
243
291
begin
@@ -252,11 +300,25 @@ procedure BowlingTests.An_incomplete_game_cannot_be_scored;
252
300
Assert.AreEqual(-1 , game.Score);
253
301
end ;
254
302
255
- procedure BowlingTests.A_game_with_more_than_ten_frames_cannot_be_scored ;
303
+ procedure BowlingTests.Cannot_roll_after_bonus_rolls_for_strike ;
256
304
var game: IBowlingGame;
257
305
begin
258
- game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ], NewBowlingGame);
259
- Assert.AreEqual(-1 , game.Score);
306
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 3 , 2 ], NewBowlingGame);
307
+ Assert.IsFalse(game.Roll(2 ));
308
+ end ;
309
+
310
+ procedure BowlingTests.Cannot_roll_after_bonus_roll_for_spare ;
311
+ var game: IBowlingGame;
312
+ begin
313
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 3 , 2 ], NewBowlingGame);
314
+ Assert.IsFalse(game.Roll(2 ));
315
+ end ;
316
+
317
+ procedure BowlingTests.Cannot_roll_if_game_already_has_ten_frames ;
318
+ var game: IBowlingGame;
319
+ begin
320
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ], NewBowlingGame);
321
+ Assert.IsFalse(game.Roll(0 ));
260
322
end ;
261
323
262
324
procedure BowlingTests.Bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated ;
@@ -273,6 +335,20 @@ procedure BowlingTests.Both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_r
273
335
Assert.AreEqual(-1 , game.Score);
274
336
end ;
275
337
338
+ procedure BowlingTests.Bonus_roll_after_a_strike_in_the_last_frame_cannot_score_more_than_10_points ;
339
+ var game: IBowlingGame;
340
+ begin
341
+ game := RollMany([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 ], NewBowlingGame);
342
+ Assert.IsFalse(game.Roll(11 ));
343
+ (* {
344
+ var sut = new BowlingGame();
345
+ var previousRolls = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10};
346
+ DoRoll(previousRolls, sut);
347
+ Assert.Throws<ArgumentException>(() => sut.Roll(11));
348
+ } (**)
349
+
350
+ end ;
351
+
276
352
procedure BowlingTests.Bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated ;
277
353
var game: IBowlingGame;
278
354
begin
0 commit comments