コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 public IList <IShipInfo> CreateMultipleFromFleet(IFleet fleet)
 {
     return(fleet.GetAllShips().Select(ship => new ShipInfo(ship)).ToList <IShipInfo>());
 }