@@ -12,51 +12,55 @@ public class ShapeSTest
public void Test_Rotations ()
{
// Init
ShapeS shapeS = new ShapeS (null );
ShapeS shapeSTest = new ShapeS (null );
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
// First rotation
shapeSTest .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 1 ), null );
shapeSTest .blocks [1 ] = new Block (Color .Tomato , new Point (1 , 1 ), null );
shapeSTest .blocks [2 ] = new Block (Color .Tomato , new Point (1 , 0 ), null );
shapeSTest .blocks [3 ] = new Block (Color .Tomato , new Point (2 , 0 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ssE .blocks [1 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ssE .blocks [2 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ssE .blocks [3 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
for (int i = 0 ; i < shapeS .blocks .Length ; i ++ )
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
Assert .AreEqual (shapeSTest .blocks [i ].Position , shapeS .blocks [i ].Position );
Assert .AreEqual (ssE .blocks [i ].Position , ss .blocks [i ].Position );
}
// Rotating
shapeS .Rotate ();
ss .Rotate ();
// Second rotation
shapeSTest .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 0 ), null );
shapeSTest .blocks [1 ] = new Block (Color .Tomato , new Point (0 , 1 ), null );
shapeSTest .blocks [2 ] = new Block (Color .Tomato , new Point (1 , 1 ), null );
shapeSTest .blocks [3 ] = new Block (Color .Tomato , new Point (1 , 2 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 0 ), board );
ssE .blocks [1 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ssE .blocks [2 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ssE .blocks [3 ] = new Block (Color .Tomato , new Point (1 , 2 ), board );
for (int i = 0 ; i < shapeS .blocks .Length ; i ++ )
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
Assert .AreEqual (shapeSTest .blocks [i ].Position , shapeS .blocks [i ].Position );
Assert .AreEqual (ssE .blocks [i ].Position , ss .blocks [i ].Position );
}
}
[TestMethod ]
public void Test_NoMove_MoveLeft ()
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ss .blocks [1 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ss .blocks [2 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ss .blocks [3 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ss .MoveLeft ();
ShapeS ssE = new ShapeS (null );
ssE .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ssE .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ssE .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ssE .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ssE .blocks [1 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ssE .blocks [2 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ssE .blocks [3 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
@@ -66,19 +70,22 @@ public void Test_NoMove_MoveLeft()
[TestMethod ]
public void Test_MoveLeft ()
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (3 , 0 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (2 , 1 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ss .blocks [1 ] = new Block (Color .Tomato , new Point (3 , 0 ), board );
ss .blocks [2 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ss .blocks [3 ] = new Block (Color .Tomato , new Point (2 , 1 ), board );
ss .MoveLeft ();
ShapeS ssE = new ShapeS (null );
ssE .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ssE .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ssE .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ssE .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ssE .blocks [1 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ssE .blocks [2 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ssE .blocks [3 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
@@ -89,19 +96,22 @@ public void Test_MoveLeft()
[TestMethod ]
public void Test_NoMove_moveright ()
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (9 , 0 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (10 , 0 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (8 , 1 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (9 , 1 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (9 , 0 ), board );
ss .blocks [1 ] = new Block (Color .Tomato , new Point (10 , 0 ), board );
ss .blocks [2 ] = new Block (Color .Tomato , new Point (8 , 1 ), board );
ss .blocks [3 ] = new Block (Color .Tomato , new Point (9 , 1 ), board );
ss .MoveRight ();
ShapeS ssE = new ShapeS (null );
ssE .blocks [0 ] = new Block (Color .Aquamarine , new Point (9 , 0 ), null );
ssE .blocks [1 ] = new Block (Color .Aquamarine , new Point (10 , 0 ), null );
ssE .blocks [2 ] = new Block (Color .Aquamarine , new Point (8 , 1 ), null );
ssE .blocks [3 ] = new Block (Color .Aquamarine , new Point (9 , 1 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (9 , 0 ), board );
ssE .blocks [1 ] = new Block (Color .Tomato , new Point (10 , 0 ), board );
ssE .blocks [2 ] = new Block (Color .Tomato , new Point (8 , 1 ), board );
ssE .blocks [3 ] = new Block (Color .Tomato , new Point (9 , 1 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
@@ -111,19 +121,22 @@ public void Test_NoMove_moveright()
[TestMethod ]
public void Test_Moveright ()
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ss .blocks [1 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ss .blocks [2 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ss .blocks [3 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ss .MoveRight ();
ShapeS ssE = new ShapeS (null );
ssE .blocks [0 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ssE .blocks [1 ] = new Block (Color .Aquamarine , new Point (3 , 0 ), null );
ssE .blocks [2 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
ssE .blocks [3 ] = new Block (Color .Aquamarine , new Point (2 , 1 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ssE .blocks [1 ] = new Block (Color .Tomato , new Point (3 , 0 ), board );
ssE .blocks [2 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ssE .blocks [3 ] = new Block (Color .Tomato , new Point (2 , 1 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
@@ -135,74 +148,98 @@ public void Test_Moveright()
[TestMethod ]
public void Test_MoveDown ()
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ss .MoveDown ();
ShapeS ssE = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 1 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 2 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 2 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 2 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 2 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 1 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
Assert .AreEqual (ssE .blocks [i ].Position , ss .blocks [i ].Position );
Assert .AreEqual (ssE .blocks [i ].Position , ssE .blocks [i ].Position );
}
}
[TestMethod ]
public void Test_NoMove_MoveDown ()
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 19 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 19 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 20 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 20 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 19 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 19 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 18 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 18 ), board );
ss .MoveDown ();
ShapeS ssE = new ShapeS (null );
ssE .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 19 ), null );
ssE .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 19 ), null );
ssE .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 20 ), null );
ssE .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 20 ), null );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 19 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 19 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 18 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 18 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
Assert .AreEqual (ssE .blocks [i ].Position , ss .blocks [i ].Position );
Assert .AreEqual (ssE .blocks [i ].Position , ssE .blocks [i ].Position );
}
}
[TestMethod ]
public void Test_Drop () // needs access to the board
{
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 1 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 1 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 0 ), board );
ss .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 0 ), board );
ss .Drop ();
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (0 , 19 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 19 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (1 , 18 ), board );
ssE .blocks [0 ] = new Block (Color .Tomato , new Point (2 , 18 ), board );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
Assert .AreEqual (ssE .blocks [i ].Position , ssE .blocks [i ].Position );
}
}
[TestMethod ]
public void Test_reset () // needs access to the board
{
ShapeS ss = new ShapeS (null );
ss .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ss .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ss .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ss .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
// Init
IBoard board = new Board ();
ShapeS ss = new ShapeS (board );
ShapeS ssE = new ShapeS (board );
ss .Rotate ();
ss .Reset ();
ShapeS ssE = new ShapeS (null );
ssE .blocks [0 ] = new Block (Color .Aquamarine , new Point (1 , 0 ), null );
ssE .blocks [1 ] = new Block (Color .Aquamarine , new Point (2 , 0 ), null );
ssE .blocks [2 ] = new Block (Color .Aquamarine , new Point (0 , 1 ), null );
ssE .blocks [3 ] = new Block (Color .Aquamarine , new Point (1 , 1 ), null );
for (int i = 0 ; i < ss .blocks .Length ; i ++ )
{
Assert .AreEqual (ssE .blocks [i ].Position , ss .blocks [i ].Position );
}
}
}
}