Пример #1
0
        public static void Constructor_ExpectedValues()
        {
            // Setup
            var    random                       = new Random(21);
            int    nrOfEngines                  = random.Next();
            double maximumThrustPerEngine       = random.NextDouble();
            double takeOffWeight                = random.NextDouble();
            Angle  pitchAngleGradient           = random.NextAngle();
            Angle  maximumPitchAngle            = random.NextAngle();
            double rollingResistanceCoefficient = random.NextDouble();
            double brakingResistanceCoefficient = random.NextDouble();

            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();

            // Call
            var aircraftData = new AircraftData(nrOfEngines, maximumThrustPerEngine,
                                                takeOffWeight,
                                                pitchAngleGradient, maximumPitchAngle,
                                                rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                aerodynamicsData);

            // Assert
            Assert.AreEqual(nrOfEngines, aircraftData.NrOfEngines);
            Assert.AreEqual(maximumThrustPerEngine, aircraftData.MaximumThrustPerEngine);
            Assert.AreEqual(takeOffWeight, aircraftData.TakeOffWeight);
            Assert.AreEqual(pitchAngleGradient.Degrees, aircraftData.PitchAngleGradient.Degrees);
            Assert.AreEqual(maximumPitchAngle.Degrees, aircraftData.MaximumPitchAngle.Degrees);
            Assert.AreEqual(rollingResistanceCoefficient, aircraftData.RollingResistanceCoefficient);
            Assert.AreEqual(brakingResistanceCoefficient, aircraftData.BrakingResistanceCoefficient);
            Assert.AreSame(aerodynamicsData, aircraftData.AerodynamicsData);
        }
Пример #2
0
        private static IEnumerable <TestCaseData> GetNegativeVelocityTestCases()
        {
            var random = new Random(21);
            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();
            Angle            angleOfAttack    = random.NextAngle();
            double           liftCoefficient  = random.NextDouble();
            double           density          = random.NextDouble();
            double           invalidVelocity  = -random.NextDouble();

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                                            angleOfAttack,
                                                                                            density,
                                                                                            invalidVelocity)))
                         .SetName("CalculateLift"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                                             liftCoefficient,
                                                                                                             density,
                                                                                                             invalidVelocity)))
                         .SetName("CalculateDragWithEngineFailure"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithoutEngineFailure(aerodynamicsData,
                                                                                                                liftCoefficient,
                                                                                                                density,
                                                                                                                invalidVelocity)))
                         .SetName("CalculateDragWithoutEngineFailure"));
        }
Пример #3
0
        private static IEnumerable <TestCaseData> GetInvalidDensityTestCases()
        {
            var random = new Random(21);
            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();
            Angle            angleOfAttack    = random.NextAngle();
            double           liftCoefficient  = random.NextDouble();
            double           invalidDensity   = -random.NextDouble();
            double           velocity         = random.NextDouble();
            double           takeOffWeight    = random.NextDouble();

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                                            angleOfAttack,
                                                                                            invalidDensity,
                                                                                            velocity)))
                         .SetName("CalculateLift - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                                            angleOfAttack,
                                                                                            0,
                                                                                            velocity)))
                         .SetName("CalculateLift - Zero"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                                             liftCoefficient,
                                                                                                             invalidDensity,
                                                                                                             velocity)))
                         .SetName("CalculateDragWithEngineFailure - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                                             liftCoefficient,
                                                                                                             0,
                                                                                                             velocity)))
                         .SetName("CalculateDragWithEngineFailure - Zero"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithoutEngineFailure(aerodynamicsData,
                                                                                                                liftCoefficient,
                                                                                                                invalidDensity,
                                                                                                                velocity)))
                         .SetName("CalculateDragWithoutEngineFailure - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithoutEngineFailure(aerodynamicsData,
                                                                                                                liftCoefficient,
                                                                                                                0,
                                                                                                                velocity)))
                         .SetName("CalculateDragWithoutEngineFailure - Zero"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateStallSpeed(aerodynamicsData,
                                                                                                  takeOffWeight,
                                                                                                  invalidDensity)))
                         .SetName("CalculateStallSpeed - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateStallSpeed(aerodynamicsData,
                                                                                                  takeOffWeight,
                                                                                                  0)))
                         .SetName("CalculateStallSpeed - Zero"));
        }
Пример #4
0
        private static IEnumerable <TestCaseData> GetInvalidLiftCoefficientTestCases()
        {
            var random = new Random(21);
            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();

            yield return(new TestCaseData(aerodynamicsData, -random.NextDouble())
                         .SetName("Lift Coefficient < 0"));

            yield return(new TestCaseData(aerodynamicsData, aerodynamicsData.MaximumLiftCoefficient + random.NextDouble())
                         .SetName("Lift Coefficient > Maximum lift coefficient CLMax"));
        }
Пример #5
0
        public static void CreateAerodynamicsData_Always_ReturnsAerodynamicsData()
        {
            // Call
            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();

            // Assert
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.AspectRatio));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.WingArea));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.ZeroLiftAngleOfAttack.Degrees));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.LiftCoefficientGradient));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.MaximumLiftCoefficient));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.RestDragCoefficientWithoutEngineFailure));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.RestDragCoefficientWithEngineFailure));
            Assert.IsTrue(IsConcreteNonZeroNumber(aerodynamicsData.OswaldFactor));
        }
Пример #6
0
        private static IEnumerable <TestCaseData> GetInvalidValuesForPropertiesLargerOrEqualToZero()
        {
            var              random                       = new Random(21);
            int              nrOfEngines                  = random.Next();
            double           maximumThrustPerEngine       = random.NextDouble();
            double           takeOffWeight                = random.NextDouble();
            Angle            pitchAngleGradient           = random.NextAngle();
            Angle            maximumPitchAngle            = random.NextAngle();
            double           rollingResistanceCoefficient = random.NextDouble();
            double           brakingResistanceCoefficient = random.NextDouble();
            AerodynamicsData aerodynamicsData             = AerodynamicsDataTestFactory.CreateAerodynamicsData();

            const string rollingResistanceCoefficientPropertyName = "rollingResistanceCoefficient";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            -1e-1, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          rollingResistanceCoefficientPropertyName)
                         .SetName($"{rollingResistanceCoefficientPropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            double.NegativeInfinity, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          rollingResistanceCoefficientPropertyName)
                         .SetName($"{rollingResistanceCoefficientPropertyName} NegativeInfinity"));

            const string brakingResistanceCoefficientPropertyName = "brakingResistanceCoefficient";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, -1e-1,
                                                                            aerodynamicsData)),
                                          brakingResistanceCoefficientPropertyName)
                         .SetName($"{brakingResistanceCoefficientPropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, double.NegativeInfinity,
                                                                            aerodynamicsData)),
                                          brakingResistanceCoefficientPropertyName)
                         .SetName($"{brakingResistanceCoefficientPropertyName} NegativeInfinity"));
        }
Пример #7
0
        private static IEnumerable <TestCaseData> GetInvalidConcreteValuesForProperties()
        {
            var              random                       = new Random(21);
            int              nrOfEngines                  = random.Next();
            double           maximumThrustPerEngine       = random.NextDouble();
            double           takeOffWeight                = random.NextDouble();
            Angle            pitchAngleGradient           = random.NextAngle();
            Angle            maximumPitchAngle            = random.NextAngle();
            double           rollingResistanceCoefficient = random.NextDouble();
            double           brakingResistanceCoefficient = random.NextDouble();
            AerodynamicsData aerodynamicsData             = AerodynamicsDataTestFactory.CreateAerodynamicsData();

            const string maximumThrustPerEnginePropertyName = "maximumThrustPerEngine";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, double.NaN, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumThrustPerEnginePropertyName)
                         .SetName($"{maximumThrustPerEnginePropertyName} NaN"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, double.PositiveInfinity, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumThrustPerEnginePropertyName)
                         .SetName($"{maximumThrustPerEnginePropertyName} PositiveInfinity"));

            const string takeOffWeightPropertyName = "takeOffWeight";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, double.NaN,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          takeOffWeightPropertyName)
                         .SetName($"{takeOffWeightPropertyName} NaN"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, double.PositiveInfinity,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          takeOffWeightPropertyName)
                         .SetName($"{takeOffWeightPropertyName} PositiveInfinity"));

            const string pitchAngleGradientPropertyName = "pitchAngleGradient";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            Angle.FromRadians(double.NaN), maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          pitchAngleGradientPropertyName)
                         .SetName($"{pitchAngleGradientPropertyName} NaN"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            Angle.FromRadians(double.PositiveInfinity), maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          pitchAngleGradientPropertyName)
                         .SetName($"{pitchAngleGradientPropertyName} PositiveInfinity"));

            const string maximumPitchAnglePropertyName = "maximumPitchAngle";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, Angle.FromRadians(double.NaN),
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumPitchAnglePropertyName)
                         .SetName($"{maximumPitchAnglePropertyName} NaN"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, Angle.FromRadians(double.PositiveInfinity),
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumPitchAnglePropertyName)
                         .SetName($"{maximumPitchAnglePropertyName} PositiveInfinity"));

            const string rollingResistanceCoefficientPropertyName = "rollingResistanceCoefficient";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            double.NaN, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          rollingResistanceCoefficientPropertyName)
                         .SetName($"{rollingResistanceCoefficientPropertyName} NaN"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            double.PositiveInfinity, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          rollingResistanceCoefficientPropertyName)
                         .SetName($"{rollingResistanceCoefficientPropertyName} PositiveInfinity"));

            const string brakingResistanceCoefficientPropertyName = "brakingResistanceCoefficient";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, double.NaN,
                                                                            aerodynamicsData)),
                                          brakingResistanceCoefficientPropertyName)
                         .SetName($"{brakingResistanceCoefficientPropertyName} NaN"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, double.PositiveInfinity,
                                                                            aerodynamicsData)),
                                          brakingResistanceCoefficientPropertyName)
                         .SetName($"{brakingResistanceCoefficientPropertyName} PositiveInfinity"));
        }
Пример #8
0
        private static IEnumerable <TestCaseData> GetInvalidValuesForPropertiesLessThanZero()
        {
            var              random                       = new Random(21);
            int              nrOfEngines                  = random.Next();
            double           maximumThrustPerEngine       = random.NextDouble();
            double           takeOffWeight                = random.NextDouble();
            Angle            pitchAngleGradient           = random.NextAngle();
            Angle            maximumPitchAngle            = random.NextAngle();
            double           rollingResistanceCoefficient = random.NextDouble();
            double           brakingResistanceCoefficient = random.NextDouble();
            AerodynamicsData aerodynamicsData             = AerodynamicsDataTestFactory.CreateAerodynamicsData();

            const string nrOfenginesPropertyName = "nrOfEngines";

            yield return(new TestCaseData(new Action(() => new AircraftData(-1, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          nrOfenginesPropertyName)
                         .SetName($"{nrOfenginesPropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(0, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          nrOfenginesPropertyName)
                         .SetName($"{nrOfenginesPropertyName} Zero"));

            const string maximumThrustPerEnginePropertyName = "maximumThrustPerEngine";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, -1e-1, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumThrustPerEnginePropertyName)
                         .SetName($"{maximumThrustPerEnginePropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, double.NegativeInfinity, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumThrustPerEnginePropertyName)
                         .SetName($"{maximumThrustPerEnginePropertyName} NegativeInfinity"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, 0, takeOffWeight,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumThrustPerEnginePropertyName)
                         .SetName($"{maximumThrustPerEnginePropertyName} Zero"));

            const string takeOffWeightPropertyName = "takeOffWeight";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, -1e-1,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          takeOffWeightPropertyName)
                         .SetName($"{takeOffWeightPropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, double.NegativeInfinity,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          takeOffWeightPropertyName)
                         .SetName($"{takeOffWeightPropertyName} NegativeInfinity"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, 0,
                                                                            pitchAngleGradient, maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          takeOffWeightPropertyName)
                         .SetName($"{takeOffWeightPropertyName} Zero"));

            const string pitchAngleGradientPropertyName = "pitchAngleGradient";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            Angle.FromRadians(-1e-1), maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          pitchAngleGradientPropertyName)
                         .SetName($"{pitchAngleGradientPropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            Angle.FromRadians(double.NegativeInfinity), maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          pitchAngleGradientPropertyName)
                         .SetName($"{pitchAngleGradientPropertyName} NegativeInfinity"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            Angle.FromRadians(0), maximumPitchAngle,
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          pitchAngleGradientPropertyName)
                         .SetName($"{pitchAngleGradientPropertyName} Zero"));

            const string maximumPitchAnglePropertyName = "maximumPitchAngle";

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, Angle.FromRadians(-1e-1),
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumPitchAnglePropertyName)
                         .SetName($"{maximumPitchAnglePropertyName} Negative"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, Angle.FromRadians(double.NegativeInfinity),
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumPitchAnglePropertyName)
                         .SetName($"{maximumPitchAnglePropertyName} NegativeInfinity"));

            yield return(new TestCaseData(new Action(() => new AircraftData(nrOfEngines, maximumThrustPerEngine, takeOffWeight,
                                                                            pitchAngleGradient, Angle.FromRadians(0),
                                                                            rollingResistanceCoefficient, brakingResistanceCoefficient,
                                                                            aerodynamicsData)),
                                          maximumPitchAnglePropertyName)
                         .SetName($"{maximumPitchAnglePropertyName} Zero"));
        }