public void HitBattleshipResultTest() { Battleship battleship = new Battleship(); ShootResult hitResult = battleship.Hit(); Assert.IsTrue(hitResult is HitResult, "The type of Hit is incorrect."); }
public void GetPathToIconAfterHitTest() { Battleship battleship = new Battleship(); battleship.Hit(); string path = battleship.NameOfCurrentIcon; Assert.AreEqual(Battleship.BATTLESHIP_FILENAME, path, "Icon to the battleship is incorrect."); }
public void Hit5TimesAndSinksTest() { Battleship battleship = new Battleship(); ShootResult typeOfHit = null; for (int i = 0; i < Battleship.LIFE_OF_BATTLESHIP; i++) { typeOfHit = battleship.Hit(); } Assert.IsTrue(typeOfHit is HitAndSinksResult, "The type of Hit is incorrect."); }
public void TestBattleshipHit() { List <Coordinate> battleshipCoords = new List <Coordinate> { new Coordinate(0, 0), new Coordinate(0, 1), new Coordinate(0, 2) }; Battleship battleship = new Battleship(battleshipCoords); // Test hitting battleship with invalid coordinates Assert.ThrowsException <ArgumentException>(() => battleship.Hit(new Coordinate(-1, -1))); Assert.ThrowsException <ArgumentException>(() => battleship.Hit(new Coordinate(0, 3))); Assert.ThrowsException <ArgumentException>(() => battleship.Hit(new Coordinate(1, 0))); battleship.Hit(new Coordinate(0, 0)); battleship.Hit(new Coordinate(0, 1)); battleship.Hit(new Coordinate(0, 2)); Assert.IsTrue(battleship.IsSunk()); }