public void Read_ValidParameters_ReturnsHydraulicBoundaryLocationCalculationOutput() { // Setup var random = new Random(22); double result = 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 HydraulicLocationOutputEntity { Result = result, TargetProbability = targetProbability, TargetReliability = targetReliability, CalculatedProbability = calculatedProbability, CalculatedReliability = calculatedReliability, CalculationConvergence = Convert.ToByte(convergence) }; // Call HydraulicBoundaryLocationCalculationOutput output = entity.Read(); // Assert Assert.AreEqual(result, output.Result, output.Result.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); Assert.IsNull(output.GeneralResult); }
public void Read_NaNParameters_ReturnsHydraulicBoundaryLocationCalculationOutputWithNaN() { // Setup var random = new Random(21); var convergence = random.NextEnumValue <CalculationConvergence>(); var entity = new HydraulicLocationOutputEntity { Result = double.NaN, TargetProbability = double.NaN, TargetReliability = double.NaN, CalculatedProbability = double.NaN, CalculatedReliability = double.NaN, CalculationConvergence = Convert.ToByte(convergence) }; // Call HydraulicBoundaryLocationCalculationOutput output = entity.Read(); // Assert Assert.IsNaN(output.Result); Assert.IsNaN(output.TargetProbability); Assert.IsNaN(output.TargetReliability); Assert.IsNaN(output.CalculatedProbability); Assert.IsNaN(output.CalculatedReliability); Assert.AreEqual(convergence, output.CalculationConvergence); Assert.IsNull(output.GeneralResult); }
/// <summary> /// Reads the <see cref="HydraulicLocationCalculationEntity"/> and uses the information to update a /// <see cref="HydraulicBoundaryLocationCalculation"/>. /// </summary> /// <param name="entity">The <see cref="HydraulicLocationCalculationEntity"/> to update the /// <see cref="HydraulicBoundaryLocationCalculation"/>.</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 HydraulicLocationCalculationEntity entity, HydraulicBoundaryLocationCalculation calculation) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (calculation == null) { throw new ArgumentNullException(nameof(calculation)); } calculation.InputParameters.ShouldIllustrationPointsBeCalculated = Convert.ToBoolean(entity.ShouldIllustrationPointsBeCalculated); HydraulicLocationOutputEntity outputEntity = entity.HydraulicLocationOutputEntities.SingleOrDefault(); if (outputEntity != null) { calculation.Output = outputEntity.Read(); } }
public void Read_EntityWithIllustrationPoints_ReturnsHydraulicBoundaryLocationCalculationOutputWithGeneralResult() { // Setup var random = new Random(21); var stochastEntities = new[] { new StochastEntity { Name = "stochastEntityOne", Duration = random.NextDouble(), Alpha = random.NextDouble(), Order = 0 } }; var topLevelIllustrationPointEntities = new[] { new TopLevelSubMechanismIllustrationPointEntity { WindDirectionName = "WindDirectionTwo", WindDirectionAngle = random.NextDouble(), ClosingSituation = "ClosingSituationTwo", SubMechanismIllustrationPointEntity = new SubMechanismIllustrationPointEntity { Beta = random.NextDouble(), Name = "IllustrationPointTwo" }, Order = 0 } }; var entity = new HydraulicLocationOutputEntity { Result = double.NaN, TargetProbability = double.NaN, TargetReliability = double.NaN, CalculatedProbability = double.NaN, CalculatedReliability = double.NaN, CalculationConvergence = Convert.ToByte(random.NextEnumValue <CalculationConvergence>()), GeneralResultSubMechanismIllustrationPointEntity = new GeneralResultSubMechanismIllustrationPointEntity { GoverningWindDirectionName = "SSE", GoverningWindDirectionAngle = random.NextDouble(), StochastEntities = stochastEntities, TopLevelSubMechanismIllustrationPointEntities = topLevelIllustrationPointEntities } }; // Call HydraulicBoundaryLocationCalculationOutput output = entity.Read(); // Assert GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult = output.GeneralResult; GeneralResultSubMechanismIllustrationPointEntity generalResultEntity = entity.GeneralResultSubMechanismIllustrationPointEntity; AssertWindDirection(generalResultEntity, generalResult.GoverningWindDirection); AssertStochasts(generalResultEntity.StochastEntities.ToArray(), generalResult.Stochasts.ToArray()); AssertIllustrationPoints(generalResultEntity.TopLevelSubMechanismIllustrationPointEntities.ToArray(), generalResult.TopLevelIllustrationPoints.ToArray()); }