コード例 #1
0
 def test_that_get_surroundings_returns_surrounding_object(self):
     f = MazeField([
         [Wall, Wall, Wall],
         [Wall, Path, Wall],
         [Wall, Wall, Wall],
     ])
     start_position = f.get_surrounding(coordinate(2, 2))  # Path (2,2)
     self.assertIsInstance(start_position, surroundings)
コード例 #2
0
 def test_that_get_start_position_returns_1_and_1(self):
     f = MazeField([
         [Wall, Wall, Wall],
         [Wall, Start, Wall],
         [Wall, Wall, Wall],
     ])
     start_position = f.get_start_position()
     self.assertEqual(start_position, coordinate(2, 2))
コード例 #3
0
 def test_that_get_surroundings_returns_walls(self):
     f = MazeField([
         [Wall, Wall, Wall],
         [Wall, Path, Wall],
         [Wall, Wall, Wall],
     ])
     start_position = f.get_surrounding(coordinate(2, 2))  # Path (2,2)
     self.assertEqual(
         start_position,
         surroundings(
             right=Wall,
             left=Wall,
             up=Wall,
             down=Wall,
         ))
コード例 #4
0
 def test_that_get_surroundings_returns_attributes_of_coordinate(self):
     f = MazeField([
         [Wall, Wall, Wall, Wall],
         [Wall, Path, Path, Wall],
         [Wall, Wall, Finish, Wall],
         [Wall, Wall, Wall, Wall],
     ])
     start_position = f.get_surrounding(coordinate(3, 2))  # Path (3, 3)
     self.assertEqual(
         start_position,
         surroundings(
             right=Wall,
             left=Path,
             up=Wall,
             down=Finish,
         ))
コード例 #5
0
 def test_that_get_start_position_returns_1_and_1(self):
     f = MazeField([[Start]])
     start_position = f.get_start_position()
     self.assertEqual(start_position, coordinate(1, 1))
コード例 #6
0
 def test_that_is_finish_returns_true_when_coordinate_is_not_finish(self):
     f = MazeField([[Wall]])
     is_finish = f.is_finish(coordinate(1, 1))
     self.assertFalse(is_finish)
コード例 #7
0
 def test_that_is_finish_returns_true_when_coordinate_is_finish(self):
     f = MazeField([[Finish]])
     is_finish = f.is_finish(coordinate(1, 1))
     self.assertTrue(is_finish)
コード例 #8
0
 def test_that_can_move_to_position_returns_False_when_coordinate_is_a_finish(
         self):
     f = MazeField([[Finish]])
     can_move = f.can_move_to_coordinate(coordinate(1, 1))
     self.assertTrue(can_move)
コード例 #9
0
 def test_that_can_move_to_position_returns_False_when_coordinate_is_a_wall(
         self):
     f = MazeField([[Wall]])
     can_move = f.can_move_to_coordinate(coordinate(1, 1))
     self.assertFalse(can_move)
コード例 #10
0
 def test_that_play_turn_changes_current_position_when_possible(self):
     self.game.play_turn()
     self.assertEqual(self.game.get_current_position(), coordinate(2, 3))
コード例 #11
0
    def test_player_can_move_up(self):
        self.player.turn.return_value = moves.DOWN

        self.game.play_turn()
        self.assertEqual(self.game.get_current_position(), coordinate(2, 3))
コード例 #12
0
    def test_player_can_move_right(self):
        self.player.turn.return_value = moves.RIGHT

        self.game.play_turn()
        self.assertEqual(self.game.get_current_position(), coordinate(3, 2))
コード例 #13
0
 def test_that_game_sets_current_position_to_start_position_of_field_on_initialization(self):
     game = setup_game()
     current_position = game.get_current_position()
     self.assertEqual(current_position, coordinate(2, 2))
コード例 #14
0
    def test_that_play_turn_keeps_current_position_when_player_raises_exception(self):
        self.player.turn.side_effect = Exception

        self.game.play_turn()
        self.assertEqual(self.game.get_current_position(), coordinate(2, 2))
コード例 #15
0
    def test_that_play_turn_keeps_current_position_when_move_is_not_possible(self):
        self.player.turn.return_value = moves.UP

        self.game.play_turn()
        self.assertEqual(self.game.get_current_position(), coordinate(2, 2))