public void RenderMapCheckCorrectlyElementsTest() { FakeMap map = new FakeMap(4, 3, new List <LiveElement>() { new FakeShip(), new FakeShip(), new FakeShip() }); Player player = new Player(map); FakeUserInterface fakeUserInterface = new FakeUserInterface(); Game game = new Game(player, fakeUserInterface); game.RenderMap(); int count = 0; int allCount = 0; for (int i = 0; i < map.Fields.GetLength(0); i++) { for (int j = 0; j < map.Fields.GetLength(1); j++) { allCount++; if (map.Hit(i, j) is HitResult) { count++; } } } Assert.IsTrue(allCount == 12 && count == 9, "The map is rendered fail"); }
public void HitEmptyFieldBattleMapTest() { FakeMap map = new FakeMap(3, new List <LiveElement>()); map.RenderMap(); for (int i = 0; i < map.Fields.GetLength(0); i++) { for (int j = 0; j < map.Fields.GetLength(1); j++) { if (map.Hit(i, j) is MissResult == false) { Assert.Fail("Hit on the map is not working correctly"); } } } }
public void RenderMapCheckWaterTest() { FakeMap map = this.CreateFakeMap(); map.RenderMap(); for (int i = 0; i < map.Fields.GetLength(0); i++) { for (int j = 0; j < map.Fields.GetLength(1); j++) { if (map.Hit(i, j) is MissResult) { Assert.Fail("Render map is failed"); } } } }
public void HitBattleMapTest() { FakeMap map = this.CreateFakeMap(); map.RenderMap(); for (int i = 0; i < map.Fields.GetLength(0); i++) { for (int j = 0; j < map.Fields.GetLength(1); j++) { ShootResult result = map.Hit(i, j); if (result is HitResult == false) { Assert.Fail("Hit on the map is not working correctly"); } } } }
public void HowManyShipsAreThereTest() { FakeMap map = this.CreateFakeMap(); int count = 0; map.RenderMap(); for (int i = 0; i < map.Fields.GetLength(0); i++) { for (int j = 0; j < map.Fields.GetLength(1); j++) { if (map.Hit(i, j) is HitAndSinksResult) { count++; } } } Assert.AreEqual(3, count, "Number of ships is incorrect"); }
public void RenderMapTest() { FakeMap map = new FakeMap(3, new List <LiveElement>() { new FakeShip(), new FakeShip() }); map.RenderMap(); int count = 0; for (int i = 0; i < map.Fields.GetLength(0); i++) { for (int j = 0; j < map.Fields.GetLength(1); j++) { if (map.Hit(i, j) is HitResult) { count++; } } } Assert.AreEqual(6, count, "Render map is failed"); }