/// <summary> /// Converts the consumables time into hours /// The need to convert all consumables into hours is because MGLT is represented by hours /// </summary> /// <param name="starship">Represent the current starship</param> /// <returns>Converted time into hours depending on the unit of measure</returns> public long hours(IStarshipMeasures starship) { if (starship.consumptiondetail == null) { throw new ArgumentNullException(nameof(starship.consumptiondetail)); } switch (starship.consumptiondetail.uom) { case Enums.UOM.Hour: return(starship.consumptiondetail.Time); case Enums.UOM.Day: return(starship.consumptiondetail.Time * 24); case Enums.UOM.Week: return(starship.consumptiondetail.Time * 168); case Enums.UOM.Month: return(starship.consumptiondetail.Time * 730); case Enums.UOM.Year: return(starship.consumptiondetail.Time * 8760); default: return(0); } }
public void testConsumptionDetailUOMDay() { IStarship starshipbase = starship; IStarshipMeasures starshipmeasures = starship; starshipbase.consumables = "1 Day"; Assert.AreEqual(starshipmeasures.consumptiondetail.uom, Swapi.Program.Enums.UOM.Day); }
public void testConsumptionDetailWrongUom() { IStarship starshipbase = starship; IStarshipMeasures starshipmeasures = starship; starshipbase.consumables = "1 dd"; Assert.AreEqual(starshipmeasures.consumptiondetail.uom, Swapi.Program.Enums.UOM.Invalid); }
public void testConsumptionDetailInvalidConsumableForTime() { IStarship starshipbase = starship; IStarshipMeasures starshipmeasures = starship; starshipbase.consumables = ""; Assert.AreEqual(starshipmeasures.consumptiondetail.Time, -1); }
public void testMgltConversion() { IStarship starshipbase = starship; IStarshipMeasures starshipmeasures = starship; starshipbase.MGLT = "100"; Assert.AreEqual(starshipmeasures.MGLTConverted, 100); }
public void testMgltUnknown() { IStarship starshipbase = starship; IStarshipMeasures starshipmeasures = starship; starshipbase.MGLT = "Unknown"; Assert.AreEqual(starshipmeasures.MGLTConverted, 0); }
/// <summary> /// Calculates the number of stops for a starship /// Divides the distance parameter by, the maximum number of hours needed for a starship resuply multiplied by the MGLT /// </summary> /// <param name="starship">Represents the current starship its stops is being calculated</param> /// <param name="distance">Represents the distance that needs to be covered</param> public void stops(IStarshipMeasures starship, long distance) { if (starship.consumptiondetail.uom == Enums.UOM.Invalid || starship.consumptiondetail.Time == -1 || starship.MGLTConverted == 0) { starship.stops = 0; return; } starship.stops = (long)(distance / (this.hours(starship) * starship.MGLTConverted)); }
public void Init() { calculator = container.GetInstance <IStopsCalculator>(); starship = container.GetInstance <IStarshipMeasures>(); }
public void Init() { starship = container.GetInstance <StarShip>(); starshipbase = starship; starshipmeasures = starship; }