diff options
Diffstat (limited to 'server/test/command/amd_add_minus_one_command_test.dart')
| -rw-r--r-- | server/test/command/amd_add_minus_one_command_test.dart | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/server/test/command/amd_add_minus_one_command_test.dart b/server/test/command/amd_add_minus_one_command_test.dart new file mode 100644 index 0000000..4a354c8 --- /dev/null +++ b/server/test/command/amd_add_minus_one_command_test.dart @@ -0,0 +1,116 @@ +// ignore_for_file: avoid-late-keyword + +import 'package:test/test.dart'; +import 'package:x_haven_server/core/commands/add_character_command.dart'; +import 'package:x_haven_server/core/commands/amd_add_minus_one_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(); + }); + + late Character character; + + setUp(() { + getIt<GameState>().clearList(); + AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); + character = + getIt<GameState>().currentList.firstWhere((e) => e is Character) + as Character; + }); + + group('AmdAddMinusOneCommand', () { + test('should add a minus one card to a character deck', () { + // Arrange + final command = AmdAddMinusOneCommand( + character.id, + gameState: getIt<GameState>(), + ); + final modifierDeck = character.characterState.modifierDeck; + int initialCount = 0; + modifierDeck.drawPileContents.toList().forEach((element) { + if (element.gfx == 'minus1') { + initialCount++; + } + }); + + // Act + command.execute(); + + // Assert + int finalCount = 0; + modifierDeck.drawPileContents.toList().forEach((element) { + if (element.gfx == 'minus1') { + finalCount++; + } + }); + expect(finalCount, initialCount + 1); + }); + + test('should add a minus one card to the monster deck', () { + // Arrange + final command = AmdAddMinusOneCommand('', gameState: getIt<GameState>()); + final modifierDeck = getIt<GameState>().modifierDeck; + int initialCount = 0; + modifierDeck.drawPileContents.toList().forEach((element) { + if (element.gfx == 'minus1') { + initialCount++; + } + }); + + // Act + command.execute(); + + // Assert + int finalCount = 0; + modifierDeck.drawPileContents.toList().forEach((element) { + if (element.gfx == 'minus1') { + finalCount++; + } + }); + expect(finalCount, initialCount + 1); + }); + + test('should add a minus one card to the allies deck', () { + // Arrange + final command = AmdAddMinusOneCommand( + 'allies', + gameState: getIt<GameState>(), + ); + final modifierDeck = getIt<GameState>().modifierDeckAllies; + int initialCount = 0; + modifierDeck.drawPileContents.toList().forEach((element) { + if (element.gfx == 'minus1') { + initialCount++; + } + }); + + // Act + command.execute(); + + // Assert + int finalCount = 0; + modifierDeck.drawPileContents.toList().forEach((element) { + if (element.gfx == 'minus1') { + finalCount++; + } + }); + expect(finalCount, initialCount + 1); + }); + + test('describe should return correct string', () { + // Arrange + final command = AmdAddMinusOneCommand( + 'Blinkblade', + gameState: getIt<GameState>(), + ); + + // Act & Assert + expect(command.describe(), 'Add minus one'); + }); + }); +} |
