Example #1
0
        public void TestIfMethodGetBlockTypeReturnGivenString()
        {
            Block  oBlock            = new O_Block(2, 1);
            string expectedBlockType = "O_Block";
            string actualResult      = oBlock.GetBlockType();

            Assert.AreEqual(expectedBlockType, actualResult);
        }
Example #2
0
        public void TestIfMethodIfBlockOutOfGridOnRotateReturnsFalse()
        {
            int   gridX          = 5;
            Block oBlock         = new O_Block(5, 6);
            bool  actualResult   = oBlock.IfBlockOutOfGridOnRotate(gridX);
            bool  expectedResult = false;

            Assert.AreEqual(expectedResult, actualResult);
        }
Example #3
0
        public void TestIfMethodIfBlockOverrideOnRotateReturnsFalse()
        {
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
            bool[,] HardLayer = { { false, false, true }, { false, true, true } };
#pragma warning restore CA1814 // Prefer jagged arrays over multidimensional
            Block oBlock         = new O_Block(85, 6576);
            bool  actualResult   = oBlock.IfBlockOverrideOnRotate(HardLayer);
            bool  expectedResult = false;
            Assert.AreEqual(expectedResult, actualResult);
        }
Example #4
0
        public void TestIfMiddlePointIsSetCorrectly()
        {
            int           middleX             = 4;
            int           middleY             = 7;
            Block         oBlock              = new O_Block(middleX, middleY);
            PrivateObject po                  = new PrivateObject(oBlock);
            Point         actualMiddlePoint   = (Point)po.GetField("middlePoint");
            Point         expectedMiddlePoint = new Point(middleX, middleY);

            Assert.AreEqual(expectedMiddlePoint.Get()[0], actualMiddlePoint.Get()[0]);
            Assert.AreEqual(expectedMiddlePoint.Get()[1], actualMiddlePoint.Get()[1]);
        }
Example #5
0
    Block CreateBlock(char shape_ch, int type)
    {
        Node[] nl = new Node[4];
        for (int i = 0; i < 4; i++)
        {
            GameObject o = Instantiate(resBlock);
            o.transform.SetParent(transform.Find("Panel"));
            o.transform.localScale = Vector3.one;
            nl[i] = new Node(o.transform);
        }
        Block tmp_b = new Block();

        switch (shape_ch)
        {
        case 'I':
            tmp_b  = new I_Block(nl, type);
            t_type = 1;
            break;

        case 'L':
            tmp_b  = new L_Block(nl, type);
            t_type = 2;
            break;

        case 'J':
            tmp_b  = new J_Block(nl, type);
            t_type = 3;
            break;

        case 'T':
            tmp_b  = new T_Block(nl, type);
            t_type = 4;
            break;

        case 'Z':
            tmp_b  = new Z_Block(nl, type);
            t_type = 5;
            break;

        case 'S':
            tmp_b  = new S_Block(nl, type);
            t_type = 6;
            break;

        case 'O':
            tmp_b  = new O_Block(nl, type);
            t_type = 7;
            break;
        }
        return(tmp_b);
    }
Example #6
0
        public void TestIfRestPointsAreSetCorrectly()
        {
            int           middleX = 3;
            int           middleY = 5;
            Block         oBlock  = new O_Block(middleX, middleY);
            PrivateObject po      = new PrivateObject(oBlock);

            Point[] actualRestPoints   = (Point[])po.GetField("restPoints");
            Point[] expectedRestPoints = new Point[3] {
                new Point(3, 4), new Point(4, 4), new Point(4, 5)
            };
            for (int i = 0; i < actualRestPoints.Length; i++)
            {
                Assert.AreEqual(expectedRestPoints[i].Get()[0], actualRestPoints[i].Get()[0]);
                Assert.AreEqual(expectedRestPoints[i].Get()[1], actualRestPoints[i].Get()[1]);
            }
        }
Example #7
0
        public void TestIfAllPointsAreSetCorrectly()
        {
            int           middleX = 23;
            int           middleY = 3;
            Block         oBlock  = new O_Block(middleX, middleY);
            PrivateObject po      = new PrivateObject(oBlock);

            Point[] actualAllPoints     = (Point[])po.GetField("allPoints");
            Point   expectedMiddlePoint = new Point(middleX, middleY);

            Point[] expectedAllPoints = new Point[4] {
                expectedMiddlePoint, new Point(23, 2), new Point(24, 2), new Point(24, 3)
            };
            for (int i = 0; i < actualAllPoints.Length; i++)
            {
                Assert.AreEqual(expectedAllPoints[i].Get()[0], actualAllPoints[i].Get()[0]);
                Assert.AreEqual(expectedAllPoints[i].Get()[1], actualAllPoints[i].Get()[1]);
            }
        }
Example #8
0
        public void TestIfAllThreePrivateFieldsAreSetByConstructorCall()
        {
            int           middleX = 23;
            int           middleY = 17;
            Block         oBlock  = new O_Block(middleX, middleY);
            PrivateObject po      = new PrivateObject(oBlock);

            Point actualMiddlePoint = (Point)po.GetField("middlePoint");

            Point[] actualRestPoints = (Point[])po.GetField("restPoints");
            Point[] actualAllPoints  = (Point[])po.GetField("allPoints");

            int expectedMiddlePointLength     = 2;
            int expectedRestPointsLength      = 3;
            int expectedActualAllPointsLength = 4;

            Assert.AreEqual(expectedMiddlePointLength, actualMiddlePoint.Get().Length);
            Assert.AreEqual(expectedRestPointsLength, actualRestPoints.Length);
            Assert.AreEqual(expectedActualAllPointsLength, actualAllPoints.Length);
        }