public void Read_NullParameters_ReturnsDuneLocationOutputWithNaN() { // Setup var convergence = new Random(36).NextEnumValue <CalculationConvergence>(); var entity = new DuneLocationCalculationOutputEntity { WaterLevel = null, WaveHeight = null, WavePeriod = null, TargetProbability = null, TargetReliability = null, CalculatedProbability = null, CalculatedReliability = null, CalculationConvergence = Convert.ToByte(convergence) }; // Call DuneLocationCalculationOutput output = entity.Read(); // Assert Assert.IsNaN(output.WaterLevel); Assert.IsNaN(output.WaveHeight); Assert.IsNaN(output.WavePeriod); Assert.IsNaN(output.TargetProbability); Assert.IsNaN(output.TargetReliability); Assert.IsNaN(output.CalculatedProbability); Assert.IsNaN(output.CalculatedReliability); Assert.AreEqual(convergence, output.CalculationConvergence); }
/// <summary> /// Reads the <see cref="DuneLocationCalculationEntity"/> and uses the information to update a /// <see cref="DuneLocationCalculation"/>. /// </summary> /// <param name="entity">The <see cref="DuneLocationCalculationEntity"/> to update the /// <see cref="DuneLocationCalculation"/>.</param> /// <param name="calculation">The target of the read operation.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> internal static void Read(this DuneLocationCalculationEntity entity, DuneLocationCalculation calculation) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (calculation == null) { throw new ArgumentNullException(nameof(calculation)); } DuneLocationCalculationOutputEntity duneLocationCalculationOutputEntity = entity.DuneLocationCalculationOutputEntities.SingleOrDefault(); if (duneLocationCalculationOutputEntity != null) { calculation.Output = duneLocationCalculationOutputEntity.Read(); } }
public void Read_ValidParameters_ReturnsDuneLocationOutput() { // Setup var random = new Random(22); double waterLevel = random.NextDouble(); double waveHeight = random.NextDouble(); double wavePeriod = random.NextDouble(); double targetProbability = random.NextDouble(); double targetReliability = random.NextDouble(); double calculatedProbability = random.NextDouble(); double calculatedReliability = random.NextDouble(); var convergence = random.NextEnumValue <CalculationConvergence>(); var entity = new DuneLocationCalculationOutputEntity { WaterLevel = waterLevel, WaveHeight = waveHeight, WavePeriod = wavePeriod, TargetProbability = targetProbability, TargetReliability = targetReliability, CalculatedProbability = calculatedProbability, CalculatedReliability = calculatedReliability, CalculationConvergence = Convert.ToByte(convergence) }; // Call DuneLocationCalculationOutput output = entity.Read(); // Assert Assert.AreEqual(waterLevel, output.WaterLevel, output.WaterLevel.GetAccuracy()); Assert.AreEqual(waveHeight, output.WaveHeight, output.WaveHeight.GetAccuracy()); Assert.AreEqual(wavePeriod, output.WavePeriod, output.WavePeriod.GetAccuracy()); Assert.AreEqual(targetProbability, output.TargetProbability); Assert.AreEqual(targetReliability, output.TargetReliability, output.TargetReliability.GetAccuracy()); Assert.AreEqual(calculatedProbability, output.CalculatedProbability); Assert.AreEqual(calculatedReliability, output.CalculatedReliability, output.CalculatedReliability.GetAccuracy()); Assert.AreEqual(convergence, output.CalculationConvergence); }