def test_a_game_should_be_saved(self): settings_manager = SettingsManager('mySettings.xml') settings_manager.load() game = Game() game.set_settings_manager(settings_manager) game.initial_sudoku = SudokuBoard() game.initial_sudoku.from_dictionary(self.puzzle, True) game.start_game_timer() save_game_command = SaveGameCommand(self.valid_params) save_game_command.set_game(game) save_game_command.execute() game_file = open('game.sgf', 'rb') read_game = pickle.load(game_file) self.assertEqual(game.initial_sudoku.to_dictionary(), read_game.initial_sudoku.to_dictionary())
def test_a_game_should_be_opened(self): settings_manager = SettingsManager('mySettings.xml') settings_manager.load() game = Game() game.set_settings_manager(settings_manager) game.initial_sudoku = SudokuBoard() game.initial_sudoku.from_dictionary(self.puzzle, True) game.start_game_timer() save_game_command = SaveGameCommand(self.valid_params) save_game_command.set_game(game) save_game_command.execute() other_game = Game() other_game.set_settings_manager(settings_manager) other_game.start_game_timer() open_game_command = OpenGameCommand(self.valid_params) open_game_command.set_game(other_game) open_game_command.execute() self.assertEqual(game.initial_sudoku.to_dictionary(), other_game.initial_sudoku.to_dictionary())
def test_an_InvalidCmdParametersException_should_be_raised_if_game_is_None(self): with self.assertRaises(InvalidCmdParametersException): cmd = SaveGameCommand(self.valid_params) cmd.execute()