コード例 #1
0
        public void TestMovement()
        {
            Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1);

            TestBlock.Rotate = false;
            TestBlock.Assign();

            Assert.AreEqual(20, TestBlock.X);
            Assert.AreEqual(10, TestBlock.Y);
            int x = 20 * (TestBlock.Size - 1);

            for (int i = 0; i < 2; i++)
            {
                TestBlock.MoveDown(x);
            }

            for (int i = 0; i < 4; i++)
            {
                TestBlock.MoveRight(x);
            }

            Assert.AreEqual(20 + 20 * 4, TestBlock.X);
            Assert.AreEqual(10 + 20 * 2, TestBlock.Y);

            for (int i = 0; i < 3; i++)
            {
                TestBlock.MoveLeft();
            }

            Assert.AreEqual(20 + 20 * 4 - 20 * 3, TestBlock.X);
            Assert.AreEqual(50, TestBlock.Y);

            for (int i = 0; i < 5; i++)
            {
                TestBlock.MoveUp();
            }

            Assert.AreEqual(20 + 20 * 4 - 20 * 3, TestBlock.X);
            Assert.AreEqual(10, TestBlock.Y);

            //Tesing After Rotaion
            TestBlock.Rotate = true;
            TestBlock.Assign();

            for (int i = 0; i < 30; i++)
            {
                TestBlock.MoveDown(x);
            }

            Assert.AreEqual(20 + 20 * 4 - 20 * 3, TestBlock.X);
            Assert.AreEqual(390 - x, TestBlock.Y);

            for (int i = 0; i < 30; i++)
            {
                TestBlock.MoveRight(x);
            }

            Assert.AreEqual(400, TestBlock.X);
            Assert.AreEqual(390 - x, TestBlock.Y);
        }
コード例 #2
0
        public void TestEdgesAndMovement()
        {
            Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1);

            TestBlock.Rotate = false;
            TestBlock.Assign();
            TestBlock.AssignEdges();
            int x = 20 * (TestBlock.Size - 1);

            TestBlock.MoveRight(x);
            TestBlock.MoveRight(x);
            TestBlock.MoveRight(x);
            TestBlock.AssignEdges();

            foreach (Point2D lte in TestBlock.TopLeftEdges)
            {
                Assert.AreEqual(20 + 20 * 3, lte.X);
                Assert.AreEqual(10, lte.Y);
            }

            TestBlock.MoveDown(x);
            TestBlock.MoveDown(x);
            TestBlock.AssignEdges();

            foreach (Point2D rbe in TestBlock.BottomRightEdges)
            {
                Assert.AreEqual(20 + 20 * TestBlock.Size + 20 * 3, rbe.X);
                Assert.AreEqual(10 + TestBlock.Length + 20 * 2, rbe.Y);
            }
        }
コード例 #3
0
        public void TestBottomEdgeAssign()
        {
            Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1);

            TestBlock.Rotate = false;
            TestBlock.Assign();
            TestBlock.AssignEdges();
            foreach (Point2D rbe in TestBlock.BottomRightEdges)
            {
                Assert.AreEqual(20 + 20 * TestBlock.Size, rbe.X);
                Assert.AreEqual(10 + TestBlock.Length, rbe.Y);
            }
            foreach (Point2D lbe in TestBlock.BottomLeftEdges)
            {
                Assert.AreEqual(20, lbe.X);
                Assert.AreEqual(10 + TestBlock.Length, lbe.Y);
            }

            //test after Rotation
            TestBlock.Rotate = true;
            TestBlock.AssignEdges();
            foreach (Point2D rbe in TestBlock.BottomRightEdges)
            {
                Assert.AreEqual(20 + TestBlock.Length, rbe.X);
                Assert.AreEqual(10 + 20 * TestBlock.Size, rbe.Y);
            }
            foreach (Point2D lbe in TestBlock.BottomLeftEdges)
            {
                Assert.AreEqual(20, lbe.X);
                Assert.AreEqual(10 + 20 * TestBlock.Size, lbe.Y);
            }
        }
コード例 #4
0
        public void TestAssign()
        {
            Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1);

            TestBlock.Rotate = false;
            TestBlock.Assign();
            for (int i = 0; i < TestBlock.Squares.Count; i++)
            {
                Assert.AreEqual(20 + i * TestBlock.Length, TestBlock.Squares[i].X);
                Assert.AreEqual(10, TestBlock.Squares[i].Y);
            }

            TestBlock.Rotate = true;
            TestBlock.Assign();
            for (int i = 0; i < TestBlock.Squares.Count; i++)
            {
                Assert.AreEqual(10 + i * TestBlock.Length, TestBlock.Squares[i].Y);
                Assert.AreEqual(20, TestBlock.Squares[i].X);
            }
        }
コード例 #5
0
        public void TestMoveLeft()
        {
            Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1);

            TestBlock.Rotate = false;
            TestBlock.Assign();

            Assert.AreEqual(20, TestBlock.X);
            int x = 20 * (TestBlock.Size - 1);

            TestBlock.MoveLeft();
            TestBlock.MoveLeft();

            Assert.AreEqual(20, TestBlock.X);

            for (int i = 0; i < 30; i++)
            {
                TestBlock.MoveLeft();
            }

            Assert.AreEqual(20, TestBlock.X);

            //Testing After Block is Rotated
            TestBlock.Rotate = true;
            TestBlock.Assign();

            Assert.AreEqual(20, TestBlock.X);

            TestBlock.MoveLeft();
            TestBlock.MoveLeft();

            Assert.AreEqual(20, TestBlock.X);

            for (int i = 0; i < 30; i++)
            {
                TestBlock.MoveLeft();
            }

            Assert.AreEqual(20, TestBlock.X);
        }