public void OneSlot() { //Init Application.Model m = new Application.Model(100); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { m.GetTable() [i, j] = i * 4 + j; } } //Test m.NewItem(); //Assert for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (m.GetTable() [i, j] == 0) { Assert.Fail(); } } } Assert.Pass(); }
public void OneElement() { //Init Application.Model m = new Application.Model(100); m.GetTable() [3, 3] = 2; //Test bool t = m.Left(); //Assert for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == 3 && j == 0) { Assert.AreEqual(2, m.GetTable()[i, j]); } else { Assert.AreEqual(0, m.GetTable()[i, j]); } } } Assert.AreEqual(true, t); }
public void EmptyBoard() { //Init Application.Model m = new Application.Model(100); //set seed for rng //Test m.NewItem(); //Assert bool ret = false; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (m.GetTable() [i, j] != 0 && ret == false) { ret = true; } else if (m.GetTable() [i, j] != 0 && ret == true) { Assert.Fail(); } } } Assert.AreEqual(true, ret); }
public void ConnectPriority() { //Init Application.Model m = new Application.Model(100); m.GetTable() [3, 3] = 2; m.GetTable() [2, 3] = 2; m.GetTable() [1, 3] = 2; m.GetTable() [0, 3] = 1; int[,] temp = new int[4, 4]; //Test bool t = m.Down(); //Assert temp [3, 3] = 4; temp [2, 3] = 2; temp [1, 3] = 1; temp [0, 3] = 0; Assert.AreEqual(temp, m.GetTable()); Assert.AreEqual(true, t); }
public void Nothing() { //Init Application.Model m = new Application.Model(100); m.GetTable() [3, 3] = 4; m.GetTable() [2, 3] = 3; m.GetTable() [1, 3] = 2; m.GetTable() [0, 3] = 1; int[,] temp = new int[4, 4]; //Test bool t = m.Down(); //Assert temp [3, 3] = 4; temp [2, 3] = 3; temp [1, 3] = 2; temp [0, 3] = 1; Assert.AreEqual(temp, m.GetTable()); Assert.AreEqual(false, t); }
public void Connect() { //Init Application.Model m = new Application.Model(100); m.GetTable() [3, 3] = 2; m.GetTable() [3, 2] = 2; m.GetTable() [3, 1] = 4; m.GetTable() [3, 0] = 1; int[,] temp = new int[4, 4]; //Test bool t = m.Right(); //Assert temp [3, 3] = 4; temp [3, 2] = 4; temp [3, 1] = 1; temp [3, 0] = 0; Assert.AreEqual(temp, m.GetTable()); Assert.AreEqual(true, t); }
public void FullBoard() { //Init Application.Model m = new Application.Model(100); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { m.GetTable() [i, j] = i * 4 + j + 1; } } //Test //Assert Assert.Throws <OverflowException>(() => { m.NewItem(); }, "Board is Full"); }