public void AvaliableMove_PawnW() { // setup environment for test GameController.StartGame (); List<Piece> PL1 = GameController.Players [0].PieceList; List<Piece> PL2 = GameController.Players [1].PieceList; for (int i = 0; i < PL1.Count; i++) { PL1 [i].isDead = true; PL1 [i].X = -1; PL1 [i].Y = -1; PL2 [i].isDead = true; PL2 [i].X = -1; PL2 [i].Y = -1; } //test piece Piece testPawn = new Pawn (1, 6, false); testPawn.AvailableMoves (); Assert.IsTrue (hasContain (testPawn.AvaliableMove_X, testPawn.AvaliableMove_Y, 1, 5)); Assert.IsTrue (hasContain (testPawn.AvaliableMove_X, testPawn.AvaliableMove_Y, 1, 4)); Piece testPawn2 = new Pawn (4, 5, false); testPawn2.AvailableMoves (); Assert.IsTrue (hasContain (testPawn2.AvaliableMove_X, testPawn2.AvaliableMove_Y, 4, 4)); }
public void Attack_Pawn() { // setup environment for test GameController.StartGame (); List<Piece> PL1 = GameController.Players [0].PieceList; List<Piece> PL2 = GameController.Players [1].PieceList; for (int i = 0; i < PL1.Count; i++) { PL1 [i].isDead = true; PL1 [i].X = -1; PL1 [i].Y = -1; PL2 [i].isDead = true; PL2 [i].X = -1; PL2 [i].Y = -1; } UtilityFunctions.CheckAvaiMoveOfAllPieces (); //test piece Piece testPawn = new Pawn (2, 2, true); Piece testPawn1 = null; Piece testPawn2 = null; //get a pwan from write player for test attack foreach (Piece p in PL1) { if (p.type == PieceType.Pawn) { testPawn1 = p; break; } } testPawn1.isDead = false; testPawn1.X = 1; testPawn1.Y = 3; testPawn.AvailableMoves (); testPawn.Move (1, 3); Assert.AreEqual (true, testPawn1.isDead); //get a pwan from black player for test attack foreach (Piece p in PL2) { if (p.type == PieceType.Pawn) { testPawn2 = p; break; } } testPawn2.isDead = false; testPawn2.X = 0; testPawn2.Y = 4; testPawn.AvailableMoves (); testPawn.Move (0, 4); Assert.AreEqual (false, testPawn2.isDead); }