예제 #1
0
        public void TestClearLines()
        {
            FakeBoard c = createInstance() as FakeBoard;

            IShape current = null;

            while (!(current is ShapeI))
            {
                c = createInstance() as FakeBoard;

                current = c.shape;
            }

            ShapeProxy z = getProxy(c);

            Console.WriteLine("Board before drop of ShapeI");
            UtilityClass.DrawFakeBoardContents(c);

            z.Drop();

            Console.WriteLine("Button line should be clear and everthing should shft");
            UtilityClass.DrawFakeBoardContents(c);

            //check if line got cleared
            Assert.AreEqual(c[19, 0], Color.Transparent);

            //check if the top piece shifted 1 down

            Assert.AreEqual(c[1, 0], Color.DarkRed);
        }
예제 #2
0
        public void MoveRotateProxyTest()
        {
            ShapeProxy b = createInstance();

            b.MoveDown();
            b.MoveDown();
            b.MoveDown();

            String beforeRotate = b.ToString();

            b.Rotate();
            Console.WriteLine(b.ToString() + "before Rotate\n" + beforeRotate);

            //back to inital state

            //if shape is an O no rotation is available
            if (boardInstance.Shape is ShapeO)
            {
                Assert.AreEqual(beforeRotate, b.ToString());
            }
            else
            {
                Assert.AreNotEqual(beforeRotate, b.ToString());
            }
        }
예제 #3
0
        public TestBoard()
        {
            this.board = new Color[20, 10];
            ShapeProxy shapeProxy = new ShapeProxy(this);

            this.shape        = shapeProxy;
            this.shapeFactory = shapeProxy;
            shape.JoinPile   += joinPileHandler;
        }
예제 #4
0
        public void TestIndexerProperty()
        {
            ShapeProxy a = createInstance();

            for (int i = 0; i < 4; i++)
            {
                Assert.AreNotEqual(a[i], null);
            }
        }
예제 #5
0
        public void TestLengthProperty()
        {
            ShapeProxy a = createInstance();

            int num = a.Length;

            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(4, num);
            }
        }
예제 #6
0
    public ShapeProxy GetShapeProxy()
    {
        ShapeProxy proxy = ScriptableObject.CreateInstance <ShapeProxy>();

        proxy.name         = "Shape";
        proxy.shape        = this;
        proxy.penSize      = penSize;
        proxy.colorOutline = colorOutline;
        proxy.colorFill    = colorFill;

        return(proxy);
    }
예제 #7
0
        public void DeployNewShape()
        {
            Board  board   = new Board();
            IShape current = new ShapeProxy(board);
            int    count   = 0;

            for (int i = 0; i < current.Length; i++)
            {
                count++;
            }

            Assert.AreEqual(true, current.Length == count);
        }
예제 #8
0
        public void DeployNewShape_WithArgument()
        {
            //arange
            IBoard     board  = new TestBoard(createEmptyBoard());
            ShapeProxy shape  = new ShapeProxy(board);
            ShapeProxy shape2 = new ShapeProxy(board);

            //act
            shape.DeployNewShape(shape2);

            //assert
            //Blocks should have the same color since the shape created in shape2 is passed to shape
            Assert.IsTrue(shape[0].Colour.Equals(shape2[0].Colour));
        }
예제 #9
0
        public void TestDeployShape()
        {
            ShapeProxy a = createInstance();

            //test Shape returns not nulls and valid shapes

            var shape = a.DeployNewShape();

            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(true, testValidShape(shape));
                shape = a.DeployNewShape();
            }
        }
예제 #10
0
        public void TestGameOver()
        {
            FakeBoard board = createInstance() as FakeBoard;

            board.GameOver += FakeGameOverHandler;

            ShapeProxy z = getProxy(board);

            //shapes will be dropped so after 6-7 pieces the board should be full
            for (int i = 0; i < 15; i++)
            {
                z.Drop();
                UtilityClass.DrawFakeBoardContents(board);
            }
        }
예제 #11
0
        public void Move_OnJoinPile()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard());
            IShape shape = new ShapeProxy(board);

            bool eventJoin = false;

            shape.JoinPile += () => eventJoin = true;
            //act
            shape.Drop();

            //assert
            Assert.IsTrue(eventJoin);
        }
예제 #12
0
        public void TestBoardAddToPile()
        {
            FakeBoard board = createInstance() as FakeBoard;

            ShapeProxy a = getProxy(board);

            //make it so IShape wont clear line when dropped
            board.board[19, 0] = Color.Transparent;

            int  index  = 19;
            bool filled = false;

            IShape current = board.shape;

            Console.WriteLine("Board before the drop");
            UtilityClass.DrawFakeBoardContents(board);
            Console.WriteLine();


            for (int i = 0; i < 12; i++)
            {
                a.Drop();

                Console.WriteLine("Board AFTER the drop");
                UtilityClass.DrawFakeBoardContents(board);

                //check the middle or 1 to the right or left

                if (board[index, 5] != Color.Transparent ||
                    board[index, 5 + 1] != Color.Transparent ||
                    board[index, 5 - 1] != Color.Transparent)
                {
                    filled = true;
                }
                else
                {
                    filled = false;
                }


                index = index - 1;
                Console.WriteLine("Checking index = " + index);

                Assert.AreEqual(true, filled);
            }
        }
예제 #13
0
        public void DeployNewShape_DifferentShapeCreated()
        {
            //arange
            IBoard     board = new TestBoard(createEmptyBoard());
            ShapeProxy shape = new ShapeProxy(board);

            //act
            shape.Drop();
            Block b1 = shape[0];

            shape.DeployNewShape();
            Block b2 = shape[0];

            //assert
            //Blocks should have different positions since belong two different shapes (and one of the was moved)
            Assert.IsFalse(b1.Position.Equals(b2.Position));
        }
예제 #14
0
        public void MoveDown_EnoughSpace()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard());
            IShape shape = new ShapeProxy(board);

            //act
            int x1 = shape[0].Position.X;
            int y1 = shape[0].Position.Y;

            shape.MoveDown();
            int x2 = shape[0].Position.X;
            int y2 = shape[0].Position.Y;

            //assert
            Assert.IsTrue(x1 == x2);
            Assert.IsTrue(y1 != y2);
        }
예제 #15
0
        public void MoveResetProxyTest()
        {
            ShapeProxy b = createInstance();

            b.MoveDown();
            String beforeReset = b.ToString();

            //two places down

            //move down once
            //act
            b.Reset();

            String afterReset = b.ToString();

            Console.WriteLine("Coors should be different" + "Before Reset" + beforeReset + "\nAfter Reset" + afterReset);

            Assert.AreNotEqual(beforeReset, afterReset);
        }
예제 #16
0
        //************************************************************************************
        private ShapeProxy createInstance()
        {
            IBoard board = new FakeBoard(20, 10);

            boardInstance = (FakeBoard)board;

            FakeBoard fake = board as FakeBoard;

            fake.board[19, 0] = Color.DarkBlue;
            fake.board[19, 1] = Color.DarkBlue;
            fake.board[19, 2] = Color.DarkBlue;
            fake.board[19, 7] = Color.DarkBlue;
            fake.board[19, 8] = Color.DarkBlue;
            fake.board[19, 9] = Color.DarkBlue;


            ShapeProxy factory = (ShapeProxy)((FakeBoard)board).shapeFactory;

            return(factory);
        }
예제 #17
0
        public void MoveRightProxyTest()
        {
            ShapeProxy b = createInstance();

            Shape a = boardInstance.Shape as Shape;

            //two places down
            for (int i = 0; i < 2; i++)
            {
                //move down once
                String expect = calDownLeftOrRight(a, 1, 0);

                //act
                b.MoveRight();

                a.DrawShape();
                Console.WriteLine("Expected is \n" + expect + "\n" + "Obtained is \n" + a.ToString());

                Assert.AreEqual(expect, b.ToString());
            }
        }
예제 #18
0
        public void DropProxyTest()
        {
            ShapeProxy b = createInstance();

            bool bottomLineFilled = false;

            //to avoid clearlines if ShapeI spawns
            boardInstance.board[19, 0] = Color.Transparent;

            //two places down
            Console.WriteLine("Board before drop\n");
            UtilityClass.DrawFakeBoardContents(boardInstance);
            //move down once
            //act
            b.Drop();

            String afterDrop = b.ToString();

            Console.WriteLine("board After drop\n");


            UtilityClass.DrawFakeBoardContents(boardInstance);

            if (boardInstance[19, 3] != Color.Transparent ||
                boardInstance[19, 4] != Color.Transparent ||
                boardInstance[19, 5] != Color.Transparent ||
                boardInstance[19, 6] != Color.Transparent)
            {
                bottomLineFilled = true;
            }
            else
            {
                bottomLineFilled = false;
            }

            Assert.AreEqual(true, bottomLineFilled);
        }
예제 #19
0
 public virtual void VisitShapeStart(ShapeProxy shape)
 {
 }
예제 #20
0
 public virtual void VisitShapeEnd(ShapeProxy shape)
 {
 }