示例#1
0
    def test_getting_input(self):
        chosen_in = StringIO("hello\n")
        chosen_out = StringIO()
        io = InputOutput(chosen_in, chosen_out)
        given_input = io.get_input()

        self.assertEqual(given_input, "hello\n")
示例#2
0
    def test_getting_input(self):
        chosen_in = StringIO("hello\n")
        chosen_out = StringIO()
        io = InputOutput(chosen_in, chosen_out)
        given_input = io.get_input()

        self.assertEqual(given_input, "hello\n")
示例#3
0
    def test_printing(self):
        chosen_in = StringIO()
        chosen_out = StringIO()
        io = InputOutput(chosen_in, chosen_out)
        io.present("hello world")
        output = chosen_out.getvalue()

        self.assertEqual(output, "hello world\n")
示例#4
0
    def test_printing(self):
        chosen_in = StringIO()
        chosen_out = StringIO()
        io = InputOutput(chosen_in, chosen_out)
        io.present("hello world")
        output = chosen_out.getvalue()

        self.assertEqual(output, "hello world\n")
示例#5
0
    def test_game_is_created_with_correct_players(self):
        io = InputOutput(StringIO(), StringIO())
        game_loop = GameLoop(io)
        game_loop.create_game(self.player1, self.player2)

        self.assertEqual(self.player1, game_loop.game.player1)
        self.assertEqual(self.player2, game_loop.game.player2)
示例#6
0
 def setUp(self):
     self.chosen_out = StringIO()
     self.io = InputOutput(StringIO, self.chosen_out)
示例#7
0
 def setUp(self):
     self.chosen_output = StringIO()
     self.io = InputOutput(None, self.chosen_output)
     self.presenter = Presenter(self.io)
示例#8
0
 def test_evaluting_no_response_to_play_again_prompt(self):
     io = InputOutput(StringIO("c\nc\nno\n"), StringIO())
     game_loop = GameLoop(io)
     game_loop.create_game(self.player1, self.player2)
     self.assertFalse(game_loop.play_again())
示例#9
0
    def test_game_is_created_with_proper_player_types(self):
        io = InputOutput(StringIO("human\ncomputer"), StringIO())
        game_loop = GameLoop(io)

        self.assertTrue(isinstance(game_loop.game.player1, Human))
        self.assertTrue(isinstance(game_loop.game.player2, Computer))