public void Throws_If_ElecHobbs_Null_But_Req()
        {
            var opts  = new AircraftOptions(true, false, false, false, false, false);
            var times = new AircraftTimes(0m, 0m, 0m, 0m, null, 0m, 0m, 0, _default);

            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, times, opts));
        }
        public void Throws_If_Cycles_Given_But_NotReq()
        {
            var opts  = new AircraftOptions(false, false, false, false, false, false);
            var times = new AircraftTimes(0m, 0m, 0m, 0m, null, null, null, 0, _default);

            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, times, opts));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a zero time twin Aircraft with all optional meters set to true.
        /// </summary>
        public static Aircraft ZeroTimeTwin(AircraftTotalTarget tgt)
        {
            var opts  = AllMeterTwinOptions();
            var times = new AircraftTimes(0, 0, 0, 0, 0m, 0m, 0m, 0, tgt);

            times.SetTwinTimes(0m, 0m, 0m);
            return(new Aircraft("", "", 0, 0, times, opts));
        }
        public void Throws_If_Airtime_Given_But_NotReq()
        {
            var opts  = new AircraftOptions(false, false, false, false, false, false);
            var curr  = new AircraftTimes(0m, 0m, 0m, 0m, null, 0m, null, null, _default);
            var total = new AircraftTimes(0m, 0m, 0m, 0m, null, null, 0m, null, _default);

            // Check both Curr and Total
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, curr, opts));
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, total, opts));
        }
        public void Throws_If_Airtime_Null_But_Req()
        {
            var opts    = new AircraftOptions(false, true, false, false, false, false);
            var noCurr  = new AircraftTimes(0m, 0m, 0m, 0m, 0m, null, 0m, 0, _default);
            var noTotal = new AircraftTimes(0m, 0m, 0m, 0m, 0m, 0m, null, 0, _default);

            // Check both Curr and Total
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, noCurr, opts));
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, noTotal, opts));
        }
        public void Throws_On_Invalid_Target(AircraftTotalTarget invalidTgt)
        {
            // Create barebones single-engine AircraftOptions
            // IMPORTANT - Engine1Current is always a valid target.
            var opts  = new AircraftOptions(false, false, false, false, false, false);
            var times = new AircraftTimes(0m, 0m, 0m, 0m, null, null, null, null,
                                          invalidTgt);

            // Create an aircraft that does not ever have Airtime or ElecHobbs data
            // while also passing in targets pointing to those properties.
            Assert.Throws <InvalidTargetException>(() => new Aircraft("", "", 0, 0, times, opts));
        }
Ejemplo n.º 7
0
        public void Cannot_Edit_Times_While_Dispatched()
        {
            // Create Aircraft and dispatch it
            var ac = AircraftBuilder.ZeroTimeTwin(AircraftTotalTarget.Engine1Current);

            ac.Activate();
            ac.Dispatch();

            var newTimes = new AircraftTimes(0m, 0m, 0m, 0m, 0m, 0m, 0m, 0, AircraftTotalTarget.Engine1Current);

            Assert.Throws <EditWhileDispatchedException>(() => ac.SetConfiguration(newTimes, ac.Options));
        }
Ejemplo n.º 8
0
        public void Throws_If_Twin_But_Null_On_Creation()
        {
            var opts  = new AircraftOptions(false, false, false, false, true, false);
            var times = new AircraftTimes(0m, 0m, 0m, 0m, null, null, null, null,
                                          AircraftTotalTarget.Engine1Current);

            // Start with eng2Curr null, then try each other (decimals not supported in InlineData)
            // eng2Curr
            times.SetTwinTimes(null, 0m, 0m);
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, times, opts));
            // eng2Total
            times.SetTwinTimes(0m, null, 0m);
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, times, opts));
            // prop2Total
            times.SetTwinTimes(0m, 0m, null);
            Assert.Throws <InvalidTimesException>(() => new Aircraft("", "", 0, 0, times, opts));
        }
Ejemplo n.º 9
0
        public void Throws_On_Lesser_Time()
        {
            // Boilerplate for a standard twin with all meters - Have all at a baseline of 0
            var ac   = AircraftBuilder.ZeroTimeTwin(AircraftTotalTarget.Engine1Current);
            var opts = AircraftBuilder.AllMeterTwinOptions();

            var times = new AircraftTimes(1m, 1m, 1m, 1m, 1m, 1m, 1m, 1, AircraftTotalTarget.Engine1Current);

            times.SetTwinTimes(0m, 0m, 0m);
            ac.SetConfiguration(times, opts);

            // Create a shifting array of times to assign, each one setting a single times
            // value to 1 so we can test all possible times we send in lesser data.
            // Picture it like 1, 0, 0, 0, 0 with the 1 moving each row (again..no decimals in inline data)
            var arr = new decimal[5, 5];

            for (var i = 0; i < 5; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    if (j == i)
                    {
                        arr[i, j] = 2;
                    }
                    else
                    {
                        arr[i, j] = 0;
                    }
                }
            }

            var row = 4;

            while (row >= 0)
            {
                // Attempt to update the aircraft with 1 zero value each time
                Assert.Throws <TimesUpdateException>(() => ac.UpdateTimes(arr[row, 0], arr[row, 1],
                                                                          arr[row, 2], arr[row, 3], (int)arr[row, 4]));
                row--;
            }
        }
 public AircraftTimesChangedDomainEvent(AircraftTimes times) => AircraftTimes = times;