public void testStopsWrongUom() { starship.consumptiondetail.uom = Enums.UOM.Invalid; starship.consumptiondetail.Time = 1; calculator.stops(starship, 0); Assert.AreEqual(0, starship.stops); }
/// <summary> /// Searches the list of starships and calculate the number of stops needed to cover a certain distance /// Categorizes the starships with valid and invalid data /// Writes each category seperately, and the amount of stops needed for each starship with valid data /// </summary> /// <param name="distance">The distance that needs to be covered by the starships</param> public void Execute(long distance) { if (starships == null) { throw new ArgumentNullException(nameof(starships)); } foreach (StarShip starship in starships.Where(x => x.MGLTConverted != 0).ToList()) { { calculator.stops(starship, distance); writer.data(starship.name + ": " + starship.stops); } } if (starships.Where(x => x.MGLTConverted == 0).Count() != 0) { writer.Info("Starships with invalid data:"); starships.Where(x => x.MGLTConverted == 0).ToList().ForEach((x) => writer.data(x.name)); } writer.Info("Stops has been calculated successfully"); writer.Info("Enter new distance or \"Exit\" to quit"); }