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 ) ); }
public void Test_CanMoveLeft_WhenNotAtTheLeftEdge_ReturnsTrue() { Field subject = new Field(10, 10); subject.SetBlock(UNUSED_BLOCK, new Vector2(1, 5)); Assert.IsTrue(subject.CanMoveLeft()); }
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); }
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))); }
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 ) ); }
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); }
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); }
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); }
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); }
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); }
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); }
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()); }
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 ) { } }
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); }
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); }
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); }
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); }
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 ); }
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); }
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); }
public void Test_CanMoveRight_WhenAtTheRightdge_ReturnsFalse() { Field subject = new Field(10, 10); subject.SetBlock(UNUSED_BLOCK, new Vector2(9, 5)); Assert.IsFalse(subject.CanMoveRight()); }
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 ); }
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 ); }
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); }
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 ) ) ); }