public IList <IShipInfo> CreateMultipleFromFleet(IFleet fleet) { IList <IShipInfo> shipInfoList = new List <IShipInfo>(); IList <IShip> shipList = fleet.GetAllShips(); /* Go through each ship in the ship list of the fleet and create a ship info object.*/ foreach (var ship in shipList) { shipInfoList.Add(new ShipInfo(ship)); } return(shipInfoList); }
public IList <IShipInfo> CreateMultipleFromFleet(IFleet fleet) { IList <IShip> ships = fleet.GetAllShips(); List <IShipInfo> shipInfo = new List <IShipInfo>(); if (ships != null) { for (int i = 0; i < ships.Count; i++) { shipInfo.Add(new ShipInfo(ships[i])); } } return(shipInfo); }
public void CreateMultipleFromFleet_ConvertsAllShipsOfTheFleetToShipInfos() { //Arrange IFleet fleet = ArrangeFleet(); //Act IList <IShipInfo> shipInfos = _factory.CreateMultipleFromFleet(fleet); //Assert Assert.That(shipInfos, Is.Not.Null, "No list of ship infos is returned."); var allShips = fleet.GetAllShips(); Assert.That(shipInfos.Count, Is.EqualTo(allShips.Count), "The number of ship infos should be equal to the number of ships in the fleet."); foreach (IShip ship in allShips) { AssertShipInfoExistsForShip(ship, shipInfos); } }
public IList <IShipInfo> CreateMultipleFromFleet(IFleet fleet) { return(fleet.GetAllShips().Select(ship => new ShipInfo(ship)).ToList <IShipInfo>()); }