Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
Tetris/TestTetris/TetrominoeTest.cs

107 lines
2.9 KiB
C#

using System;
using System.Drawing;
using NUnit.Framework;
using Tetris.Models;
using Point = System.Drawing.Point;
namespace TestTetris;
public class TetrominoeTest {
private Tetrominoe t;
private Grid g;
[SetUp]
public void SetUp() {
g = new Grid(new Color[10, 20]);
t = new Tetrominoe(g, new bool[,] {
{true, false, false},
{true, true, true}
}, new Point(5, 10), 0, Color.Aqua);
Console.Out.WriteLine("===={Grid w/ Tetrominoe}====");
Console.Out.WriteLine(g.ToString(t));
Console.Out.WriteLine("============================");
}
[Test]
public void ShapeRotate() {
Assert.AreEqual(new bool[,] {
{true, false, false},
{true, true, true}
}, t.Shape);
t.RotateRight();
Console.Out.WriteLine(t);
Assert.AreEqual(new bool[,] {
{true, true},
{true, false},
{true, false}
}, t.Shape);
t.RotateRight();
Console.Out.WriteLine(t);
Assert.AreEqual(new bool[,] {
{true, true, true},
{false, false, true}
}, t.Shape);
t.RotateRight();
Console.Out.WriteLine(t);
Assert.AreEqual(new bool[,] {
{false, true},
{false, true},
{true, true}
}, t.Shape);
t.RotateRight();
Console.Out.WriteLine(t);
Assert.AreEqual(new bool[,] {
{true, false, false},
{true, true, true}
}, t.Shape);
}
[Test]
public void Orientation() {
t.Orientation = 0;
Assert.AreEqual(0, t.Orientation);
t.RotateLeft();
Assert.AreEqual(3, t.Orientation);
t.RotateLeft();
Assert.AreEqual(2, t.Orientation);
t.RotateLeft();
Assert.AreEqual(1, t.Orientation);
t.RotateLeft();
Assert.AreEqual(0, t.Orientation);
t.Orientation = 3;
t.RotateRight();
Assert.AreEqual(0, t.Orientation);
t.RotateRight();
Assert.AreEqual(1, t.Orientation);
t.RotateRight();
Assert.AreEqual(2, t.Orientation);
t.RotateRight();
Assert.AreEqual(3, t.Orientation);
t.RotateRight();
Assert.AreEqual(0, t.Orientation);
}
[Test]
public void GoRight() {
int startX = t.Coordinates.X;
int startY = t.Coordinates.Y;
t.GoRight();
Assert.AreEqual(new Point(startX+1, startY), t.Coordinates);
}
[Test]
public void GoLeft() {
int startX = t.Coordinates.X;
int startY = t.Coordinates.Y;
t.GoLeft();
Assert.AreEqual(new Point(startX-1, startY), t.Coordinates);
}
[Test]
public void GoDown() {
int startX = t.Coordinates.X;
int startY = t.Coordinates.Y;
t.GoDown();
Assert.AreEqual(new Point(startX,startY+1), t.Coordinates);
}
}