コード例 #1
0
        public static void Calculate_ContinuedTakeOffDistanceCalculatorThrowsCalculatorException_ThrowsCalculatorException()
        {
            // Setup
            var random = new Random(21);

            AircraftData        aircraftData              = AircraftDataTestFactory.CreateRandomAircraftData();
            var                 integrator                = Substitute.For <IIntegrator>();
            int                 nrOfFailedEngines         = random.Next();
            double              density                   = random.NextDouble();
            double              gravitationalAcceleration = random.NextDouble();
            CalculationSettings calculationSettings       = CalculationSettingsTestFactory.CreateDistanceCalculatorSettings();

            var calculatorException = new CalculatorException();

            var continuedTakeOffDistanceCalculator = Substitute.For <IDistanceCalculator>();

            continuedTakeOffDistanceCalculator.Calculate().Throws(calculatorException);

            var distanceCalculatorFactory = Substitute.For <IDistanceCalculatorFactory>();

            distanceCalculatorFactory.CreateAbortedTakeOffDistanceCalculator(null, null, 0, 0, null).ReturnsForAnyArgs(continuedTakeOffDistanceCalculator);

            var aggregatedCalculator = new Calculator.AggregatedDistanceCalculator.AggregatedDistanceCalculator(distanceCalculatorFactory);

            // Call
            TestDelegate call = () => aggregatedCalculator.Calculate(aircraftData, integrator, nrOfFailedEngines, density, gravitationalAcceleration, calculationSettings);

            // Assert
            var exception = Assert.Throws <CalculatorException>(call);

            Assert.AreSame(calculatorException, exception);
        }
コード例 #2
0
        public void runSelfTest_UpdateTransponderData()
        {
            List <string> listOfStrings = new List <string>();
            string        testerString  = "ATR423;39045;12932;14000;20151006213456789";
            string        testerString1 = "ATR424;39045;12932;14000;20151006213456789";

            listOfStrings.Add(testerString);
            listOfStrings.Add(testerString1);
            //  Decodes into list = _AirCraft

            // Explit Old data from last tick
            AircraftData aircraftDataNew2 = new AircraftData("FlIGHT02", 0002, 00002, 00002, new TimeStamp(0002, 02, 2, 2, 2, 2, 2));
            AircraftData aircraftDataNew3 = new AircraftData("FlIGHT03", 0003, 00003, 00003, new TimeStamp(0003, 03, 3, 3, 3, 3, 3));

            List <AircraftData> toMock = new List <AircraftData>();

            toMock.Add(aircraftDataNew3);
            toMock.Add(aircraftDataNew2);

            _utility.CloneList(toMock).ReturnsForAnyArgs(toMock);
            _utility.Speed(aircraftDataNew3, aircraftDataNew2).ReturnsForAnyArgs(5);
            _utility.CalculateDegree(aircraftDataNew2, aircraftDataNew2).ReturnsForAnyArgs(300);

            //_uut.UpdateTransponderData(listOfStrings);
            _reciever.TransponderDataReady += Raise.EventWith(new RawTransponderDataEventArgs(listOfStrings));

            Assert.AreEqual(numberOfEventTriggered, 1);

            Assert.That(_uut._Aircrafts[0].Tag == "ATR423" && _uut._Aircrafts[0].Speed == 5 && _uut._Aircrafts[0].Coords == 300);
            Assert.That(_uut._Aircrafts[1].Tag == "ATR424" && _uut._Aircrafts[0].Speed == 5 && _uut._Aircrafts[0].Coords == 300);
        }
コード例 #3
0
 internal static List <AircraftData> PostAircraftData(AircraftData aircraftData)
 {
     using (var context = new AirportInventoryEntities())
     {
         Aircraft newAircraft = new Aircraft()
         {
             Aircraft_No = aircraftData.aircraft_no,
             Airline     = aircraftData.airline
         };
         context.Aircrafts.Add(newAircraft);
         context.SaveChanges();
         var aircraftList = context.Aircrafts.
                            Where(h => 1 == 1)
                            .Select(x => new AircraftData
         {
             aircraft_id = x.AircraftId,
             airline     = x.Airline,
             aircraft_no = x.Aircraft_No,
         }).ToList();
         if (aircraftList != null)
         {
             return(aircraftList);
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #4
0
        public void runSelfTest_InsertSpeedWhereOldListIsLess()
        {
            // After this test, all the new objects should have the speed of the old objects

            AircraftData aircraftDataOld1 = new AircraftData("FlIGHT01", 0001, 00001, 00001, new TimeStamp(0001, 01, 1, 1, 1, 1, 1));
            AircraftData aircraftDataOld2 = new AircraftData("FlIGHT02", 0002, 00002, 00002, new TimeStamp(0002, 02, 2, 2, 2, 2, 2));

            AircraftData aircraftDataNew1 = new AircraftData("FlIGHT01", 0001, 00001, 00001, new TimeStamp(0001, 01, 1, 1, 1, 1, 1));
            AircraftData aircraftDataNew2 = new AircraftData("FlIGHT02", 0002, 00002, 00002, new TimeStamp(0002, 02, 2, 2, 2, 2, 2));
            AircraftData aircraftDataNew3 = new AircraftData("FlIGHT03", 0003, 00003, 00003, new TimeStamp(0003, 03, 3, 3, 3, 3, 3));


            List <AircraftData> oldFakeList = new List <AircraftData>();

            oldFakeList.Add(aircraftDataOld1);
            oldFakeList.Add(aircraftDataOld2);


            List <AircraftData> newFakeList = new List <AircraftData>();

            newFakeList.Add(aircraftDataNew1);
            newFakeList.Add(aircraftDataNew2);
            newFakeList.Add(aircraftDataNew3);

            _utility.Speed(aircraftDataNew3, aircraftDataNew1).ReturnsForAnyArgs(5);
            _utility.CalculateDegree(aircraftDataNew1, aircraftDataNew1).ReturnsForAnyArgs(300);

            _uut.InsertSpeedAndCourse(oldFakeList, newFakeList);


            Assert.That(newFakeList[0].Speed == 5 && newFakeList[0].Coords == 300);
            Assert.That(newFakeList[1].Speed == 5 && newFakeList[1].Coords == 300);
        }
コード例 #5
0
        public KernelValidationError Validate(AircraftData aircraftData,
                                              double density,
                                              double gravitationalAcceleration,
                                              int nrOfFailedEngines)
        {
            if (aircraftData == null)
            {
                throw new ArgumentNullException(nameof(aircraftData));
            }

            var validationError = KernelValidationError.None;

            if (density <= 0)
            {
                validationError |= KernelValidationError.InvalidDensity;
            }

            if (gravitationalAcceleration <= 0)
            {
                validationError |= KernelValidationError.InvalidGravitationalAcceleration;
            }

            if (nrOfFailedEngines >= aircraftData.NrOfEngines)
            {
                validationError |= KernelValidationError.InvalidNrOfFailedEngines;
            }

            return(validationError);
        }
コード例 #6
0
        /// <summary>
        /// Creates a new instance of <see cref="AircraftDataTabViewModel"/>.
        /// </summary>
        /// <param name="aircraftData">The <see cref="AircraftData"/> to create the view model for.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="aircraftData"/> is <c>null</c>.</exception>
        public AircraftDataTabViewModel(AircraftData aircraftData)
        {
            if (aircraftData == null)
            {
                throw new ArgumentNullException(nameof(aircraftData));
            }

            this.aircraftData = aircraftData;

            TakeOffWeight     = aircraftData.TakeOffWeight;
            PitchGradient     = aircraftData.PitchGradient;
            MaximumPitchAngle = aircraftData.MaximumPitchAngle;

            WingSurfaceArea = aircraftData.WingSurfaceArea;
            AspectRatio     = aircraftData.AspectRatio;
            OswaldFactor    = aircraftData.OswaldFactor;

            MaximumLiftCoefficient  = aircraftData.MaximumLiftCoefficient;
            LiftCoefficientGradient = aircraftData.LiftCoefficientGradient;
            ZeroLiftAngleOfAttack   = aircraftData.ZeroLiftAngleOfAttack;

            RestDragCoefficient = aircraftData.RestDragCoefficient;
            RestDragCoefficientWithEngineFailure = aircraftData.RestDragCoefficientWithEngineFailure;

            RollResistanceCoefficient           = aircraftData.RollResistanceCoefficient;
            RollResistanceWithBrakesCoefficient = aircraftData.RollResistanceWithBrakesCoefficient;
        }
コード例 #7
0
        public static void CreateAircraftData_Always_ReturnsAircraftData()
        {
            // Call
            AircraftData data = AircraftDataTestFactory.CreateRandomAircraftData();

            // Assert
            Assert.IsTrue(IsConcreteNonZeroNumber(data.NrOfEngines));
            Assert.IsTrue(IsConcreteNonZeroNumber(data.MaximumThrustPerEngine));
            Assert.IsTrue(IsConcreteNonZeroNumber(data.TakeOffWeight));
            Assert.IsTrue(IsConcreteNonZeroNumber(data.PitchAngleGradient.Degrees));
            Assert.IsTrue(IsConcreteNonZeroNumber(data.MaximumPitchAngle.Degrees));
            Assert.IsTrue(IsConcreteNonZeroNumber(data.RollingResistanceCoefficient));
            Assert.IsTrue(IsConcreteNonZeroNumber(data.BrakingResistanceCoefficient));

            AerodynamicsData aerodynamicsData = data.AerodynamicsData;

            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));
        }
コード例 #8
0
        public static void Constructor_ExpectedValues()
        {
            // Setup
            var data = new AircraftData();

            // Call
            var viewModel = new AircraftDataTabViewModel(data);

            // Assert
            Assert.That(viewModel, Is.InstanceOf <ITabViewModel>());
            Assert.That(viewModel, Is.InstanceOf <ViewModelBase>());
            Assert.That(viewModel.TabName, Is.EqualTo("Aircraft data"));

            Assert.That(viewModel.TakeOffWeight, Is.EqualTo(data.TakeOffWeight));
            Assert.That(viewModel.PitchGradient, Is.EqualTo(data.PitchGradient));
            Assert.That(viewModel.MaximumPitchAngle, Is.EqualTo(data.MaximumPitchAngle));

            Assert.That(viewModel.WingSurfaceArea, Is.EqualTo(data.WingSurfaceArea));
            Assert.That(viewModel.AspectRatio, Is.EqualTo(data.AspectRatio));
            Assert.That(viewModel.OswaldFactor, Is.EqualTo(data.OswaldFactor));

            Assert.That(viewModel.MaximumLiftCoefficient, Is.EqualTo(data.MaximumLiftCoefficient));
            Assert.That(viewModel.LiftCoefficientGradient, Is.EqualTo(data.LiftCoefficientGradient));
            Assert.That(viewModel.ZeroLiftAngleOfAttack, Is.EqualTo(data.ZeroLiftAngleOfAttack));

            Assert.That(viewModel.RestDragCoefficientWithEngineFailure, Is.EqualTo(data.RestDragCoefficientWithEngineFailure));
            Assert.That(viewModel.RestDragCoefficient, Is.EqualTo(data.RestDragCoefficient));

            Assert.That(viewModel.RollResistanceCoefficient, Is.EqualTo(data.RollResistanceCoefficient));
            Assert.That(viewModel.RollResistanceWithBrakesCoefficient, Is.EqualTo(data.RollResistanceWithBrakesCoefficient));
        }
コード例 #9
0
 public JsonResult AddAircraft(AircraftData aircraftData)
 {
     try
     {
         var result = DashboardBusiness.PostAircraftData(aircraftData);
         if (result != null)
         {
             return(new JsonResult {
                 Data = result
             });
         }
         else
         {
             return(new JsonResult {
                 Data = "Error!!"
             });
         }
     }
     catch (Exception ex)
     {
         return(new JsonResult {
             Data = ex.Message
         });
     }
 }
コード例 #10
0
 /// <summary>
 /// Creates a new instance of <see cref="ContinuedTakeOffDynamicsCalculator"/>.
 /// </summary>
 /// <param name="aircraftData">Tee <see cref="AircraftData"/> which holds
 /// all the information of the aircraft to simulate.</param>
 /// <param name="numberOfFailedEngines">The number of engines which failed during takeoff.</param>
 /// <param name="density">The air density. [kg/m3]</param>
 /// <param name="gravitationalAcceleration">The gravitational acceleration g0. [m/s^2]</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="aircraftData"/>
 /// is <c>null</c>.</exception>
 public ContinuedTakeOffDynamicsCalculator(AircraftData aircraftData, int numberOfFailedEngines, double density, double gravitationalAcceleration)
     : base(aircraftData, density, gravitationalAcceleration)
 {
     this.aircraftData          = aircraftData;
     this.numberOfFailedEngines = numberOfFailedEngines;
     this.density = density;
 }
コード例 #11
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);
        }
コード例 #12
0
        public void Create_WithArguments_ReturnsExpectedAircraftData()
        {
            // Setup
            var random = new Random(21);

            var aircraftData = new AircraftData
            {
                WingSurfaceArea         = random.NextDouble(),
                AspectRatio             = random.NextDouble(),
                OswaldFactor            = random.NextDouble(),
                MaximumLiftCoefficient  = random.NextDouble(),
                LiftCoefficientGradient = random.NextDouble(),
                ZeroLiftAngleOfAttack   = random.NextAngle(),
                RestDragCoefficient     = random.NextDouble(),
                RestDragCoefficientWithEngineFailure = random.NextDouble(),
                MaximumPitchAngle                   = random.NextAngle(),
                PitchGradient                       = random.NextAngle(),
                RollResistanceCoefficient           = random.NextDouble(),
                RollResistanceWithBrakesCoefficient = random.NextDouble(),
                TakeOffWeight                       = random.NextDouble()
            };

            var engineData = new EngineData
            {
                NrOfEngines     = random.Next(),
                ThrustPerEngine = random.NextDouble()
            };

            // Call
            KernelAircraftData data = AircraftDataFactory.Create(aircraftData, engineData);

            // Assert
            AircraftDataTestHelper.AssertAircraftData(aircraftData, engineData, data);
        }
コード例 #13
0
    public void SendFuelRequestConfirmation(int fuelOrderId)
    {
        _FuelOrder = new FuelOrders(fuelOrderId);
        _Customer  = new CustomerDetails(_FuelOrder.CustClientID);

        try
        {
            _Customer.Contacts = new ContactsCollection();
            _Customer.Contacts.LoadByCustClientID(_Customer.CustClientID);
            _Customer.Email = "";
            foreach (Contacts contact in _Customer.Contacts)
            {
                if (contact.Distribute)
                {
                    _Customer.Email += contact.Email + ";";
                }
            }
            _FuelOrder.Aircraft = Aircrafts.GetAircraft(_FuelOrder.AircraftID);
            _FuelOrder.Aircraft.MakeAndModel = AircraftData.GetAircraftData(_FuelOrder.Aircraft.MakeModelID);
            CreateAndSendEmail();
            _FuelOrder.AdminStatus = AdminStatuses.Confirmed;
            _FuelOrder.Update();
        }
        catch (Exception e)
        {
            ErrorLog EL = new ErrorLog(e);
            EL.UserID = _FuelOrder.CustClientID;
            EL.URL    = "SendFuelRequestConfirmation, ID: " + _FuelOrder.Id.ToString();
            EL.LogError();
        }
    }
コード例 #14
0
        public void GivenAircraftStateResultsIntoInvalidCalculationException_WhenCalculateCalled_ThenCalculatorExceptionThrown()
        {
            // Given
            var random = new Random(21);

            AircraftData aircraftData = AircraftDataTestFactory.CreateRandomAircraftData();
            var          calculator   = new TestTakeOffDynamicsCalculator(aircraftData, random.NextDouble(), random.NextDouble());

            var state = new AircraftState(aircraftData.AerodynamicsData.ZeroLiftAngleOfAttack - Angle.FromRadians(1),
                                          new Angle(),
                                          random.NextDouble(),
                                          random.NextDouble(),
                                          random.NextDouble());

            // When
            TestDelegate call = () => calculator.Calculate(state);

            // Then
            var exception = Assert.Throws <CalculatorException>(call);

            Exception innerException = exception.InnerException;

            Assert.IsInstanceOf <InvalidCalculationException>(innerException);
            Assert.AreEqual(innerException.Message, exception.Message);
        }
コード例 #15
0
        public void Create_WithAircraftDataResultingInArgumentOutOfRangeException_ThrowsCreateKernelDataException()
        {
            // Setup
            var random       = new Random(21);
            var aircraftData = new AircraftData
            {
                WingSurfaceArea         = -1 * random.NextDouble(),
                AspectRatio             = random.NextDouble(),
                OswaldFactor            = random.NextDouble(),
                MaximumLiftCoefficient  = random.NextDouble(),
                LiftCoefficientGradient = random.NextDouble(),
                ZeroLiftAngleOfAttack   = random.NextAngle(),
                RestDragCoefficient     = random.NextDouble(),
                RestDragCoefficientWithEngineFailure = random.NextDouble()
            };

            // Call
            TestDelegate call = () => AerodynamicsDataFactory.Create(aircraftData);

            // Assert
            var       exception      = Assert.Throws <CreateKernelDataException>(call);
            Exception innerException = exception.InnerException;

            Assert.That(innerException, Is.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(exception.Message, Is.EqualTo(exception.Message));
        }
コード例 #16
0
    private void SendRequestForRelease()
    {
        _Client            = new Clients(_FuelOrder.AdminClientID);
        _Customer.Contacts = new ContactsCollection();
        _Customer.Contacts.LoadByCustClientID(_Customer.CustClientID);

        try
        {
            if (_Customer.Contacts.Count > 0)
            {
                if (!string.IsNullOrEmpty(_Customer.Email) && !_Customer.Email.EndsWith(";"))
                {
                    _Customer.Email += ";";
                }
                foreach (Contacts contact in _Customer.Contacts)
                {
                    if (!contact.Distribute || string.IsNullOrEmpty(contact.Email))
                    {
                        continue;
                    }
                    _Customer.Email += contact.Email + ";";
                }
            }
            _FuelOrder.Aircraft = Aircrafts.GetAircraft(_FuelOrder.AircraftID);
            _FuelOrder.Aircraft.MakeAndModel = AircraftData.GetAircraftData(_FuelOrder.Aircraft.MakeModelID);
            CreateAndSendEmail();
        }
        catch (Exception e)
        {
            ErrorLog EL = new ErrorLog(e);
            EL.UserID = _FuelOrder.CustClientID;
            EL.URL    = "SendFuelOrderVendorDispatchRequestForRelease, ID: " + _FuelOrder.Id.ToString();
            EL.LogError();
        }
    }
コード例 #17
0
        private void Simconnect_OnRecvSimobjectDataBytypeAsync(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
        {
            switch (data.dwRequestID)
            {
            case (uint)DATA_REQUESTS.AIRCRAFT_DATA:
            {
                var aircraftData = data.dwData[0] as AircraftDataStruct?;

                if (aircraftData.HasValue)
                {
                    var result = new AircraftData
                    {
                        Type  = aircraftData.Value.Type,
                        Model = aircraftData.Value.Model,
                        Title = aircraftData.Value.Title,
                        EstimatedCruiseSpeed = aircraftData.Value.EstimatedCruiseSpeed
                    };
                    AircraftDataUpdated?.Invoke(this, new AircraftDataUpdatedEventArgs(result));

                    aircraftDataTcs?.TrySetResult(result);
                    aircraftDataTcs = null;
                }
            }
            break;
            }
        }
コード例 #18
0
        public void TakeOffWeight_ValueChanges_RaisesNotifyPropertyChangedEvent()
        {
            // Setup
            var data      = new AircraftData();
            var viewModel = new AircraftDataTabViewModel(data);

            bool propertyChangedTriggered      = false;
            PropertyChangedEventArgs eventArgs = null;

            viewModel.PropertyChanged += (o, e) =>
            {
                propertyChangedTriggered = true;
                eventArgs = e;
            };

            var    random   = new Random(21);
            double newValue = random.NextDouble();

            // Call
            viewModel.TakeOffWeight = newValue;

            // Assert
            Assert.That(propertyChangedTriggered, Is.True);

            Assert.That(eventArgs, Is.Not.Null);
            Assert.That(eventArgs.PropertyName, Is.EqualTo(nameof(AircraftDataTabViewModel.TakeOffWeight)));
            Assert.That(data.TakeOffWeight, Is.EqualTo(newValue));
        }
コード例 #19
0
        private void Simconnect_OnRecvSimobjectDataBytypeAsync(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
        {
            // Must be general SimObject information
            switch (data.dwRequestID)
            {
            case (uint)DATA_REQUESTS.AIRCRAFT_DATA:
            {
                // Handle this when aircraft is changed
                var aircraftData = data.dwData[0] as AircraftDataStruct?;

                if (aircraftData.HasValue)
                {
                    logger.LogInformation("Aircraft data received.");

                    var result = new AircraftData
                    {
                        Type  = aircraftData.Value.Type,
                        Model = aircraftData.Value.Model,
                        Title = aircraftData.Value.Title,
                        EstimatedCruiseSpeed = aircraftData.Value.EstimatedCruiseSpeed
                    };
                    AircraftDataUpdated?.Invoke(this, new AircraftDataUpdatedEventArgs(result));

                    aircraftDataTcs?.TrySetResult(result);
                    aircraftDataTcs = null;
                }
            }
            break;
            }
        }
コード例 #20
0
        [TestCase(24900, 25100, 30000, 29100, 270, 360)] // Nort-West

        public void CalculateCourse(int xNew, int xOld, int yNew, int yOld, int grad1, int grad2)
        {
            AircraftData newAircraftData = new AircraftData("test", xNew, yNew, 1, new TimeStamp(1, 1, 1, 1, 1, 1, 1));
            AircraftData oldAircraftData = new AircraftData("test", xOld, yOld, 1, new TimeStamp(1, 1, 1, 1, 1, 1, 1));

            double grad = _uut.CalculateDegree(newAircraftData, oldAircraftData);

            Assert.That(grad >= grad1 && grad <= grad2);
        }
コード例 #21
0
        [TestCase(23, 50, 53, 600, 85853600)] //82 800 000 + 3 000 000 + 53 000 + 600 == 85853600
        public void CalculateMiliisecTest(int hour, int min, int sec, int ms, int result)
        {
            AircraftData aircraft = new AircraftData("test", 1, 1, 1, new TimeStamp(1, 1, 1, hour, min, sec, ms));
            //TimeSpan test = new TimeSpan();

            int millisec = _uut.ConvertTimeToMilliseconds(aircraft);

            Assert.That(millisec == result);
        }
コード例 #22
0
 public AggregatedDistanceOutput Calculate(AircraftData aircraftData,
                                           IIntegrator integrator,
                                           int nrOfFailedEngines,
                                           double density,
                                           double gravitationalAcceleration,
                                           CalculationSettings calculationSettings)
 {
     return(aggregatedDistanceCalculator.Calculate(aircraftData, integrator, nrOfFailedEngines, density, gravitationalAcceleration, calculationSettings));
 }
コード例 #23
0
        private static double GetRotationSpeed(AircraftData aircraftData)
        {
            double stallSpeed = AerodynamicsHelper.CalculateStallSpeed(aircraftData.AerodynamicsData,
                                                                       aircraftData.TakeOffWeight * 1000,
                                                                       airDensity);
            double rotationSpeed = stallSpeed * 1.2;

            return(rotationSpeed);
        }
コード例 #24
0
        /// <summary>
        /// Creates an instance of <see cref="AircraftDataRuleProvider"/>.
        /// </summary>
        /// <param name="data">The <see cref="AircraftData"/> to create the provider for.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/> is <c>null</c>.</exception>
        public AircraftDataRuleProvider(AircraftData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            this.data = data;
        }
コード例 #25
0
ファイル: AnalyserTest.cs プロジェクト: 201508876PMH/ATM
        public void Test_CheckForCollisionIsTrue(int Alt1, int Alt2, int Dist, bool Collision)
        {
            AircraftData a1 = new AircraftData("", 0, 0, Alt1, null);
            AircraftData a2 = new AircraftData("", 0, 0, Alt2, null);

            _utility.CalcDistance(a1, a2).Returns(Dist);

            Assert.That(_uut.CheckForCollision(a1, a2) == Collision);
        }
コード例 #26
0
        public void CalculateDistanceTest(int x1, int y1, int x2, int y2, int result)
        {
            AircraftData airObj1 = new AircraftData("test", x1, y1, 500, new TimeStamp(1, 1, 1, 1, 1, 1, 1));
            AircraftData airObj2 = new AircraftData("test", x2, y2, 500, new TimeStamp(1, 1, 1, 1, 1, 1, 1));

            int distance = _uut.CalcDistance(airObj1, airObj2);

            Assert.That(distance == result);
        }
コード例 #27
0
        public void Constructor_WithArguments_ExpectedValues()
        {
            // Setup
            var data = new AircraftData();

            // Call
            var provider = new AircraftDataRuleProvider(data);

            // Assert
            Assert.That(provider, Is.InstanceOf <IDataModelRuleProvider>());
        }
コード例 #28
0
        public static void Constructor_ExpectedValues()
        {
            // Setup
            var          random       = new Random(21);
            AircraftData aircraftData = AircraftDataTestFactory.CreateRandomAircraftData();

            // Call
            var calculator = new NormalTakeOffDynamicsCalculator(aircraftData, random.NextDouble(), random.NextDouble());

            // Assert
            Assert.IsInstanceOf <TakeOffDynamicsCalculatorBase>(calculator);
            Assert.IsInstanceOf <INormalTakeOffDynamicsCalculator>(calculator);
        }
コード例 #29
0
        public IDistanceCalculator CreateAbortedTakeOffDistanceCalculator(AircraftData data,
                                                                          IIntegrator integrator,
                                                                          double density,
                                                                          double gravitationalAcceleration,
                                                                          CalculationSettings calculationSettings)
        {
            INormalTakeOffDynamicsCalculator normalTakeOffDynamicsCalculator =
                takeOffDynamicsCalculatorFactory.CreateNormalTakeOffDynamics(data, density, gravitationalAcceleration);
            IFailureTakeOffDynamicsCalculator failureTakeOffDynamicsCalculator =
                takeOffDynamicsCalculatorFactory.CreateAbortedTakeOffDynamics(data, density, gravitationalAcceleration);

            return(new DistanceCalculator(normalTakeOffDynamicsCalculator, failureTakeOffDynamicsCalculator, integrator, calculationSettings));
        }
コード例 #30
0
        public void CalcluLateSpeedest()
        {
            AircraftData newAircraftData = new AircraftData("test", 15000, 20000, 1, new TimeStamp(1, 1, 1, 23, 50, 53, 999));
            AircraftData oldAircraftData = new AircraftData("test", 25000, 30000, 1, new TimeStamp(1, 1, 1, 23, 50, 53, 600));

            double speedMeterPerSec = Math.Round(_uut.Speed(newAircraftData, oldAircraftData), 2);

            // Wolfram says = 35443.94
            // Probably  wolffram who uses more indexes
            // Our says == 35443.61

            Assert.That(speedMeterPerSec == 35443.61);
        }
コード例 #31
0
        public static List<AircraftData> initializeAircraftData()
        {

            List<AircraftData> data = new List<AircraftData>();
            data.Capacity = (int)Aircraft.Type.TypeCount;

            AircraftData eagle = new AircraftData();
            eagle.hitpoints = 100;
            eagle.speed = 200;
            eagle.texture = ResourceID.Eagle;
            eagle.fireInterval = Time.FromSeconds(1);
            data.Insert((int)Aircraft.Type.Eagle, eagle);
            eagle.directions = new List<Direction>();

            AircraftData raptor = new AircraftData();
            raptor.hitpoints = 20;
            raptor.speed = 100;
            raptor.texture = ResourceID.Raptor;
            raptor.directions = new List<Direction>();

            raptor.directions.Add(new Direction(90, 120));
            raptor.directions.Add(new Direction(-90, 120));
            //raptor.directions.Add(new Direction(45, 90));
            data.Insert((int)Aircraft.Type.Raptor, raptor);


            AircraftData avenger = new AircraftData();
            avenger.hitpoints = 40;
            avenger.speed = 80;
            avenger.texture = ResourceID.Avenger; //TODO: Fix bug where avenger only uses first texture
            avenger.directions = new List<Direction>();

            avenger.directions.Add(new Direction(+90, 100));
            avenger.directions.Add(new Direction(+180, 100));
            avenger.directions.Add(new Direction(-90, 100));
            avenger.directions.Add(new Direction(-180, 100));
            avenger.directions.Add(new Direction(+90, 100));
            data.Insert((int)Aircraft.Type.Avenger,avenger);

            return data;
        }