コード例 #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
ファイル: FieldTest.cs プロジェクト: ryreitsma/TddTetris
        public void Test_CanMoveLeft_WhenNotAtTheLeftEdge_ReturnsTrue()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(UNUSED_BLOCK, new Vector2(1, 5));

            Assert.IsTrue(subject.CanMoveLeft());
        }
コード例 #3
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_CanMoveLeft_WhenAtTheLeftEdge_ReturnsFalse()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(2, 1), new Vector2(0, 5));

            Assert.That(subject.CanMoveLeft(), Is.False);
        }
コード例 #4
0
        public void Test_ColorAt_WhenNoBlockIsThere_ReturnsNull()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(), new Vector2(3, 4));

            Assert.IsNull(subject.ColorAt(new Vector2(3, 3)));
        }
コード例 #5
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 ) );
 }
コード例 #6
0
 public void SetUp()
 {
     IBlockFactory mockBlockFactory = new BlockHelper.MockBlockFactory();
     position = new Vector2(4, 4);
     field = new Field(10, 10);
     field.SetBlock(new BlockHelper.MockBlock(), position);
     subject = new GameMechanics(field, mockBlockFactory);
 }
コード例 #7
0
ファイル: FieldTests.cs プロジェクト: elroyp/TddTetris
        public void FixBlock_BlockIsDrawnWhenFixed()
        {
            Field f = new Field(1,1);
            f.SetBlock(new Block(), new Vector2(0, 0));
            GameMechanics mech = new GameMechanics(f, new BlockFactory());
            mech.AdvanceIfPossible();

            Color? color = f.ColorAt(new Vector2(0, 0));
            Assert.IsNotNull(color);
        }
コード例 #8
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_CanAdvance_WhenNotAtTheBottom_ReturnsTrue()
        {
            int blockHeight = 3;
            int fieldHeight = 10;

            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(1, blockHeight), new Vector2(2, fieldHeight - blockHeight - 1));

            Assert.That(subject.CanAdvance(), Is.True);
        }
コード例 #9
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_CanAdvance_WhenAtBottom_ReturnsFalse()
        {
            int blockHeight = 3;
            int fieldHeight = 10;

            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(1, blockHeight), new Vector2(3, fieldHeight - blockHeight));

            Assert.That(subject.CanAdvance(), Is.False);
        }
コード例 #10
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_AdvanceBlock()
        {
            Field subject = new Field(10, 10);

            subject.SetBlock(UNUSED_BLOCK, new Vector2(3, 4));

            subject.AdvanceBlock();

            Assert.AreEqual(new Vector2(3, 5), subject.Position);
        }
コード例 #11
0
        public void Test_ColorAt_WhenBlockIsThereWithColor_ReturnsBlockColorAt()
        {
            Field subject = new Field(10, 10);

            Mock<IBlock> block = new Mock<IBlock>();
            block.Setup(b => b.ColorAt(new Vector2(1, 2))).Returns(Color.White);
            block.Setup(b => b.Width).Returns(2);
            block.Setup(b => b.Height).Returns(3);
            subject.SetBlock(block.Object, new Vector2(4, 4));

            Color? result = subject.ColorAt(new Vector2(5, 6));
            Assert.AreEqual(Color.White, result.Value);
        }
コード例 #12
0
ファイル: FieldTest.cs プロジェクト: ryreitsma/TddTetris
        public void Test_CanAdvance_WhenNotAtTheBottom_ReturnsTrue()
        {
            int blockHeight = 3;
            int fieldHeight = 10;

            Mock<IBlock> block = new Mock<IBlock>();
            block.Setup(b => b.Height).Returns(blockHeight);

            Field subject = new Field(10, 10);
            subject.SetBlock(block.Object, new Vector2(2, fieldHeight - blockHeight - 1));

            Assert.IsTrue(subject.CanAdvance());
        }
コード例 #13
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
 public void BadPositionTest( int x, int y )
 {
     IField field = new Field( 10, 10 );
     IBlock block = new BlockFactory().MakeBlock();
     field.SetBlock( block, new Point( 5, 5 ) );
     try
     {
         if ( field.Checker.Check( field, block, x, y ) )
         {
             throw new Exception( string.Format( "bad position has succeeded: x: {0}, y: {1}", x, y ) );
         }
     }
     catch ( FieldException )
     {
     }
 }
コード例 #14
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_CanAdvance_WhenNotAtTheBottomButBlockInWay_ReturnsFalse()
        {
            int blockHeight = 3;
            int fieldHeight = 10;

            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(1, blockHeight), new Vector2(2, fieldHeight - blockHeight - 1));
            subject.SetContentsForTest(new Color?[,]{
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,Color.Red},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null}
            });

            Assert.That(subject.CanAdvance(), Is.False);
        }
コード例 #15
0
        public void Test_ColorAt_WhenBlockIsThereAndNoColor_ItReturnsFieldColorAt()
        {
            Field subject = new Field(4, 4);
            Color white = Color.White;

            subject.SetContentsForTest(new Color?[,]
            { { null, null,  null,  null},
              { null, white, white, null },
              { null, white, white, null },
              { null, null,  null,  null} });

            Mock<IBlock> block = new Mock<IBlock>();
            Color? nullColor = null;

            block.Setup(b => b.Width).Returns(2);
            block.Setup(b => b.Height).Returns(2);
            block.Setup(b => b.ColorAt(new Vector2(0, 1))).Returns(nullColor);

            subject.SetBlock(block.Object, new Vector2(1, 1));

            Color? result = subject.ColorAt(new Vector2(1, 2));
            Assert.AreEqual(Color.White, result.Value);
        }
コード例 #16
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_SetBlock()
        {
            Field subject = new Field(10, 10);
            IBlock block = new BlockHelper.MockBlock(4, 4);
            Vector2 position = new Vector2(2, 3);

            subject.SetBlock(block, position);

            Assert.AreEqual(block, subject.Block);
            Assert.AreEqual(position, subject.Position);
        }
コード例 #17
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_MoveRight()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(), new Vector2(3, 4));
            subject.MoveBlockRight();

            Assert.AreEqual(new Vector2(4, 4), subject.Position);
        }
コード例 #18
0
ファイル: FieldTest.cs プロジェクト: rutgerk1/TddTetris
 public void PositionTest( int x, int y )
 {
     IField field = new Field( 10, 10 );
     IBlock block = new BlockFactory().MakeBlock();
     field.SetBlock( block, new Point( x, y ) );
     field.Checker.Check( field, block, x, y );
 }
コード例 #19
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_CanRotateRight_RightSideNotFreeToRotate_ReturnsFalse()
        {
            int blockHeight = 2;

            Field subject = new Field(3, 3);
            subject.SetBlock(new BlockHelper.MockBlock(1, blockHeight), new Vector2(1, 0));
            subject.SetContentsForTest(new Color?[,]{
                {null,null,null},
                {null,null,null},
                {null,null,null}
            });

            Assert.That(subject.CanRotateRight(), Is.True);
        }
コード例 #20
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_CanMoveRight_WhenNotAtTheRightEdge_ReturnsTrue()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(2, 1), new Vector2(7, 5));

            Assert.That(subject.CanMoveRight(), Is.True);
        }
コード例 #21
0
ファイル: FieldTest.cs プロジェクト: ryreitsma/TddTetris
        public void Test_CanMoveRight_WhenAtTheRightdge_ReturnsFalse()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(UNUSED_BLOCK, new Vector2(9, 5));

            Assert.IsFalse(subject.CanMoveRight());
        }
コード例 #22
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 );
        }
コード例 #23
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 );
        }
コード例 #24
0
ファイル: FieldTest.cs プロジェクト: mmsommer/TddTetris
        public void Test_MoveLeft()
        {
            Field subject = new Field(10, 10);
            subject.SetBlock(UNUSED_BLOCK, new Vector2(3, 4));
            subject.MoveBlockLeft();

            Assert.AreEqual(new Vector2(2, 4), subject.Position);
        }
コード例 #25
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 ) ) );
 }