40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using NUnit.Framework;
|
|
using Tetris.Models;
|
|
|
|
namespace TestTetris;
|
|
|
|
public class GameTest {
|
|
private Game g;
|
|
|
|
[SetUp]
|
|
public void SetUp() {
|
|
g = new("test", new Grid(new Color[10,20]));
|
|
Console.Out.WriteLine("===={Grid w/ Tetrominoe}====");
|
|
Console.Out.WriteLine(g.Grid.ToString(g.CurrentTetrominoe));
|
|
Console.Out.WriteLine("============================");
|
|
}
|
|
|
|
[Test]
|
|
public void HitBottom() {
|
|
for (int i = 1; i < (g.Grid.MaxGrid.Y+1)-g.CurrentTetrominoe.Shape.GetLength(1)+1; i++) {
|
|
g.CurrentTetrominoe.GoDown();
|
|
Console.Out.WriteLine(g.Grid.ToString(g.CurrentTetrominoe));
|
|
}
|
|
|
|
Assert.AreEqual(true, g.HitBottom());
|
|
}
|
|
|
|
[Test]
|
|
public void HitTop() {
|
|
Assert.False(g.HitTop());
|
|
|
|
for (int x = 0; x <= g.Grid.MaxGrid.X; x++)
|
|
g.Grid.CGrid[x,g.CurrentTetrominoe.Shape.GetLength(1)] = Color.Red;
|
|
|
|
Console.Out.WriteLine(g.Grid.ToString(g.CurrentTetrominoe));
|
|
|
|
Assert.True(g.HitTop());
|
|
}
|
|
}
|