

from app.chess.chess import Chess
import unittest


class TestBuildChess(unittest.TestCase):
    """
    `TestBuildChess()` class is unit-testing the class
    Chess().
    """

    # ///////////////////////////////////////////////////
    def setUp(self):
        params = [4, 4]
        pieces = {'King': 2, 'Queen': 1, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
        params.append(pieces)
        self.chess = Chess(params)

    # ///////////////////////////////////////////////////
    def test_solve(self):
        """Tests validity of solution"""
        self.assertEqual(self.chess.pieces_types == ['K', 'K', 'Q'], True)
        self.assertEqual(self.chess.number_pieces == 3, True)
#       self.assertEqual(self.chess.solutions == 1, True)
       

if __name__ == '__main__':
    unittest.main()
    



from app.chess.chess import Chess
import unittest


class TestBuildChess(unittest.TestCase):
    """
    `TestBuildChess()` class is unit-testing the class
    Chess().
    """

    # ///////////////////////////////////////////////////
    def setUp(self):
        params = [4, 4]
        pieces = {'King': 2, 'Queen': 1, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
        params.append(pieces)
        self.chess = Chess(params)

    # ///////////////////////////////////////////////////
    def test_solve(self):
        """Tests validity of solution"""
        self.assertEqual(self.chess.pieces_types == ['K', 'K', 'Q'], True)
        self.assertEqual(self.chess.number_pieces == 3, True)
#       self.assertEqual(self.chess.solutions == 1, True)
     
    def test_solution_only_kings(self):
        params = [5, 5]
        pieces = {'King': 2, 'Queen': 0, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
        params.append(pieces)
        self.chess = Chess(params)
        self.chess.run_game()
        self.assertEqual(self.chess.solutions == 228, True)
        

if __name__ == '__main__':
    unittest.main()
    

Add a TDD funct to test the solution (only kings)
Add a TDD funct to test the solution (only kings)
  
  
  from app.chess.chess import Chess
  import unittest
  
  
  class TestBuildChess(unittest.TestCase):
      """
      `TestBuildChess()` class is unit-testing the class
      Chess().
      """
  
      # ///////////////////////////////////////////////////
      def setUp(self):
          params = [4, 4]
          pieces = {'King': 2, 'Queen': 1, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
          params.append(pieces)
          self.chess = Chess(params)
  
      # ///////////////////////////////////////////////////
      def test_solve(self):
          """Tests validity of solution"""
          self.assertEqual(self.chess.pieces_types == ['K', 'K', 'Q'], True)
          self.assertEqual(self.chess.number_pieces == 3, True)
  #       self.assertEqual(self.chess.solutions == 1, True)
+      
+     def test_solution_only_kings(self):
+         params = [5, 5]
+         pieces = {'King': 2, 'Queen': 0, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
+         params.append(pieces)
+         self.chess = Chess(params)
+         self.chess.run_game()
+         self.assertEqual(self.chess.solutions == 228, True)
-        
+         
  
  if __name__ == '__main__':
      unittest.main()
      
  
Add a TDD funct to test the solution (only kings)
## Code Before:


from app.chess.chess import Chess
import unittest


class TestBuildChess(unittest.TestCase):
    """
    `TestBuildChess()` class is unit-testing the class
    Chess().
    """

    # ///////////////////////////////////////////////////
    def setUp(self):
        params = [4, 4]
        pieces = {'King': 2, 'Queen': 1, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
        params.append(pieces)
        self.chess = Chess(params)

    # ///////////////////////////////////////////////////
    def test_solve(self):
        """Tests validity of solution"""
        self.assertEqual(self.chess.pieces_types == ['K', 'K', 'Q'], True)
        self.assertEqual(self.chess.number_pieces == 3, True)
#       self.assertEqual(self.chess.solutions == 1, True)
       

if __name__ == '__main__':
    unittest.main()
    

## Instruction:
Add a TDD funct to test the solution (only kings)
## Code After:


from app.chess.chess import Chess
import unittest


class TestBuildChess(unittest.TestCase):
    """
    `TestBuildChess()` class is unit-testing the class
    Chess().
    """

    # ///////////////////////////////////////////////////
    def setUp(self):
        params = [4, 4]
        pieces = {'King': 2, 'Queen': 1, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
        params.append(pieces)
        self.chess = Chess(params)

    # ///////////////////////////////////////////////////
    def test_solve(self):
        """Tests validity of solution"""
        self.assertEqual(self.chess.pieces_types == ['K', 'K', 'Q'], True)
        self.assertEqual(self.chess.number_pieces == 3, True)
#       self.assertEqual(self.chess.solutions == 1, True)
     
    def test_solution_only_kings(self):
        params = [5, 5]
        pieces = {'King': 2, 'Queen': 0, 'Bishop': 0, 'Rook': 0, 'Knight': 0}
        params.append(pieces)
        self.chess = Chess(params)
        self.chess.run_game()
        self.assertEqual(self.chess.solutions == 228, True)
        

if __name__ == '__main__':
    unittest.main()
    
