diff options
Diffstat (limited to 'server/test/command/set_difficulty_command_test.dart')
| -rw-r--r-- | server/test/command/set_difficulty_command_test.dart | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/server/test/command/set_difficulty_command_test.dart b/server/test/command/set_difficulty_command_test.dart new file mode 100644 index 0000000..d63571b --- /dev/null +++ b/server/test/command/set_difficulty_command_test.dart @@ -0,0 +1,35 @@ +// ignore_for_file: no-magic-number + +import 'package:test/test.dart'; +import 'package:x_haven_server/core/commands/set_difficulty_command.dart'; +import 'package:x_haven_server/core/state/game_state.dart'; +import 'package:x_haven_server/core/service_locator.dart'; + +import 'test_helpers.dart'; + +void main() { + setUpAll(() async { + await setUpGame(); + }); + + group('SetDifficultyCommand', () { + test('should set difficulty to given value', () { + final command = SetDifficultyCommand(2, gameState: getIt<GameState>()); + command.execute(); + expect(getIt<GameState>().difficulty, 2); + checkSaveState(); + }); + + test('should set difficulty to negative value', () { + final command = SetDifficultyCommand(-1, gameState: getIt<GameState>()); + command.execute(); + expect(getIt<GameState>().difficulty, -1); + checkSaveState(); + }); + + test('describe should include difficulty level', () { + final command = SetDifficultyCommand(3, gameState: getIt<GameState>()); + expect(command.describe(), 'Set difficulty level to 3'); + }); + }); +} |
