コード例 #1
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
 public void BadBigBlockPlacementTest( int x, int y )
 {
     Field field = new Field( 5, 10 );
     IBlock block = new Block();
     createBigBlock( block );
     field.SetBlock( block, new Point( x, y ) );
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: sjbecque/TddTetris
        static void Main(string[] args)
        {
            //fixedBlocks anders invullen, want property hoort private te zijn

            var field = new Field(3,3);
            field.fixedBlocks = new Grid(
                new Square[,] {
                    {_,_,_},
                    {_,_,_},
                    {x,_,_}
            });
            field.Position = new Vector2(1,1);

            var block = new Block(); //!!moet interface worden
            block.vectors = new List<Vector2>
            {
                new Vector2(0,1), //ToSelf: let op [x,y] , niet [y,x] overigens
                new Vector2(1,0)
            };
            block.squareType = x;
            field.Block = block;

            bool ClippingOccured = false;
            Grid gridSuperposition = field.getSuperposition(out ClippingOccured);

            var gridForCheck = new Grid(
                new Square[,] {
                    {_,_,_},
                    {_,_,x},
                    {x,x,_}
            });

            bool r = gridSuperposition.Equals(gridForCheck);
            bool c = ClippingOccured;
        }
コード例 #3
0
ファイル: BlockTest.cs プロジェクト: rutgerk1/TddTetris
        public void ColorAtPositionNegativeTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            Assert.AreEqual( null, block.ColorAt( position ) );
        }
コード例 #4
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
 public void BadBlockPlacementTest( int x, int y )
 {
     Field field = new Field( 2, 10 );
     IBlock block = new Block();
     block.Grid [ 2 ] [ 2 ] = Color.Tomato;
     field.SetBlock( block, new Point( x, y ) );
 }
コード例 #5
0
ファイル: BlockFactory.cs プロジェクト: rutgerk1/TddTetris
 private void insertStraight(Block block)
 {
     List<List<Color?>> grid = block.Grid;
     grid [ 2 ] [ 1 ] = Color.Tomato;
     grid [ 2 ] [ 2 ] = Color.Tomato;
     grid [ 2 ] [ 3 ] = Color.Tomato;
     grid [ 2 ] [ 4 ] = Color.Tomato;
 }
コード例 #6
0
        public void Test_WhenBlockHasOneShape_ItShouldNotChangeShape()
        {
            Color color = Color.Beige;

            Block subject = new Block(oShape, color);

            CompareAllShapesRight(subject, oShape, color);
        }
コード例 #7
0
        public void Test_WhenBlockHasFourShapes_RotateRightShouldCycleThroughThem()
        {
            Color color = Color.Azure;

            Block subject = new Block(lShape, color);

            CompareAllShapesRight(subject, lShape, color);
        }
コード例 #8
0
ファイル: BlockTest.cs プロジェクト: rutgerk1/TddTetris
        public void ColorAtPositionTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            block.Grid [ position.Y ] [ position.X ] = Color.Tomato;
            Assert.AreEqual( Color.Tomato, block.ColorAt( position ) );
        }
コード例 #9
0
ファイル: BlockFactory.cs プロジェクト: Lutger/TddTetris
 public IBlock MakeBlock()
 {
     var block = new Block();
     var definition = this.TetrominoDefinitions[random.Next(0, this.TetrominoDefinitions.Length - 1)];
     block.color = definition.color;
     block.TetrominoGrid = definition.Grid;
     return block;
 }
コード例 #10
0
        private void CompareAllShapesLeft(Block subject, List<bool[,]> shapes, Color color)
        {
            for (int i = shapes.Count -1; i >= 0; i--)
            {
                int currentShape = i % shapes.Count;
                subject.RotateLeft();

                Assert.AreEqual(shapes[currentShape].GetLength(1), subject.Width);
                Assert.AreEqual(shapes[currentShape].GetLength(0), subject.Height);
                CompareBlock(subject, shapes[currentShape], color);
            }

            subject.RotateLeft();
            CompareBlock(subject, shapes[shapes.Count - 1], color);
        }
コード例 #11
0
ファイル: BlockTest.cs プロジェクト: rutgerk1/TddTetris
        public void RotateRightTest()
        {
            Block block = new Block();

            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 4 ] );

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 4 ] );

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 0 ] );

            block.RotateRight();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 0 ] );
        }
コード例 #12
0
ファイル: BlockTest.cs プロジェクト: rutgerk1/TddTetris
        public void RotateLeftTest()
        {
            var block = new Block();

            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 0 ] );
            Assert.AreEqual( null, block.Grid [ 0 ] [ 0 ] );

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 4 ] [ 4 ] );
            Assert.AreEqual( null, block.Grid [ 0 ] [ 0 ] );

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 4 ] );
            Assert.AreEqual( null, block.Grid [ 0 ] [ 0 ] );

            block.RotateLeft();
            Assert.AreEqual( Color.Tomato, block.Grid [ 0 ] [ 0 ] );
        }
コード例 #13
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
        public void TwoColumnMoveLeftOkTest()
        {
            Field field = new Field( 2, 10 );
            IBlock block = new Block();
            field.SetBlock( block, new Point( 1, 0 ) );
            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            bool moveleft = field.CanMoveLeft();
            Assert.AreEqual( true, moveleft );
        }
コード例 #14
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
        public void SingleColumnNoMovesTest()
        {
            Field field = new Field( 1, 10 );
            IBlock block = new Block();
            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            field.SetBlock( block, new Point( 0, 0 ) );

            block.Grid [ 0 ] [ 0 ] = Color.Tomato;

            bool moveleft = field.CanMoveLeft();
            Assert.AreEqual( false, moveleft );
            bool moveright = field.CanMoveRight();
            Assert.AreEqual( false, moveright );
        }
コード例 #15
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
 public void FixSquareBlockTest()
 {
     Field field = new Field( 2, 10 );
     IBlock block = new Block();
     block.Grid [ 0 ] [ 0 ] = Color.Tomato;
     block.Grid [ 0 ] [ 1 ] = Color.Tomato;
     block.Grid [ 1 ] [ 0 ] = Color.Tomato;
     block.Grid [ 1 ] [ 1 ] = Color.Tomato;
     field.SetBlock( block, new Point( 0, 0 ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 0, 9 ) ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 1, 9 ) ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 0, 8 ) ) );
     Assert.AreEqual( null, field.ColorAt( new Point( 1, 8 ) ) );
     field.FixBlock();
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 0, 9 ) ) );
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 1, 9 ) ) );
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 0, 8 ) ) );
     Assert.AreEqual( Color.Tomato, field.ColorAt( new Point( 1, 8 ) ) );
 }
コード例 #16
0
        private void CompareAllShapesRight(Block subject, List<bool[,]> shapes, Color color)
        {
            for (int i = 1; i < shapes.Count; i++)
            {
                subject.RotateRight();

                Assert.AreEqual(shapes[i].GetLength(1), subject.Width);
                Assert.AreEqual(shapes[i].GetLength(0), subject.Height);
                CompareBlock(subject, shapes[i], color);
            }

            subject.RotateRight();
            CompareBlock(subject, shapes[0], color);
        }
コード例 #17
0
ファイル: BlockTests.cs プロジェクト: Lutger/TddTetris
 public IBlock MakeBlock(Color color, byte[,] tetrominoGrid)
 {
     var block = new Block();
     block.TetrominoGrid = tetrominoGrid;
     block.color = color;
     block.Position = new Vector2(0,0);
     return block;
 }
コード例 #18
0
ファイル: BlockFactory.cs プロジェクト: rutgerk1/TddTetris
 public IBlock MakeBlock()
 {
     Block block = new Block();
     insertStraight( block );
     return block;
 }