from src.Game.game import Game
from src.Board.board import Board
from src.AI.ai import AI
import unittest

class Game_Tester(unittest.TestCase):
    def setUp(self) -> None:
        self.board=Board()
        self.ai=AI()
        self.game=Game(self.board,self.ai)
        return super().setUp()
    
    def tearDown(self) -> None:
        self.game=None
        return super().tearDown()

    def test_play(self):
        self.game.reset_game()
        self.board.reset()
        self.board.place(0,1)
        self.board.place(1,1)
        self.game.play(3)
        self.assertEqual(self.board.check_cell(0,0),1)
        self.assertEqual(self.board.check_cell(0,1),1)
        self.assertEqual(self.board.check_cell(0,2),1)
        self.assertEqual(self.board.check_cell(0,3),2)

    def test_get_score(self):
        self.game.reset_game()
        self.assertListEqual(self.game.get_score(),[0,0])
        self.board.reset()
        self.board.place(0,1)
        self.board.place(1,1)
        self.board.place(2,1)
        self.game.play(4)
        self.assertListEqual(self.game.get_score(),[1,0])

    def test_reset_board(self):
        self.game.reset_board()
        count=0
        for i in range(7):
                if self.board.check_cell(0,i)==None:
                    count+=1
        self.assertGreaterEqual(count,6)
    def test_reset_game(self):
        self.game.reset_game()
        count=0
        for i in range(7):
                if self.board.check_cell(0,i)==None:
                    count+=1
        self.assertGreaterEqual(count,6)
        self.assertListEqual(self.game.get_score(),[0,0])