示例#1
0
        /// <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);
            }
        }
示例#2
0
        public void testConsumptionDetailUOMDay()
        {
            IStarship         starshipbase     = starship;
            IStarshipMeasures starshipmeasures = starship;

            starshipbase.consumables = "1 Day";
            Assert.AreEqual(starshipmeasures.consumptiondetail.uom, Swapi.Program.Enums.UOM.Day);
        }
示例#3
0
        public void testConsumptionDetailWrongUom()
        {
            IStarship         starshipbase     = starship;
            IStarshipMeasures starshipmeasures = starship;

            starshipbase.consumables = "1 dd";
            Assert.AreEqual(starshipmeasures.consumptiondetail.uom, Swapi.Program.Enums.UOM.Invalid);
        }
示例#4
0
        public void testConsumptionDetailInvalidConsumableForTime()
        {
            IStarship         starshipbase     = starship;
            IStarshipMeasures starshipmeasures = starship;

            starshipbase.consumables = "";
            Assert.AreEqual(starshipmeasures.consumptiondetail.Time, -1);
        }
示例#5
0
        public void testMgltConversion()
        {
            IStarship         starshipbase     = starship;
            IStarshipMeasures starshipmeasures = starship;

            starshipbase.MGLT = "100";
            Assert.AreEqual(starshipmeasures.MGLTConverted, 100);
        }
示例#6
0
        public void testMgltUnknown()
        {
            IStarship         starshipbase     = starship;
            IStarshipMeasures starshipmeasures = starship;

            starshipbase.MGLT = "Unknown";


            Assert.AreEqual(starshipmeasures.MGLTConverted, 0);
        }
示例#7
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));
        }
示例#8
0
 public void Init()
 {
     calculator = container.GetInstance <IStopsCalculator>();
     starship   = container.GetInstance <IStarshipMeasures>();
 }
示例#9
0
 public void Init()
 {
     starship         = container.GetInstance <StarShip>();
     starshipbase     = starship;
     starshipmeasures = starship;
 }