public void TestMovement() { Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1); TestBlock.Rotate = false; TestBlock.Assign(); Assert.AreEqual(20, TestBlock.X); Assert.AreEqual(10, TestBlock.Y); int x = 20 * (TestBlock.Size - 1); for (int i = 0; i < 2; i++) { TestBlock.MoveDown(x); } for (int i = 0; i < 4; i++) { TestBlock.MoveRight(x); } Assert.AreEqual(20 + 20 * 4, TestBlock.X); Assert.AreEqual(10 + 20 * 2, TestBlock.Y); for (int i = 0; i < 3; i++) { TestBlock.MoveLeft(); } Assert.AreEqual(20 + 20 * 4 - 20 * 3, TestBlock.X); Assert.AreEqual(50, TestBlock.Y); for (int i = 0; i < 5; i++) { TestBlock.MoveUp(); } Assert.AreEqual(20 + 20 * 4 - 20 * 3, TestBlock.X); Assert.AreEqual(10, TestBlock.Y); //Tesing After Rotaion TestBlock.Rotate = true; TestBlock.Assign(); for (int i = 0; i < 30; i++) { TestBlock.MoveDown(x); } Assert.AreEqual(20 + 20 * 4 - 20 * 3, TestBlock.X); Assert.AreEqual(390 - x, TestBlock.Y); for (int i = 0; i < 30; i++) { TestBlock.MoveRight(x); } Assert.AreEqual(400, TestBlock.X); Assert.AreEqual(390 - x, TestBlock.Y); }
public void TestEdgesAndMovement() { Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1); TestBlock.Rotate = false; TestBlock.Assign(); TestBlock.AssignEdges(); int x = 20 * (TestBlock.Size - 1); TestBlock.MoveRight(x); TestBlock.MoveRight(x); TestBlock.MoveRight(x); TestBlock.AssignEdges(); foreach (Point2D lte in TestBlock.TopLeftEdges) { Assert.AreEqual(20 + 20 * 3, lte.X); Assert.AreEqual(10, lte.Y); } TestBlock.MoveDown(x); TestBlock.MoveDown(x); TestBlock.AssignEdges(); foreach (Point2D rbe in TestBlock.BottomRightEdges) { Assert.AreEqual(20 + 20 * TestBlock.Size + 20 * 3, rbe.X); Assert.AreEqual(10 + TestBlock.Length + 20 * 2, rbe.Y); } }
public void TestMoveDown() { Block TestBlock = new Block_Line(Color.Blue, 20, 10, 20, 4, 1); TestBlock.Rotate = false; TestBlock.Assign(); Assert.AreEqual(10, TestBlock.Y); int x = 20 * (TestBlock.Size - 1); TestBlock.MoveDown(x); TestBlock.MoveDown(x); Assert.AreEqual(50, TestBlock.Y); for (int i = 0; i < 30; i++) { TestBlock.MoveDown(x); } Assert.AreEqual(390, TestBlock.Y); //Testing After Block is Rotated TestBlock.Rotate = true; TestBlock.Assign(); Assert.AreEqual(390, TestBlock.Y); TestBlock.MoveDown(x); TestBlock.MoveDown(x); Assert.AreEqual(390, TestBlock.Y); for (int i = 0; i < 30; i++) { TestBlock.MoveDown(x); } Assert.AreEqual(390, TestBlock.Y); }