예제 #1
0
	def test_start_game_action_is_not_legal_for_less_then_three_players(self):
		for i in range(0,3):
			game = Game()
			for n in range(0,i):
				game.create_player('Player %d' % n)
			with self.assertRaises(IllegalActionException):
				self.action.assert_legal(game)
예제 #2
0
 def test_start_game_action_is_not_legal_for_less_then_three_players(self):
     for i in range(0, 3):
         game = Game()
         for n in range(0, i):
             game.create_player('Player %d' % n)
         with self.assertRaises(IllegalActionException):
             self.action.assert_legal(game)
예제 #3
0
	def test_existing_player_is_enforced(self):
		game = Game()
		pa = PlayerAction('red')
		with self.assertRaises(IllegalActionException):
			pa.assert_legal(game)
		game.create_player('redPlayer', 'red')
		pa.assert_legal(game)
예제 #4
0
 def test_existing_player_is_enforced(self):
     game = Game()
     pa = PlayerAction('red')
     with self.assertRaises(IllegalActionException):
         pa.assert_legal(game)
     game.create_player('redPlayer', 'red')
     pa.assert_legal(game)
예제 #5
0
class TestPlayerAction(unittest.TestCase, TestPlayerActionMixin):
	def setUp(self):
		self.game = Game()
		self.game.create_player('bluePlayer', 'blue')
		self.action = PlayerAction('blue')

	def test_constructor_sets_player(self):
		pa = PlayerAction('red')
		self.assertEqual(pa.player, 'red')

	def test_existing_player_is_enforced(self):
		game = Game()
		pa = PlayerAction('red')
		with self.assertRaises(IllegalActionException):
			pa.assert_legal(game)
		game.create_player('redPlayer', 'red')
		pa.assert_legal(game)
예제 #6
0
class TestPlayerAction(unittest.TestCase, TestPlayerActionMixin):
    def setUp(self):
        self.game = Game()
        self.game.create_player('bluePlayer', 'blue')
        self.action = PlayerAction('blue')

    def test_constructor_sets_player(self):
        pa = PlayerAction('red')
        self.assertEqual(pa.player, 'red')

    def test_existing_player_is_enforced(self):
        game = Game()
        pa = PlayerAction('red')
        with self.assertRaises(IllegalActionException):
            pa.assert_legal(game)
        game.create_player('redPlayer', 'red')
        pa.assert_legal(game)
예제 #7
0
class TestStartGameAction(unittest.TestCase, TestPlayerActionMixin):
	def setUp(self):
		self.game = Game()
		self.game.create_player('playerOne', 'red')
		self.game.create_player('playerTwo')
		self.game.create_player('playerThree')
		self.action = StartGameAction('red')

	def test_start_game_action_initializes_board(self):
		self.action.apply_unchecked(self.game)
		self.assertIsNotNone(self.game.board)

	def test_start_game_action_starts_game(self):
		self.action.apply_unchecked(self.game)
		self.assertEqual('setup', self.game.phase)

	def test_start_game_action_assert_legal_on_init(self):
		self.action.assert_legal(self.game)
		self.action.apply_unchecked(self.game)
		with self.assertRaises(IllegalActionException):
			self.action.assert_legal(self.game)

	def test_start_game_sets_up_turn_order(self):
		self.assertIsNone(self.game.turn_order)
		self.action.apply_unchecked(self.game)
		self.assertIsNotNone(self.game.turn_order)

	def test_start_game_action_is_not_legal_for_less_then_three_players(self):
		for i in range(0,3):
			game = Game()
			for n in range(0,i):
				game.create_player('Player %d' % n)
			with self.assertRaises(IllegalActionException):
				self.action.assert_legal(game)
예제 #8
0
class TestStartGameAction(unittest.TestCase, TestPlayerActionMixin):
    def setUp(self):
        self.game = Game()
        self.game.create_player('playerOne', 'red')
        self.game.create_player('playerTwo')
        self.game.create_player('playerThree')
        self.action = StartGameAction('red')

    def test_start_game_action_initializes_board(self):
        self.action.apply_unchecked(self.game)
        self.assertIsNotNone(self.game.board)

    def test_start_game_action_starts_game(self):
        self.action.apply_unchecked(self.game)
        self.assertEqual('setup', self.game.phase)

    def test_start_game_action_assert_legal_on_init(self):
        self.action.assert_legal(self.game)
        self.action.apply_unchecked(self.game)
        with self.assertRaises(IllegalActionException):
            self.action.assert_legal(self.game)

    def test_start_game_sets_up_turn_order(self):
        self.assertIsNone(self.game.turn_order)
        self.action.apply_unchecked(self.game)
        self.assertIsNotNone(self.game.turn_order)

    def test_start_game_action_is_not_legal_for_less_then_three_players(self):
        for i in range(0, 3):
            game = Game()
            for n in range(0, i):
                game.create_player('Player %d' % n)
            with self.assertRaises(IllegalActionException):
                self.action.assert_legal(game)
예제 #9
0
	def setUp(self):
		self.game = Game()
		self.game.create_player('playerOne', 'red')
		self.game.create_player('playerTwo')
		self.game.create_player('playerThree')
		self.action = StartGameAction('red')
예제 #10
0
	def setUp(self):
		self.game = Game()
		self.game.create_player('bluePlayer', 'blue')
		self.action = PlayerAction('blue')
예제 #11
0
 def setUp(self):
     self.game = Game()
     self.game.create_player('playerOne', 'red')
     self.game.create_player('playerTwo')
     self.game.create_player('playerThree')
     self.action = StartGameAction('red')
예제 #12
0
 def setUp(self):
     self.game = Game()
     self.game.create_player('bluePlayer', 'blue')
     self.action = PlayerAction('blue')