|
|
@ -10,13 +10,15 @@ void main() {
|
|
|
|
GameState(
|
|
|
|
GameState(
|
|
|
|
score: 0,
|
|
|
|
score: 0,
|
|
|
|
balls: 0,
|
|
|
|
balls: 0,
|
|
|
|
bonusLetters: const [],
|
|
|
|
activatedBonusLetters: const [],
|
|
|
|
|
|
|
|
bonusHistory: const [],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
equals(
|
|
|
|
equals(
|
|
|
|
const GameState(
|
|
|
|
const GameState(
|
|
|
|
score: 0,
|
|
|
|
score: 0,
|
|
|
|
balls: 0,
|
|
|
|
balls: 0,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -25,7 +27,12 @@ void main() {
|
|
|
|
group('constructor', () {
|
|
|
|
group('constructor', () {
|
|
|
|
test('can be instantiated', () {
|
|
|
|
test('can be instantiated', () {
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
const GameState(score: 0, balls: 0, bonusLetters: []),
|
|
|
|
const GameState(
|
|
|
|
|
|
|
|
score: 0,
|
|
|
|
|
|
|
|
balls: 0,
|
|
|
|
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
|
|
|
|
),
|
|
|
|
isNotNull,
|
|
|
|
isNotNull,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -36,7 +43,12 @@ void main() {
|
|
|
|
'when balls are negative',
|
|
|
|
'when balls are negative',
|
|
|
|
() {
|
|
|
|
() {
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
() => GameState(balls: -1, score: 0, bonusLetters: const []),
|
|
|
|
() => GameState(
|
|
|
|
|
|
|
|
balls: -1,
|
|
|
|
|
|
|
|
score: 0,
|
|
|
|
|
|
|
|
activatedBonusLetters: const [],
|
|
|
|
|
|
|
|
bonusHistory: const [],
|
|
|
|
|
|
|
|
),
|
|
|
|
throwsAssertionError,
|
|
|
|
throwsAssertionError,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -47,7 +59,12 @@ void main() {
|
|
|
|
'when score is negative',
|
|
|
|
'when score is negative',
|
|
|
|
() {
|
|
|
|
() {
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
() => GameState(balls: 0, score: -1, bonusLetters: const []),
|
|
|
|
() => GameState(
|
|
|
|
|
|
|
|
balls: 0,
|
|
|
|
|
|
|
|
score: -1,
|
|
|
|
|
|
|
|
activatedBonusLetters: const [],
|
|
|
|
|
|
|
|
bonusHistory: const [],
|
|
|
|
|
|
|
|
),
|
|
|
|
throwsAssertionError,
|
|
|
|
throwsAssertionError,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -60,7 +77,8 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
balls: 0,
|
|
|
|
balls: 0,
|
|
|
|
score: 0,
|
|
|
|
score: 0,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(gameState.isGameOver, isTrue);
|
|
|
|
expect(gameState.isGameOver, isTrue);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -71,7 +89,8 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
balls: 1,
|
|
|
|
balls: 1,
|
|
|
|
score: 0,
|
|
|
|
score: 0,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(gameState.isGameOver, isFalse);
|
|
|
|
expect(gameState.isGameOver, isFalse);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -85,7 +104,8 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
balls: 1,
|
|
|
|
balls: 1,
|
|
|
|
score: 0,
|
|
|
|
score: 0,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(gameState.isLastBall, isTrue);
|
|
|
|
expect(gameState.isLastBall, isTrue);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -98,7 +118,8 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
balls: 2,
|
|
|
|
balls: 2,
|
|
|
|
score: 0,
|
|
|
|
score: 0,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(gameState.isLastBall, isFalse);
|
|
|
|
expect(gameState.isLastBall, isFalse);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -113,7 +134,8 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
balls: 0,
|
|
|
|
balls: 0,
|
|
|
|
score: 2,
|
|
|
|
score: 2,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
() => gameState.copyWith(score: gameState.score - 1),
|
|
|
|
() => gameState.copyWith(score: gameState.score - 1),
|
|
|
@ -129,7 +151,8 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
balls: 0,
|
|
|
|
balls: 0,
|
|
|
|
score: 2,
|
|
|
|
score: 2,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
expect(
|
|
|
|
gameState.copyWith(),
|
|
|
|
gameState.copyWith(),
|
|
|
@ -145,12 +168,14 @@ void main() {
|
|
|
|
const gameState = GameState(
|
|
|
|
const gameState = GameState(
|
|
|
|
score: 2,
|
|
|
|
score: 2,
|
|
|
|
balls: 0,
|
|
|
|
balls: 0,
|
|
|
|
bonusLetters: [],
|
|
|
|
activatedBonusLetters: [],
|
|
|
|
|
|
|
|
bonusHistory: [],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
final otherGameState = GameState(
|
|
|
|
final otherGameState = GameState(
|
|
|
|
score: gameState.score + 1,
|
|
|
|
score: gameState.score + 1,
|
|
|
|
balls: gameState.balls + 1,
|
|
|
|
balls: gameState.balls + 1,
|
|
|
|
bonusLetters: const ['A'],
|
|
|
|
activatedBonusLetters: const [0],
|
|
|
|
|
|
|
|
bonusHistory: const [GameBonus.word],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
expect(gameState, isNot(equals(otherGameState)));
|
|
|
|
expect(gameState, isNot(equals(otherGameState)));
|
|
|
|
|
|
|
|
|
|
|
@ -158,7 +183,8 @@ void main() {
|
|
|
|
gameState.copyWith(
|
|
|
|
gameState.copyWith(
|
|
|
|
score: otherGameState.score,
|
|
|
|
score: otherGameState.score,
|
|
|
|
balls: otherGameState.balls,
|
|
|
|
balls: otherGameState.balls,
|
|
|
|
bonusLetters: otherGameState.bonusLetters,
|
|
|
|
activatedBonusLetters: otherGameState.activatedBonusLetters,
|
|
|
|
|
|
|
|
bonusHistory: otherGameState.bonusHistory,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
equals(otherGameState),
|
|
|
|
equals(otherGameState),
|
|
|
|
);
|
|
|
|
);
|
|
|
|