public void Board_WhenGridGenerated_ReturnThirteenOccupiedSegments() { // Arrange var ships = new List <IShip> { new BattleShip(1), new Destroyer(2), new Destroyer(3) }; var occupiedSegments = shipRandomiser.GetRandomisedShipCoordinates(ships).Count; // Act var result = gridGenerator.NumberOfOccupiedSegments; // Assert Assert.AreNotEqual(occupiedSegments, result); }
private void UpdateSegmentationGridWithShips() { SortedDictionary <Coordinate, Segment> segments = shipRandomiser.GetRandomisedShipCoordinates(ships); segmentation.UpdateSegmentRange(segments); this.NumberOfOccupiedSegments = segmentation.GetSegments().Count(q => !q.Value.IsEmpty); }
public void GetRandomisedShipCoordinates_GetNumberOfBattleships_ReturnOne() { // Arrange int numberOfBattleships = 1; List <IShip> ships = new List <IShip> { new BattleShip(1), new Destroyer(2), new Destroyer(3) }; // Act SortedDictionary <Coordinate, Segment> segments = shipRandomiser.GetRandomisedShipCoordinates(ships); // Make sure that the HashCodes are different IEnumerable <IShip> battleship = segments.Where(s => s.Value.Ship.ShipChar == BattleShipCode).Select(s => s.Value.Ship); int counter = battleship.GroupBy(q => q.GetHashCode()).Count(); // Assert Assert.AreEqual(counter, numberOfBattleships); }