Esempio n. 1
0
        public void TestNumberPieces()
        {
            GameObject      prepObj    = new GameObject();
            BoardPreparator prep       = prepObj.AddComponent <BoardPreparator>();
            BoardController controller = prepObj.AddComponent <BoardController>();

            Piece prefabwhite = this.prefabW.GetComponent <Piece>();
            Piece prefabblack = this.prefabB.GetComponent <Piece>();

            prepObj.AddComponent <Piece>();

            prep.setTestData(prepObj.GetComponent <Piece>());

            prep.setPrefabsTest(prefabwhite, prefabblack);
            controller.setTestData(prep);

            Piece[][] pieces = prep.PrepareBoard();
            controller.setBoardTestData(pieces);

            int resultWhite = controller.countWhitePieces();
            int resultBlack = controller.countBlackPieces();

            Assert.AreEqual(15, resultBlack);
            Assert.AreEqual(15, resultWhite);
        }
Esempio n. 2
0
        public void TestPieceDie()
        {
            GameObject      b    = new GameObject();
            BoardController c    = b.AddComponent <BoardController>();
            Piece           p    = b.AddComponent <Piece>();
            BoardPreparator prep = b.AddComponent <BoardPreparator>();

            prep.setTestData(p);
            c.setTestData(prep);
            b.AddComponent <Animator>();

            p.Die();
            Assert.AreNotEqual(p, null);
        }
Esempio n. 3
0
        public void TestUpdatePlayer()
        {
            GameObject      prepObj    = new GameObject();
            BoardPreparator prep       = prepObj.AddComponent <BoardPreparator>();
            BoardController controller = prepObj.AddComponent <BoardController>();

            prepObj.AddComponent <Piece>();

            prep.setTestData(prepObj.GetComponent <Piece>());

            controller.setTestData(prep);

            controller.UpdateCurrentPlayer();
            Assert.AreEqual(2, controller.GetCurrentPlayerNumber());
            controller.UpdateCurrentPlayer();
            Assert.AreEqual(1, controller.GetCurrentPlayerNumber());
        }
        public void TestPrepareBoard()
        {
            GameObject      obj      = new GameObject();
            BoardPreparator prep     = obj.AddComponent <BoardPreparator>();
            GameObject      pieceObj = new GameObject();

            pieceObj.AddComponent <Piece>();

            prep.setTestData(pieceObj.GetComponent <Piece>());

            Piece[][] pieces = prep.PrepareBoard();
            Assert.AreEqual(10, pieces.Length);
            for (int i = 0; i < pieces.Length; i++)
            {
                Assert.AreEqual(10, pieces[i].Length);
            }
        }
Esempio n. 5
0
        public void TestPieceDama()
        {
            GameObject      b = new GameObject();
            BoardController c = b.AddComponent <BoardController>();

            Piece           p    = b.AddComponent <Piece>();
            BoardPreparator prep = b.AddComponent <BoardPreparator>();

            prep.setTestData(p);
            c.setTestData(prep);
            p.transform.position = new Vector2(1, 3);
            Assert.IsFalse(p.isThisDama());
            p.makeDama();
            Assert.IsFalse(p.isThisDama());
            p.transform.position = new Vector2(2, 9);
            p.makeDama();
            Assert.IsTrue(p.isThisDama());
        }
Esempio n. 6
0
        public void TestPiecePositions()
        {
            GameObject      b    = new GameObject();
            Piece           p    = b.AddComponent <Piece>();
            BoardController c    = b.AddComponent <BoardController>();
            BoardPreparator prep = b.AddComponent <BoardPreparator>();

            prep.setTestData(p);
            c.setTestData(prep);
            float x = 10;
            float y = 5;

            b.transform.position = new Vector2(x, y);
            Assert.AreEqual(p.GetXPosition(), x);
            Assert.AreEqual(p.GetYPosition(), y);
            int x2 = 15;
            int y2 = 15;

            p.MoveTo(x2, y2);
            Assert.AreEqual(p.GetXPosition(), x2);
            Assert.AreEqual(p.GetYPosition(), y2);
        }