public void TakeShootTest_PointOutOfField() { Field field = new Field_Valid_OneShip(); field.SetRandomShips(); field.TakeShoot(new Point(-1)); }
public void CellsForEnemyTest_RandomValues() { Field field = new Field_Valid_OneShip(); Random rnd = new Random(); for (int i = 0; i < field.FieldSize; i++) { for (int j = 0; j < field.FieldSize; j++) { do { field.Cells[i, j] = (CellStatus)rnd.Next(Enum.GetNames(typeof(CellStatus)).Length); } while (field.Cells[i, j] != CellStatus.Hidden); } } for (int i = 0; i < field.FieldSize; i++) { for (int j = 0; j < field.FieldSize; j++) { if (field.Cells[i, j] == CellStatus.Alive || field.Cells[i, j] == CellStatus.NotSet) { Assert.AreEqual(CellStatus.Hidden, field.CellsForEnemy[i, j]); } else { Assert.AreEqual(field.Cells[i, j], field.CellsForEnemy[i, j]); } } } }
public void TakeShootTest_AleadyShooted() { Field field = new Field_Valid_OneShip(); field.SetRandomShips(); field.TakeShoot(new Point(0)); field.TakeShoot(new Point(0)); }
public void TakeShootTest_Hit() { Field field = new Field_Valid_OneShip(); Point point = new Point(1); Ship ship = Ship.CreateNewShip(point, Orientation.Vertical, field.Ships[0].Id, field.Ships[0].Size); field.SetShip(ship); Assert.AreEqual(ShotResult.Hit, field.TakeShoot(point)); Assert.AreEqual(CellStatus.Hit, field.Cells[point.Y, point.X]); }
public void DeleteShipFromFieldTest_ValidShip() { Field field = new Field_Valid_OneShip(); field.SetRandomShips(); field.DeleteShipFromField(field.Ships[0].Id); foreach (var cell in field.Cells) { Assert.AreEqual(CellStatus.NotSet, cell); } }
public void GetShipTest_ValidTest() { Field field = new Field_Valid_OneShip(); field.SetShip(Ship.CreateNewShip( new Point(1), Orientation.Vertical, field.Ships[0].Id, field.Ships[0].Size) ); ReferenceEquals(field.Ships[0], field.GetShip(new Point(1))); }
public void GetShipTest_NullTest() { Field field = new Field_Valid_OneShip(); field.SetShip(Ship.CreateNewShip( new Point(1), Orientation.Vertical, field.Ships[0].Id, field.Ships[0].Size) ); Assert.IsNull(field.GetShip(new Point(0))); }
public void SetShipTest_InvalidShipId() { Field field = new Field_Valid_OneShip(); Ship ship = Ship.CreateNewShip( field.Ships[0].StartPosition, Orientation.Horizontal, field.Ships[0].Id + 1, field.Ships[0].Size ); field.SetShip(ship); }
public void CellsForEnemyTest_Hidden() { Field field = new Field_Valid_OneShip(); foreach (var cell in field.CellsForEnemy) { Assert.AreEqual(CellStatus.Hidden, cell); } for (int i = 0; i < field.FieldSize; i++) { for (int j = 0; j < field.FieldSize; j++) { field.Cells[i, j] = CellStatus.Alive; } } foreach (var cell in field.CellsForEnemy) { Assert.AreEqual(CellStatus.Hidden, cell); } }
public void TakeShootTest_NotSetShip() { Field field = new Field_Valid_OneShip(); field.TakeShoot(new Point(0)); }
public void DeleteShipFromFieldTest_NotSetShip() { Field field = new Field_Valid_OneShip(); field.DeleteShipFromField(field.Ships[0].Id); }
public void DeleteShipFromFieldTest_InvalidShipId() { Field field = new Field_Valid_OneShip(); field.DeleteShipFromField(field.Ships[0].Id + 1); }