REFACTOR: tests clean up
This commit is contained in:
parent
b4cdd039ae
commit
acf96ad482
1 changed files with 12 additions and 10 deletions
|
|
@ -3,23 +3,25 @@ import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Bowling Game', () {
|
group('Bowling Game', () {
|
||||||
test('gutter game - all zeros', () {
|
late BowlingGame game;
|
||||||
final game = BowlingGame();
|
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++) {
|
setUp(() {
|
||||||
game.roll(0);
|
game = BowlingGame();
|
||||||
|
});
|
||||||
|
|
||||||
|
void rollMany(int times, int pins) {
|
||||||
|
for (int i = 0; i < times; i++) {
|
||||||
|
game.roll(pins);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('gutter game - all zeros', () {
|
||||||
|
rollMany(20, 0);
|
||||||
expect(game.score(), 0);
|
expect(game.score(), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('all ones - score is 20', () {
|
test('all ones - score is 20', () {
|
||||||
final game = BowlingGame();
|
rollMany(20, 1);
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++) {
|
|
||||||
game.roll(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(game.score(), 20);
|
expect(game.score(), 20);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue