def test_check_move_with_condition_2_and_valid_items_in_destination(self): game = GameState(4) game.columns[0].cards.items = [Card(1), Card(2)] game.columns[1].cards.items = [Card(4), Card(3)] move = Move(0, 1) self.assertTrue(MoveHelper.check_move(game, move))
def test_check_move_with_empty_column_0(self): # TODO: Consider whether this should be implemented game = GameState(2) game.columns[1].cards.items = [1] move = Move(1, 0) self.assertRaises(ValueError, MoveHelper.check_move, game, move)
def test_draw_game_with_empty_game(self): screen = Screen(10, 10) game = GameState(2) ScreenHelper.draw_game(screen, game) expected_screen = Screen(10, 10) self.assertListEqual(expected_screen.get_matrix(), screen.get_matrix())
def test_check_move_with_condition_3_and_valid_items_in_destination(self): game = GameState( 14) # large so that we generate the correct number of columns game.columns[1].cards.items = [Card(2), Card(1)] game.columns[2].cards.items = [Card(4), Card(3)] game.columns[3].cards.items = [Card(2), Card(1)] self.assertTrue(MoveHelper.check_move(game, Move(1, 2))) self.assertTrue(MoveHelper.check_move(game, Move(3, 2)))
def test_make_move_with_valid_condition_1(self): game = GameState(4) game.columns[0].cards.items = [4, 3, 2, 1] move = Move(0, 0) MoveHelper.make_move(game, move) actual_column = game.columns[0].cards.items expected_column = [1, 4, 3, 2] self.assertListEqual(expected_column, actual_column)
def test_draw_game_with_one_column(self): screen = Screen(10, 10) game = GameState(2) game.columns[0].cards.items = [Card(5), Card(4)] ScreenHelper.draw_game(screen, game) expected_screen = Screen(10, 10) column = Column() column.cards.items = [Card(5), Card(4)] ScreenHelper.draw_column(expected_screen, 0, 0, column) self.assertListEqual(expected_screen.get_matrix(), screen.get_matrix())
def test_make_move_with_single_valid_condition_3_and_no_cards_in_destination( self): game = GameState(4) game.columns[1].cards.items = [4] move = Move(1, 2) MoveHelper.make_move(game, move) actual_column_1 = game.columns[1].cards.items expected_column_1 = [] actual_column_2 = game.columns[2].cards.items expected_column_2 = [4] self.assertListEqual(expected_column_2, actual_column_2) self.assertListEqual(expected_column_1, actual_column_1)
def test_make_move_with_valid_condition_2_and_cards_in_destination(self): game = GameState(4) game.columns[0].cards.items = [4, 3, 1] game.columns[1].cards.items = [2] move = Move(0, 1) MoveHelper.make_move(game, move) actual_column_0 = game.columns[0].cards.items expected_column_0 = [4, 3] actual_column_1 = game.columns[1].cards.items expected_column_1 = [2, 1] self.assertListEqual(expected_column_0, actual_column_0) self.assertListEqual(expected_column_1, actual_column_1)
def test_draw_game_with_multiple_columns(self): screen = Screen(30, 30) game = GameState(4) game.columns[0].cards.items = [Card(5), Card(4)] game.columns[1].cards.items = [Card(3), Card(2)] ScreenHelper.draw_game(screen, game) expected_screen = Screen(30, 30) column1 = Column() column2 = Column() column1.cards.items = [Card(5), Card(4)] column2.cards.items = [Card(3), Card(2)] ScreenHelper.draw_column(expected_screen, 0, 0, column1) ScreenHelper.draw_column(expected_screen, 10, 0, column2) self.assertListEqual(expected_screen.get_matrix(), screen.get_matrix())
def test_check_if_won_without_cards_in_first_column(self): game = GameState(4) game.columns[1].cards.items = [3, 2, 1] self.assertTrue(WinChecker.check_if_won(game))
def test_check_move_with_condition_1_and_items_in_deque(self): game = GameState(2) game.columns[0].cards.items = [Card(1), Card(2)] move = Move(0, 0) self.assertTrue(MoveHelper.check_move(game, move))
def test_check_move_with_condition_1_and_no_items_in_deque(self): game = GameState(2) move = Move(0, 0) self.assertFalse(MoveHelper.check_move(game, move))
def test_check_move_with_condition_3_and_no_items_in_destination(self): game = GameState(2) game.columns[1].cards.items = [Card(1), Card(2)] move = Move(1, 2) self.assertTrue(MoveHelper.check_move(game, move))
def test_check_move_with_condition_2_and_no_items_in_destination(self): game = GameState(2) game.setup_random_deck() move = Move(0, 1) self.assertTrue(MoveHelper.check_move(game, move))
def test_check_if_won_with_card_in_two_columns(self): game = GameState(4) game.columns[1].cards.items = [3, 2, 1] game.columns[2].cards.items = [5, 4] self.assertFalse(WinChecker.check_if_won(game))
def test_check_if_won_with_cards_in_first_column(self): game = GameState(4) game.columns[0].cards.items = [0, 1] self.assertFalse(WinChecker.check_if_won(game))
def test_check_move_with_condition_3_and_no_items_in_destination_and_no_items_in_source( self): game = GameState(2) move = Move(2, 1) self.assertFalse(MoveHelper.check_move(game, move))