public void Read_ValidParameters_ReturnsDikeHeightOutput() { // Setup var random = new Random(22); double dikeHeight = 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 GrassCoverErosionInwardsDikeHeightOutputEntity { DikeHeight = dikeHeight, TargetProbability = targetProbability, TargetReliability = targetReliability, CalculatedProbability = calculatedProbability, CalculatedReliability = calculatedReliability, CalculationConvergence = Convert.ToByte(convergence) }; // Call DikeHeightOutput output = entity.Read(); // Assert Assert.AreEqual(dikeHeight, output.DikeHeight, output.DikeHeight.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 Create_NaNValues_ReturnGrassCoverErosionInwardsOutputEntity() { // Setup var overtoppingOutput = new OvertoppingOutput(double.NaN, true, double.NaN, null); var dikeHeightOutput = new TestDikeHeightOutput(double.NaN, CalculationConvergence.CalculatedConverged); var overtoppingRateOutput = new TestOvertoppingRateOutput(double.NaN, CalculationConvergence.CalculatedConverged); var output = new GrassCoverErosionInwardsOutput(overtoppingOutput, dikeHeightOutput, overtoppingRateOutput); // Call GrassCoverErosionInwardsOutputEntity entity = output.Create(); // Assert Assert.IsNull(entity.WaveHeight); Assert.AreEqual(Convert.ToByte(overtoppingOutput.IsOvertoppingDominant), entity.IsOvertoppingDominant); Assert.IsNull(entity.Reliability); Assert.IsNull(entity.GeneralResultFaultTreeIllustrationPointEntity); GrassCoverErosionInwardsDikeHeightOutputEntity dikeHeightEntity = entity.GrassCoverErosionInwardsDikeHeightOutputEntities.Single(); Assert.IsNull(dikeHeightEntity.DikeHeight); Assert.IsNull(dikeHeightEntity.TargetProbability); Assert.IsNull(dikeHeightEntity.TargetReliability); Assert.IsNull(dikeHeightEntity.CalculatedProbability); Assert.IsNull(dikeHeightEntity.CalculatedReliability); Assert.AreEqual((byte)dikeHeightOutput.CalculationConvergence, dikeHeightEntity.CalculationConvergence); GrassCoverErosionInwardsOvertoppingRateOutputEntity overtoppingRateEntity = entity.GrassCoverErosionInwardsOvertoppingRateOutputEntities.Single(); Assert.IsNull(overtoppingRateEntity.OvertoppingRate); Assert.IsNull(overtoppingRateEntity.TargetProbability); Assert.IsNull(overtoppingRateEntity.TargetReliability); Assert.IsNull(overtoppingRateEntity.CalculatedProbability); Assert.IsNull(overtoppingRateEntity.CalculatedReliability); Assert.AreEqual((byte)overtoppingRateOutput.CalculationConvergence, overtoppingRateEntity.CalculationConvergence); }
public void Read_WithGeneralResultEntity_ReturnsDikeHeightOutputWithGeneralResult() { // Setup var random = new Random(22); var generalResultEntity = new GeneralResultFaultTreeIllustrationPointEntity { GoverningWindDirectionName = "SSE", GoverningWindDirectionAngle = random.NextDouble() }; var convergence = random.NextEnumValue <CalculationConvergence>(); var entity = new GrassCoverErosionInwardsDikeHeightOutputEntity { CalculationConvergence = Convert.ToByte(convergence), GeneralResultFaultTreeIllustrationPointEntity = generalResultEntity }; // Call DikeHeightOutput output = entity.Read(); // Assert GeneralResultEntityTestHelper.AssertGeneralResultPropertyValues(output.GeneralResult, generalResultEntity); }
/// <summary> /// Reads the <see cref="GrassCoverErosionInwardsDikeHeightOutputEntity"/> and use /// the information to construct a <see cref="DikeHeightOutput"/>. /// </summary> /// <param name="entity">The <see cref="GrassCoverErosionInwardsDikeHeightOutputEntity"/> /// to create <see cref="DikeHeightOutput"/> for.</param> /// <returns>A new <see cref="DikeHeightOutput"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/> /// is <c>null</c>.</exception> internal static DikeHeightOutput Read(this GrassCoverErosionInwardsDikeHeightOutputEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(new DikeHeightOutput(entity.DikeHeight.ToNullAsNaN(), entity.TargetProbability.ToNullAsNaN(), entity.TargetReliability.ToNullAsNaN(), entity.CalculatedProbability.ToNullAsNaN(), entity.CalculatedReliability.ToNullAsNaN(), (CalculationConvergence)entity.CalculationConvergence, entity.GeneralResultFaultTreeIllustrationPointEntity?.Read())); }
public void Create_WithGeneralResult_ReturnsGrassCoverErosionInwardsDikeHeightOutputEntityWithGeneralResultEntity() { // Setup var random = new Random(21); var output = new DikeHeightOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, random.NextEnumValue <CalculationConvergence>(), new TestGeneralResultFaultTreeIllustrationPoint()); // Call GrassCoverErosionInwardsDikeHeightOutputEntity entity = output.Create(); // Assert Assert.IsNotNull(entity); GeneralResultEntityTestHelper.AssertGeneralResultPropertyValues(output.GeneralResult, entity.GeneralResultFaultTreeIllustrationPointEntity); }
public void Create_ValidInput_ReturnGrassCoverErosionInwardsOutputEntity() { // Setup var random = new Random(456); var overtoppingOutput = new OvertoppingOutput(random.NextDouble(), false, random.NextDouble(), null); var dikeHeightConvergence = random.NextEnumValue <CalculationConvergence>(); var overtoppingRateConvergence = random.NextEnumValue <CalculationConvergence>(); var dikeHeightOutput = new DikeHeightOutput(random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), dikeHeightConvergence, null); var overtoppingRateOutput = new OvertoppingRateOutput(random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), overtoppingRateConvergence, null); var output = new GrassCoverErosionInwardsOutput(overtoppingOutput, dikeHeightOutput, overtoppingRateOutput); // Call GrassCoverErosionInwardsOutputEntity entity = output.Create(); // Assert Assert.AreEqual(overtoppingOutput.WaveHeight.Value, entity.WaveHeight); Assert.AreEqual(Convert.ToByte(overtoppingOutput.IsOvertoppingDominant), entity.IsOvertoppingDominant); Assert.AreEqual(overtoppingOutput.Reliability, entity.Reliability); Assert.IsNull(entity.GeneralResultFaultTreeIllustrationPointEntity); GrassCoverErosionInwardsDikeHeightOutputEntity dikeHeightEntity = entity.GrassCoverErosionInwardsDikeHeightOutputEntities.Single(); Assert.AreEqual(dikeHeightOutput.DikeHeight, dikeHeightEntity.DikeHeight, dikeHeightOutput.DikeHeight.GetAccuracy()); Assert.AreEqual(dikeHeightOutput.TargetProbability, dikeHeightEntity.TargetProbability); Assert.AreEqual(dikeHeightOutput.TargetReliability, dikeHeightEntity.TargetReliability, dikeHeightOutput.TargetReliability.GetAccuracy()); Assert.AreEqual(dikeHeightOutput.CalculatedProbability, dikeHeightEntity.CalculatedProbability); Assert.AreEqual(dikeHeightOutput.CalculatedReliability, dikeHeightEntity.CalculatedReliability, dikeHeightOutput.CalculatedReliability.GetAccuracy()); Assert.AreEqual((byte)dikeHeightOutput.CalculationConvergence, dikeHeightEntity.CalculationConvergence); GrassCoverErosionInwardsOvertoppingRateOutputEntity overtoppingRateEntity = entity.GrassCoverErosionInwardsOvertoppingRateOutputEntities.Single(); Assert.AreEqual(overtoppingRateOutput.OvertoppingRate, overtoppingRateEntity.OvertoppingRate, overtoppingRateOutput.OvertoppingRate.GetAccuracy()); Assert.AreEqual(overtoppingRateOutput.TargetProbability, overtoppingRateEntity.TargetProbability); Assert.AreEqual(overtoppingRateOutput.TargetReliability, overtoppingRateEntity.TargetReliability, overtoppingRateOutput.TargetReliability.GetAccuracy()); Assert.AreEqual(overtoppingRateOutput.CalculatedProbability, overtoppingRateEntity.CalculatedProbability); Assert.AreEqual(overtoppingRateOutput.CalculatedReliability, overtoppingRateEntity.CalculatedReliability, overtoppingRateOutput.CalculatedReliability.GetAccuracy()); Assert.AreEqual((byte)overtoppingRateOutput.CalculationConvergence, overtoppingRateEntity.CalculationConvergence); }
public void Create_WithNaNParameters_ReturnsGrassCoverErosionInwardsDikeHeightOutputEntityWithOutputNull() { // Setup var random = new Random(21); var output = new DikeHeightOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, random.NextEnumValue <CalculationConvergence>(), null); // Call GrassCoverErosionInwardsDikeHeightOutputEntity entity = output.Create(); // Assert Assert.IsNotNull(entity); Assert.IsNull(entity.DikeHeight); Assert.IsNull(entity.TargetProbability); Assert.IsNull(entity.TargetReliability); Assert.IsNull(entity.CalculatedProbability); Assert.IsNull(entity.CalculatedReliability); Assert.AreEqual((byte)output.CalculationConvergence, entity.CalculationConvergence); Assert.IsNull(entity.GeneralResultFaultTreeIllustrationPointEntity); }
public void Read_NullParameters_ReturnsDikeHeightOutputWithNaN() { // Setup var random = new Random(22); var convergence = random.NextEnumValue <CalculationConvergence>(); var entity = new GrassCoverErosionInwardsDikeHeightOutputEntity { CalculationConvergence = Convert.ToByte(convergence) }; // Call DikeHeightOutput output = entity.Read(); // Assert Assert.IsNaN(output.DikeHeight); 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); }
private static DikeHeightOutput GetDikeHeightOutput(GrassCoverErosionInwardsOutputEntity entity) { GrassCoverErosionInwardsDikeHeightOutputEntity dikeHeightOutputEntity = entity.GrassCoverErosionInwardsDikeHeightOutputEntities.SingleOrDefault(); return(dikeHeightOutputEntity?.Read()); }