예제 #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 TestMoveUp()
        {
            Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1);

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

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

            TestBlock.MoveUp();
            TestBlock.MoveUp();

            Assert.AreEqual(10, TestBlock.Y);

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

            Assert.AreEqual(10, TestBlock.Y);

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

            Assert.AreEqual(10, TestBlock.Y);

            TestBlock.MoveUp();
            TestBlock.MoveUp();

            Assert.AreEqual(10, TestBlock.Y);

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

            Assert.AreEqual(10, TestBlock.Y);
        }