Example #1
0
        public void Create_SettingsNull_ThrowsArgumentNullException()
        {
            // Setup
            var random = new Random(21);

            // Call
            TestDelegate call = () => CalculationSettingsFactory.Create(null, random.Next());

            // Assert
            Assert.That(call, Throws.ArgumentNullException
                        .With.Property(nameof(ArgumentNullException.ParamName))
                        .EqualTo("settings"));
        }
Example #2
0
        public void Create_WithValidGeneralSimulationSettingsData_ReturnsExpectedCalculationSettings()
        {
            // Setup
            var random       = new Random(21);
            int failureSpeed = random.Next();

            var settings = new GeneralSimulationSettingsData
            {
                TimeStep = random.NextDouble(),
                MaximumNrOfIterations = random.Next()
            };

            // Call
            CalculationSettings calculationSettings = CalculationSettingsFactory.Create(settings, failureSpeed);

            // Assert
            CalculationSettingsTestHelper.AssertCalculationSettings(settings, failureSpeed, calculationSettings);
        }
 /// <summary>
 /// Calculates the <see cref="AggregatedDistanceOutput"/> based on the calculation input.
 /// </summary>
 /// <param name="calculationInput">The calculation input to calculate for.</param>
 /// <returns>A <see cref="AggregatedDistanceOutput"/>.</returns>
 /// <exception cref="CreateKernelDataException">Thrown when the calculation input
 /// could not be created for the kernel.</exception>
 /// <exception cref="KernelCalculationException">Thrown when <see cref="AggregatedDistanceOutput"/>
 /// could not be calculated.</exception>
 private AggregatedDistanceOutput CalculateDistances(CalculationInput calculationInput)
 {
     try
     {
         CalculationSettings simulationSettings = CalculationSettingsFactory.Create(calculationInput.GeneralSimulationSettings,
                                                                                    calculationInput.FailureVelocity);
         return(kernel.Calculate(calculationInput.AircraftData,
                                 calculationInput.Integrator,
                                 calculationInput.NrOfFailedEngines,
                                 calculationInput.Density,
                                 calculationInput.GravitationalAcceleration,
                                 simulationSettings));
     }
     catch (CalculatorException e)
     {
         throw new KernelCalculationException(e.Message, e);
     }
 }
Example #4
0
        public void Create_WithGeneralSimulationSettingsDataResultingInArgumentOutOfRangeException_ThrowsKernelDataCreateException()
        {
            // Setup
            var random = new Random(21);

            var settings = new GeneralSimulationSettingsData
            {
                TimeStep = random.NextDouble(),
                MaximumNrOfIterations = -1 * random.Next()
            };

            // Call
            TestDelegate call = () => CalculationSettingsFactory.Create(settings, random.Next());

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

            Assert.That(innerException, Is.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(exception.Message, Is.EqualTo(innerException.Message));
        }