def test_game_params(self):
     game_params = {
         'messages': CliMessages(),
         'cli_input': FakeInput("7", "5"),
         'cli_output': Output(),
         'validator': Validator()
     }
     return game_params
Exemple #2
0
 def test_that_it_can_check_if_the_user_move_is_valid(self, monkeypatch, capsys):
     game_params = {
         'messages': CliMessages(),
         'cli_input': FakeInput("363", "7"),
         'cli_output': Output(),
         'validator': Validator() 
     }
     name = "foo"
     test_input_strategy = InputStrategy()
     result = test_input_strategy.get_move(name, game_params)
     assert result == "7"
Exemple #3
0
 def test_that_it_can_check_if_the_user_icon_is_invalid(
         self, test_game_config, monkeypatch, capsys):
     game_params = {
         'messages': CliMessages(),
         'cli_input': FakeInput("test", "x"),
         'cli_output': Output(),
         'validator': Validator()
     }
     game_params['cli_input'].reset_count()
     test_game_config.get_icon(game_params)
     captured = capsys.readouterr()
     assert captured.out == "\nThat was an invalid selection. Icon should be one alpha character. Please try again.\n\nYour selected icon is x\n"
Exemple #4
0
 def test_that_it_can_check_if_the_user_name_is_invalid(
         self, test_game_config, monkeypatch, capsys):
     game_params = {
         'messages': CliMessages(),
         'cli_input': FakeInput("p", "Player 1"),
         'cli_output': Output(),
         'validator': Validator()
     }
     game_params['cli_input'].reset_count()
     test_game_config.get_name(game_params)
     captured = capsys.readouterr()
     assert captured.out == "\nName should not be empty, please try again\n\nYour selected player name is Player 1\n"
Exemple #5
0
 def test_that_it_can_check_if_the_user_turn_is_invalid(
         self, test_game_config, monkeypatch, capsys):
     game_params = {
         'messages': CliMessages(),
         'cli_input': FakeInput("345", "2"),
         'cli_output': Output(),
         'validator': Validator()
     }
     game_params['cli_input'].reset_count()
     test_game_config.get_turn_order(game_params)
     captured = capsys.readouterr()
     assert captured.out == "\nThat was an invalid selection. Please enter 1 if you would like to go first or 2 if second.\n\nYour selected turn order is 2\n"
Exemple #6
0
 def test_that_it_can_check_if_the_user_move_is_invalid(self, monkeypatch, capsys):
     game_params = {
         'messages': CliMessages(),
         'cli_input': FakeInput("568", "4"),
         'cli_output': Output(),
         'validator': Validator() 
     }
     game_params['cli_input'].reset_count()
     name = "foo"
     test_input_strategy = InputStrategy()
     test_input_strategy.get_move(name, game_params)
     captured = capsys.readouterr()
     assert captured.out == "That was an invalid move, please try again. Please select a move between 1 - 9:\nfoo selects square 4. Placing foo's move.\n"
Exemple #7
0
    def test_that_best_move_returns_a_move(self):
        game_params = {
            'messages': CliMessages(),
            'cli_input': FakeInput("363", "7"),
            'cli_output': Output(),
            'validator': Validator() 
        }
        board = Board()
        rules = Rules(board)
        game = Game(board, rules)
        
        human_player = Player("Player 1", "x", "foo")
        computer_player = Player("Computer", "o", "foo")
        game.add_player(human_player)
        game.add_player(computer_player)
        game.set_current_player(computer_player)

        test_input_strategy = InputStrategy()
        assert test_input_strategy.best_move(game, game_params) == "7"