public void Constructor_ExpectedValues() { // Call var kernel = new AggregatedDistanceCalculatorKernel(); // Assert Assert.IsInstanceOf <IAggregatedDistanceCalculatorKernel>(kernel); }
public void Validate_AircraftDataNull_ThrowsArgumentNullException() { // Setup var random = new Random(21); double density = random.NextDouble(); double gravitationalAcceleration = random.NextDouble(); int nrOfFailedEngines = random.Next(); var kernel = new AggregatedDistanceCalculatorKernel(); // Call TestDelegate call = () => kernel.Validate(null, density, gravitationalAcceleration, nrOfFailedEngines); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("aircraftData", exception.ParamName); }
public void Validate_AllDataInvalid_ReturnsExpectedValidationResult() { // Setup AircraftData aircraftData = AircraftDataTestFactory.CreateRandomAircraftData(); var kernel = new AggregatedDistanceCalculatorKernel(); // Call KernelValidationError result = kernel.Validate(aircraftData, 0, 0, aircraftData.NrOfEngines + 1); // Assert const KernelValidationError expectedResult = KernelValidationError.InvalidDensity | KernelValidationError.InvalidGravitationalAcceleration | KernelValidationError.InvalidNrOfFailedEngines; Assert.AreEqual(expectedResult, result); }
public void GivenKernel_WhenCalculationsAreMadeForVelocityRange_ThenReturnsExpectedOutputsAndBalancedFieldLength(AircraftData aircraftData, IntegrationReferenceData integrationReferenceData) { // Given var integrator = new EulerIntegrator(); var calculationKernel = new AggregatedDistanceCalculatorKernel(); // When var outputs = new List <AggregatedDistanceOutput>(); for (int i = 0; i < 90; i++) { var calculationSettings = new CalculationSettings(i, maximumTimeSteps, timeStep); AggregatedDistanceOutput result = calculationKernel.Calculate(aircraftData, integrator, 1, density, gravitationalAcceleration, calculationSettings); outputs.Add(result); } BalancedFieldLength balancedFieldLength = BalancedFieldLengthCalculator.CalculateBalancedFieldLength(outputs); // Then IEnumerable <ReferenceOutput> referenceOutputs = GetReferenceOutputs(integrationReferenceData.FileName); int expectedLength = referenceOutputs.Count(); Assert.AreEqual(expectedLength, outputs.Count, "Number of reference data entries do not match with actual number of entries"); int velocity = 0; foreach (ReferenceOutput referenceOutput in referenceOutputs) { Assert.AreEqual(referenceOutput.Velocity, outputs[velocity].FailureSpeed); Assert.AreEqual(referenceOutput.ContinuedTakeOffDistance, outputs[velocity].ContinuedTakeOffDistance, tolerance); Assert.AreEqual(referenceOutput.AbortedTakeOffDistance, outputs[velocity].AbortedTakeOffDistance, tolerance); velocity++; } Assert.AreEqual(integrationReferenceData.Velocity, balancedFieldLength.Velocity, tolerance); Assert.AreEqual(integrationReferenceData.Distance, balancedFieldLength.Distance, tolerance); }
public void Validate_WithValidData_ReturnsExpectedValidationResult() { // Setup var random = new Random(21); AircraftData aircraftData = AircraftDataTestFactory.CreateRandomAircraftData(); double density = random.NextDouble(); double gravitationalAcceleration = random.NextDouble(); var kernel = new AggregatedDistanceCalculatorKernel(); // Call KernelValidationError result = kernel.Validate(aircraftData, density, gravitationalAcceleration, aircraftData.NrOfEngines - 1); // Assert Assert.AreEqual(KernelValidationError.None, result); }
public void Validate_DensityInvalid_ReturnsExpectedValidationResult(double density) { // Setup var random = new Random(21); AircraftData aircraftData = AircraftDataTestFactory.CreateRandomAircraftData(); double gravitationalAcceleration = random.NextDouble(); var kernel = new AggregatedDistanceCalculatorKernel(); // Call KernelValidationError result = kernel.Validate(aircraftData, density, gravitationalAcceleration, aircraftData.NrOfEngines - 1); // Assert Assert.IsTrue(result.HasFlag(KernelValidationError.InvalidDensity)); Assert.IsFalse(result.HasFlag(KernelValidationError.InvalidGravitationalAcceleration)); Assert.IsFalse(result.HasFlag(KernelValidationError.InvalidNrOfFailedEngines)); }