public void Read_ValidParameters_ReturnsOvertoppingRateOutput() { // Setup var random = new Random(22); double overtoppingRate = 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 GrassCoverErosionInwardsOvertoppingRateOutputEntity { OvertoppingRate = overtoppingRate, TargetProbability = targetProbability, TargetReliability = targetReliability, CalculatedProbability = calculatedProbability, CalculatedReliability = calculatedReliability, CalculationConvergence = Convert.ToByte(convergence) }; // Call OvertoppingRateOutput output = entity.Read(); // Assert Assert.AreEqual(overtoppingRate, output.OvertoppingRate, output.OvertoppingRate.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 Create_WithGeneralResult_ReturnsGrassCoverErosionInwardsDikeHeightOutputEntityWithGeneralResultEntity() { // Setup var random = new Random(21); var output = new OvertoppingRateOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, random.NextEnumValue <CalculationConvergence>(), new TestGeneralResultFaultTreeIllustrationPoint()); // Call GrassCoverErosionInwardsOvertoppingRateOutputEntity entity = output.Create(); // Assert Assert.IsNotNull(entity); GeneralResultEntityTestHelper.AssertGeneralResultPropertyValues(output.GeneralResult, entity.GeneralResultFaultTreeIllustrationPointEntity); }
/// <summary> /// Reads the <see cref="GrassCoverErosionInwardsOvertoppingRateOutputEntity"/> and use /// the information to construct a <see cref="OvertoppingRateOutput"/>. /// </summary> /// <param name="entity">The <see cref="GrassCoverErosionInwardsOvertoppingRateOutputEntity"/> /// to create <see cref="OvertoppingRateOutput"/> for.</param> /// <returns>A new <see cref="OvertoppingRateOutput"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/> /// is <c>null</c>.</exception> internal static OvertoppingRateOutput Read(this GrassCoverErosionInwardsOvertoppingRateOutputEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(new OvertoppingRateOutput(entity.OvertoppingRate.ToNullAsNaN(), entity.TargetProbability.ToNullAsNaN(), entity.TargetReliability.ToNullAsNaN(), entity.CalculatedProbability.ToNullAsNaN(), entity.CalculatedReliability.ToNullAsNaN(), (CalculationConvergence)entity.CalculationConvergence, entity.GeneralResultFaultTreeIllustrationPointEntity?.Read())); }
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_ReturnsGrassCoverErosionInwardsOvertoppingRateOutputEntityWithOutputNull() { // Setup var random = new Random(21); var output = new OvertoppingRateOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, random.NextEnumValue <CalculationConvergence>(), null); // Call GrassCoverErosionInwardsOvertoppingRateOutputEntity entity = output.Create(); // Assert Assert.IsNotNull(entity); Assert.IsNull(entity.OvertoppingRate); 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_ReturnsOvertoppingRateOutputWithNaN() { // Setup var random = new Random(22); var convergence = random.NextEnumValue <CalculationConvergence>(); var entity = new GrassCoverErosionInwardsOvertoppingRateOutputEntity { CalculationConvergence = Convert.ToByte(convergence) }; // Call OvertoppingRateOutput output = entity.Read(); // Assert Assert.IsNaN(output.OvertoppingRate); 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); }
public void Read_ValidEntityWithGeneralResultEntity_ReturnsOvertoppingRateOutputWithGeneralResult() { // Setup var random = new Random(22); var generalResultEntity = new GeneralResultFaultTreeIllustrationPointEntity { GoverningWindDirectionName = "SSE", GoverningWindDirectionAngle = random.NextDouble() }; var convergence = random.NextEnumValue <CalculationConvergence>(); var entity = new GrassCoverErosionInwardsOvertoppingRateOutputEntity { CalculationConvergence = Convert.ToByte(convergence), GeneralResultFaultTreeIllustrationPointEntity = generalResultEntity }; // Call OvertoppingRateOutput output = entity.Read(); // Assert GeneralResultEntityTestHelper.AssertGeneralResultPropertyValues(output.GeneralResult, generalResultEntity); }
private static OvertoppingRateOutput GetOvertoppingRateOutput(GrassCoverErosionInwardsOutputEntity entity) { GrassCoverErosionInwardsOvertoppingRateOutputEntity overtoppingRateOutputEntity = entity.GrassCoverErosionInwardsOvertoppingRateOutputEntities.SingleOrDefault(); return(overtoppingRateOutputEntity?.Read()); }