public void Read_ValidEntity_InputObjectUpdated() { // Setup var random = new Random(78); var mocks = new MockRepository(); var entity = mocks.Stub <IStructuresCalculationEntity>(); entity.StructureNormalOrientation = random.NextDouble(0, 360); entity.AllowedLevelIncreaseStorageMean = random.NextDouble(1e-6, 9999.9999); entity.AllowedLevelIncreaseStorageStandardDeviation = random.NextDouble(1e-6, 9999.9999); entity.FlowWidthAtBottomProtectionMean = random.NextDouble(1e-6, 9999.9999); entity.FlowWidthAtBottomProtectionStandardDeviation = random.NextDouble(1e-6, 9999.9999); entity.CriticalOvertoppingDischargeMean = random.NextDouble(1e-6, 9999.9999); entity.CriticalOvertoppingDischargeCoefficientOfVariation = random.NextDouble(1e-6, 9999.9999); entity.FailureProbabilityStructureWithErosion = random.NextDouble(); entity.WidthFlowAperturesMean = random.NextDouble(1e-6, 9999.9999); entity.WidthFlowAperturesStandardDeviation = random.NextDouble(1e-6, 9999.9999); entity.StormDurationMean = random.NextDouble(1e-6, 9999.9999); entity.UseForeshore = Convert.ToByte(random.NextBoolean()); entity.UseBreakWater = Convert.ToByte(random.NextBoolean()); entity.ShouldIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()); mocks.ReplayAll(); var inputToUpdate = new SimpleStructuresInput(); var collector = new ReadConversionCollector(); // Call entity.Read(inputToUpdate, collector); // Assert AssertBoolean(entity.UseForeshore, inputToUpdate.UseForeshore); AssertBoolean(entity.UseBreakWater, inputToUpdate.UseBreakWater); AssertBoolean(entity.ShouldIllustrationPointsBeCalculated, inputToUpdate.ShouldIllustrationPointsBeCalculated); RoundedDoubleTestHelper.AssertRoundedDouble(entity.StructureNormalOrientation, inputToUpdate.StructureNormalOrientation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.AllowedLevelIncreaseStorageMean, inputToUpdate.AllowedLevelIncreaseStorage.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.AllowedLevelIncreaseStorageStandardDeviation, inputToUpdate.AllowedLevelIncreaseStorage.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.FlowWidthAtBottomProtectionMean, inputToUpdate.FlowWidthAtBottomProtection.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.FlowWidthAtBottomProtectionStandardDeviation, inputToUpdate.FlowWidthAtBottomProtection.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.CriticalOvertoppingDischargeMean, inputToUpdate.CriticalOvertoppingDischarge.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.CriticalOvertoppingDischargeCoefficientOfVariation, inputToUpdate.CriticalOvertoppingDischarge.CoefficientOfVariation); Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, inputToUpdate.FailureProbabilityStructureWithErosion); RoundedDoubleTestHelper.AssertRoundedDouble(entity.WidthFlowAperturesMean, inputToUpdate.WidthFlowApertures.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.WidthFlowAperturesStandardDeviation, inputToUpdate.WidthFlowApertures.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.StormDurationMean, inputToUpdate.StormDuration.Mean); CollectionAssert.IsEmpty(inputToUpdate.ForeshoreGeometry); Assert.IsNull(inputToUpdate.ForeshoreProfile); Assert.IsNull(inputToUpdate.HydraulicBoundaryLocation); Assert.IsNull(inputToUpdate.Structure); mocks.VerifyAll(); }
public void Read_ValidEntity_ReturnSemiProbabilisticPipingCalculationScenario( bool isRelevant, bool useAssessmentLevelManualInput, double contribution, string name, string comments, double entryPoint, double exitPoint, double assessmentLevel, int seed) { // Setup var random = new Random(seed); var entity = new SemiProbabilisticPipingCalculationEntity { RelevantForScenario = Convert.ToByte(isRelevant), ScenarioContribution = contribution, Name = name, Comments = comments, EntryPointL = entryPoint.ToNaNAsNull(), ExitPointL = exitPoint.ToNaNAsNull(), PhreaticLevelExitMean = random.NextDouble(-9999.99, 9999.99), PhreaticLevelExitStandardDeviation = random.NextDouble(0, 9999.99), DampingFactorExitMean = random.NextDouble(1e-6, 9999.99), DampingFactorExitStandardDeviation = random.NextDouble(0, 9999.99), AssessmentLevel = assessmentLevel.ToNaNAsNull(), UseAssessmentLevelManualInput = Convert.ToByte(useAssessmentLevelManualInput) }; var collector = new ReadConversionCollector(); // Call SemiProbabilisticPipingCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreEqual(isRelevant, calculation.IsRelevant); RoundedDoubleTestHelper.AssertRoundedDouble(contribution, calculation.Contribution); Assert.AreEqual(name, calculation.Name); Assert.AreEqual(comments, calculation.Comments.Body); RoundedDoubleTestHelper.AssertRoundedDouble(entryPoint, calculation.InputParameters.EntryPointL); RoundedDoubleTestHelper.AssertRoundedDouble(exitPoint, calculation.InputParameters.ExitPointL); RoundedDoubleTestHelper.AssertRoundedDouble(entity.PhreaticLevelExitMean, calculation.InputParameters.PhreaticLevelExit.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.PhreaticLevelExitStandardDeviation, calculation.InputParameters.PhreaticLevelExit.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.DampingFactorExitMean, calculation.InputParameters.DampingFactorExit.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.DampingFactorExitStandardDeviation, calculation.InputParameters.DampingFactorExit.StandardDeviation); Assert.AreEqual(useAssessmentLevelManualInput, calculation.InputParameters.UseAssessmentLevelManualInput); Assert.AreEqual(entity.AssessmentLevel.ToNullAsNaN(), calculation.InputParameters.AssessmentLevel.Value); Assert.IsNull(calculation.InputParameters.SurfaceLine); Assert.IsNull(calculation.InputParameters.HydraulicBoundaryLocation); Assert.IsNull(calculation.InputParameters.StochasticSoilModel); Assert.IsNull(calculation.InputParameters.StochasticSoilProfile); Assert.IsNull(calculation.Output); }
public void Read_ValidEntity_ReturnCalculation() { // Setup var random = new Random(14); var breakWaterType = random.NextEnumValue <BreakWaterType>(); var entity = new GrassCoverErosionInwardsCalculationEntity { Name = "sodhfksn", Comments = "s;ohfgwjo5p09u", HydraulicLocationEntity = null, DikeProfileEntity = null, Orientation = 5.6, CriticalFlowRateMean = 3.4, CriticalFlowRateStandardDeviation = 1.2, UseForeshore = Convert.ToByte(random.NextBoolean()), DikeHeight = 2.3, UseBreakWater = Convert.ToByte(random.NextBoolean()), BreakWaterType = Convert.ToByte(breakWaterType), BreakWaterHeight = 5.7, ShouldOvertoppingOutputIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()), ShouldDikeHeightBeCalculated = Convert.ToByte(random.NextBoolean()), DikeHeightTargetProbability = 0.01, ShouldDikeHeightIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()), ShouldOvertoppingRateBeCalculated = Convert.ToByte(random.NextBoolean()), OvertoppingRateTargetProbability = 0.02, ShouldOvertoppingRateIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()), RelevantForScenario = Convert.ToByte(random.NextBoolean()), ScenarioContribution = 0.45 }; var collector = new ReadConversionCollector(); // Call GrassCoverErosionInwardsCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreEqual(entity.Name, calculation.Name); Assert.AreEqual(entity.Comments, calculation.Comments.Body); AssertBoolean(entity.RelevantForScenario, calculation.IsRelevant); RoundedDoubleTestHelper.AssertRoundedDouble(entity.ScenarioContribution, calculation.Contribution); GrassCoverErosionInwardsInput input = calculation.InputParameters; Assert.AreEqual(entity.Orientation, input.Orientation.Value); Assert.AreEqual(entity.CriticalFlowRateMean, input.CriticalFlowRate.Mean.Value); Assert.AreEqual(entity.CriticalFlowRateStandardDeviation, input.CriticalFlowRate.StandardDeviation.Value); AssertBoolean(entity.UseForeshore, input.UseForeshore); Assert.AreEqual(entity.DikeHeight, input.DikeHeight.Value); AssertBoolean(entity.UseBreakWater, input.UseBreakWater); Assert.AreEqual(breakWaterType, input.BreakWater.Type); Assert.AreEqual(entity.BreakWaterHeight, input.BreakWater.Height.Value); AssertBoolean(entity.ShouldOvertoppingOutputIllustrationPointsBeCalculated, input.ShouldOvertoppingOutputIllustrationPointsBeCalculated); AssertBoolean(entity.ShouldDikeHeightBeCalculated, input.ShouldDikeHeightBeCalculated); Assert.AreEqual(entity.DikeHeightTargetProbability, input.DikeHeightTargetProbability); AssertBoolean(entity.ShouldDikeHeightIllustrationPointsBeCalculated, input.ShouldDikeHeightIllustrationPointsBeCalculated); AssertBoolean(entity.ShouldOvertoppingRateBeCalculated, input.ShouldOvertoppingRateBeCalculated); Assert.AreEqual(entity.OvertoppingRateTargetProbability, input.OvertoppingRateTargetProbability); AssertBoolean(entity.ShouldOvertoppingRateIllustrationPointsBeCalculated, input.ShouldOvertoppingRateIllustrationPointsBeCalculated); Assert.IsNull(input.DikeProfile); Assert.IsNull(input.HydraulicBoundaryLocation); Assert.IsFalse(calculation.HasOutput); }
public void Read_ValidEntity_ReturnStabilityPointStructuresCalculation() { // Setup var entity = new StabilityPointStructuresCalculationEntity { Name = "name", RelevantForScenario = Convert.ToByte(true), ScenarioContribution = 0.0, Comments = "comments", StructureNormalOrientation = 1.1, AllowedLevelIncreaseStorageMean = 2.2, AllowedLevelIncreaseStorageStandardDeviation = 3.3, StorageStructureAreaMean = 4.4, StorageStructureAreaCoefficientOfVariation = 5.5, FlowWidthAtBottomProtectionMean = 6.6, FlowWidthAtBottomProtectionStandardDeviation = 7.7, CriticalOvertoppingDischargeMean = 8.8, CriticalOvertoppingDischargeCoefficientOfVariation = 9.9, FailureProbabilityStructureWithErosion = 0.10, WidthFlowAperturesMean = 11.11, WidthFlowAperturesStandardDeviation = 12.12, StormDurationMean = 13.13, UseBreakWater = Convert.ToByte(true), BreakWaterType = Convert.ToByte(BreakWaterType.Wall), BreakWaterHeight = 14.14, UseForeshore = Convert.ToByte(true), InsideWaterLevelMean = 15.15, InsideWaterLevelStandardDeviation = 16.16, ThresholdHeightOpenWeirMean = 17.17, ThresholdHeightOpenWeirStandardDeviation = 18.18, ConstructiveStrengthLinearLoadModelMean = 19.19, ConstructiveStrengthLinearLoadModelCoefficientOfVariation = 20.20, ConstructiveStrengthQuadraticLoadModelMean = 21.21, ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = 22.22, BankWidthMean = 23.23, BankWidthStandardDeviation = 24.24, InsideWaterLevelFailureConstructionMean = 25.25, InsideWaterLevelFailureConstructionStandardDeviation = 26.26, EvaluationLevel = 27.27, LevelCrestStructureMean = 28.28, LevelCrestStructureStandardDeviation = 29.29, VerticalDistance = 30.30, FailureProbabilityRepairClosure = 0.31, FailureCollisionEnergyMean = 32.32, FailureCollisionEnergyCoefficientOfVariation = 33.33, ShipMassMean = 34.34, ShipMassCoefficientOfVariation = 35.35, ShipVelocityMean = 36.36, ShipVelocityCoefficientOfVariation = 37.37, LevellingCount = 38, ProbabilityCollisionSecondaryStructure = 0.39, FlowVelocityStructureClosableMean = 40.40, StabilityLinearLoadModelMean = 41.41, StabilityLinearLoadModelCoefficientOfVariation = 42.42, StabilityQuadraticLoadModelMean = 43.43, StabilityQuadraticLoadModelCoefficientOfVariation = 44.44, AreaFlowAperturesMean = 45.45, AreaFlowAperturesStandardDeviation = 46.46, InflowModelType = Convert.ToByte(StabilityPointStructureInflowModelType.FloodedCulvert), LoadSchematizationType = Convert.ToByte(LoadSchematizationType.Quadratic), VolumicWeightWater = 47.47, FactorStormDurationOpenStructure = 48.48, DrainCoefficientMean = 49.49, DrainCoefficientStandardDeviation = 50.50 }; var collector = new ReadConversionCollector(); // Call StructuresCalculationScenario <StabilityPointStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreEqual(entity.Name, calculation.Name); Assert.AreEqual(Convert.ToBoolean(entity.RelevantForScenario), calculation.IsRelevant); RoundedDoubleTestHelper.AssertRoundedDouble(entity.ScenarioContribution, calculation.Contribution); Assert.AreEqual(entity.Comments, calculation.Comments.Body); StabilityPointStructuresInput inputParameters = calculation.InputParameters; Assert.IsNull(inputParameters.ForeshoreProfile); Assert.IsNull(inputParameters.Structure); Assert.IsNull(inputParameters.HydraulicBoundaryLocation); Assert.AreEqual(entity.StructureNormalOrientation, inputParameters.StructureNormalOrientation.Value); Assert.AreEqual(entity.AllowedLevelIncreaseStorageMean, inputParameters.AllowedLevelIncreaseStorage.Mean.Value); Assert.AreEqual(entity.AllowedLevelIncreaseStorageStandardDeviation, inputParameters.AllowedLevelIncreaseStorage.StandardDeviation.Value); Assert.AreEqual(entity.StorageStructureAreaMean, inputParameters.StorageStructureArea.Mean.Value); Assert.AreEqual(entity.StorageStructureAreaCoefficientOfVariation, inputParameters.StorageStructureArea.CoefficientOfVariation.Value); Assert.AreEqual(entity.FlowWidthAtBottomProtectionMean, inputParameters.FlowWidthAtBottomProtection.Mean.Value); Assert.AreEqual(entity.FlowWidthAtBottomProtectionStandardDeviation, inputParameters.FlowWidthAtBottomProtection.StandardDeviation.Value); Assert.AreEqual(entity.CriticalOvertoppingDischargeMean, inputParameters.CriticalOvertoppingDischarge.Mean.Value); Assert.AreEqual(entity.CriticalOvertoppingDischargeCoefficientOfVariation, inputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation.Value); Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, inputParameters.FailureProbabilityStructureWithErosion); Assert.AreEqual(entity.WidthFlowAperturesMean, inputParameters.WidthFlowApertures.Mean.Value); Assert.AreEqual(entity.WidthFlowAperturesStandardDeviation, inputParameters.WidthFlowApertures.StandardDeviation.Value); Assert.AreEqual(entity.StormDurationMean, inputParameters.StormDuration.Mean.Value); Assert.AreEqual(Convert.ToBoolean(entity.UseBreakWater), inputParameters.UseBreakWater); Assert.AreEqual((BreakWaterType)entity.BreakWaterType, inputParameters.BreakWater.Type); Assert.AreEqual(entity.BreakWaterHeight, inputParameters.BreakWater.Height.Value); Assert.AreEqual(Convert.ToBoolean(entity.UseForeshore), inputParameters.UseForeshore); Assert.AreEqual(entity.InsideWaterLevelMean, inputParameters.InsideWaterLevel.Mean.Value); Assert.AreEqual(entity.InsideWaterLevelStandardDeviation, inputParameters.InsideWaterLevel.StandardDeviation.Value); Assert.AreEqual(entity.ThresholdHeightOpenWeirMean, inputParameters.ThresholdHeightOpenWeir.Mean.Value); Assert.AreEqual(entity.ThresholdHeightOpenWeirStandardDeviation, inputParameters.ThresholdHeightOpenWeir.StandardDeviation.Value); Assert.AreEqual(entity.ConstructiveStrengthLinearLoadModelMean, inputParameters.ConstructiveStrengthLinearLoadModel.Mean.Value); Assert.AreEqual(entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation, inputParameters.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.ConstructiveStrengthQuadraticLoadModelMean, inputParameters.ConstructiveStrengthQuadraticLoadModel.Mean.Value); Assert.AreEqual(entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation, inputParameters.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.BankWidthMean, inputParameters.BankWidth.Mean.Value); Assert.AreEqual(entity.BankWidthStandardDeviation, inputParameters.BankWidth.StandardDeviation.Value); Assert.AreEqual(entity.InsideWaterLevelFailureConstructionMean, inputParameters.InsideWaterLevelFailureConstruction.Mean.Value); Assert.AreEqual(entity.InsideWaterLevelFailureConstructionStandardDeviation, inputParameters.InsideWaterLevelFailureConstruction.StandardDeviation.Value); Assert.AreEqual(entity.EvaluationLevel, inputParameters.EvaluationLevel.Value); Assert.AreEqual(entity.LevelCrestStructureMean, inputParameters.LevelCrestStructure.Mean.Value); Assert.AreEqual(entity.LevelCrestStructureStandardDeviation, inputParameters.LevelCrestStructure.StandardDeviation.Value); Assert.AreEqual(entity.VerticalDistance, inputParameters.VerticalDistance.Value); Assert.AreEqual(entity.FailureProbabilityRepairClosure, inputParameters.FailureProbabilityRepairClosure); Assert.AreEqual(entity.FailureCollisionEnergyMean, inputParameters.FailureCollisionEnergy.Mean.Value); Assert.AreEqual(entity.FailureCollisionEnergyCoefficientOfVariation, inputParameters.FailureCollisionEnergy.CoefficientOfVariation.Value); Assert.AreEqual(entity.ShipMassMean, inputParameters.ShipMass.Mean.Value); Assert.AreEqual(entity.ShipMassCoefficientOfVariation, inputParameters.ShipMass.CoefficientOfVariation.Value); Assert.AreEqual(entity.ShipVelocityMean, inputParameters.ShipVelocity.Mean.Value); Assert.AreEqual(entity.ShipVelocityCoefficientOfVariation, inputParameters.ShipVelocity.CoefficientOfVariation.Value); Assert.AreEqual(entity.LevellingCount, inputParameters.LevellingCount); Assert.AreEqual(entity.ProbabilityCollisionSecondaryStructure, inputParameters.ProbabilityCollisionSecondaryStructure); Assert.AreEqual(entity.FlowVelocityStructureClosableMean, inputParameters.FlowVelocityStructureClosable.Mean.Value); Assert.AreEqual(entity.StabilityLinearLoadModelMean, inputParameters.StabilityLinearLoadModel.Mean.Value); Assert.AreEqual(entity.StabilityLinearLoadModelCoefficientOfVariation, inputParameters.StabilityLinearLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.StabilityQuadraticLoadModelMean, inputParameters.StabilityQuadraticLoadModel.Mean.Value); Assert.AreEqual(entity.StabilityQuadraticLoadModelCoefficientOfVariation, inputParameters.StabilityQuadraticLoadModel.CoefficientOfVariation.Value); Assert.AreEqual(entity.AreaFlowAperturesMean, inputParameters.AreaFlowApertures.Mean.Value); Assert.AreEqual(entity.AreaFlowAperturesStandardDeviation, inputParameters.AreaFlowApertures.StandardDeviation.Value); Assert.AreEqual((StabilityPointStructureInflowModelType)entity.InflowModelType, inputParameters.InflowModelType); Assert.AreEqual((LoadSchematizationType)entity.LoadSchematizationType, inputParameters.LoadSchematizationType); Assert.AreEqual(entity.VolumicWeightWater, inputParameters.VolumicWeightWater.Value); Assert.AreEqual(entity.FactorStormDurationOpenStructure, inputParameters.FactorStormDurationOpenStructure.Value); Assert.AreEqual(entity.DrainCoefficientMean, inputParameters.DrainCoefficient.Mean.Value); Assert.AreEqual(entity.DrainCoefficientStandardDeviation, inputParameters.DrainCoefficient.StandardDeviation.Value); Assert.IsFalse(calculation.HasOutput); }
public void Read_ValidEntity_ReturnCalculation(string name, string comments, int randomSeed) { // Setup var random = new Random(randomSeed); var entity = new HeightStructuresCalculationEntity { Name = name, RelevantForScenario = Convert.ToByte(true), ScenarioContribution = random.NextDouble(), Comments = comments, UseForeshore = Convert.ToByte(false), UseBreakWater = Convert.ToByte(false), StructureNormalOrientation = random.NextDouble(0, 360), ModelFactorSuperCriticalFlowMean = random.NextDouble(-9999.9999, 9999.9999), AllowedLevelIncreaseStorageMean = random.NextDouble(1e-6, 9999.9999), AllowedLevelIncreaseStorageStandardDeviation = random.NextDouble(1e-6, 9999.9999), FlowWidthAtBottomProtectionMean = random.NextDouble(1e-6, 9999.9999), FlowWidthAtBottomProtectionStandardDeviation = random.NextDouble(1e-6, 9999.9999), CriticalOvertoppingDischargeMean = random.NextDouble(1e-6, 9999.9999), CriticalOvertoppingDischargeCoefficientOfVariation = random.NextDouble(1e-6, 9999.9999), FailureProbabilityStructureWithErosion = random.NextDouble(), WidthFlowAperturesMean = random.NextDouble(1e-6, 9999.9999), WidthFlowAperturesStandardDeviation = random.NextDouble(1e-6, 9999.9999), StormDurationMean = random.NextDouble(1e-6, 9999.9999), LevelCrestStructureMean = random.NextDouble(1e-6, 9999.9999), LevelCrestStructureStandardDeviation = random.NextDouble(1e-6, 9999.9999), DeviationWaveDirection = random.NextDouble(-360, 360) }; var collector = new ReadConversionCollector(); // Call StructuresCalculationScenario <HeightStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreEqual(name, calculation.Name); Assert.AreEqual(Convert.ToBoolean(entity.RelevantForScenario), calculation.IsRelevant); RoundedDoubleTestHelper.AssertRoundedDouble(entity.ScenarioContribution, calculation.Contribution); Assert.AreEqual(comments, calculation.Comments.Body); HeightStructuresInput input = calculation.InputParameters; Assert.IsFalse(input.UseForeshore); Assert.IsFalse(input.UseBreakWater); RoundedDoubleTestHelper.AssertRoundedDouble(entity.StructureNormalOrientation, input.StructureNormalOrientation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.ModelFactorSuperCriticalFlowMean, input.ModelFactorSuperCriticalFlow.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.AllowedLevelIncreaseStorageMean, input.AllowedLevelIncreaseStorage.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.AllowedLevelIncreaseStorageStandardDeviation, input.AllowedLevelIncreaseStorage.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.FlowWidthAtBottomProtectionMean, input.FlowWidthAtBottomProtection.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.FlowWidthAtBottomProtectionStandardDeviation, input.FlowWidthAtBottomProtection.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.CriticalOvertoppingDischargeMean, input.CriticalOvertoppingDischarge.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.CriticalOvertoppingDischargeCoefficientOfVariation, input.CriticalOvertoppingDischarge.CoefficientOfVariation); Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, input.FailureProbabilityStructureWithErosion); RoundedDoubleTestHelper.AssertRoundedDouble(entity.WidthFlowAperturesMean, input.WidthFlowApertures.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.WidthFlowAperturesStandardDeviation, input.WidthFlowApertures.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.StormDurationMean, input.StormDuration.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.LevelCrestStructureMean, input.LevelCrestStructure.Mean); RoundedDoubleTestHelper.AssertRoundedDouble(entity.LevelCrestStructureStandardDeviation, input.LevelCrestStructure.StandardDeviation); RoundedDoubleTestHelper.AssertRoundedDouble(entity.DeviationWaveDirection, input.DeviationWaveDirection); CollectionAssert.IsEmpty(input.ForeshoreGeometry); Assert.IsNull(input.ForeshoreProfile); Assert.IsNull(input.HydraulicBoundaryLocation); Assert.IsNull(input.Structure); Assert.IsFalse(calculation.HasOutput); }
public void Read_ValidEntity_ReturnCalculation() { // Setup const string name = "Calculation Name"; const string comments = "Calculation Comment"; var random = new Random(21); double orientation = random.NextDouble(); bool useBreakWater = random.NextBoolean(); var breakWaterType = random.NextEnumValue <BreakWaterType>(); double breakWaterHeight = random.NextDouble(); bool useForeshore = random.NextBoolean(); const double lowerBoundaryRevetment = 3.58; const double upperBoundaryRevetment = 6.10; const double lowerBoundaryWaterLevels = 3.40; const double upperBoundaryWaterLevels = 5.88; var stepSize = random.NextEnumValue <WaveConditionsInputStepSize>(); var waterLevelType = random.NextEnumValue <WaveConditionsInputWaterLevelType>(); var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity { Name = name, Comments = comments, UseBreakWater = Convert.ToByte(useBreakWater), BreakWaterType = Convert.ToByte(breakWaterType), BreakWaterHeight = breakWaterHeight, UseForeshore = Convert.ToByte(useForeshore), Orientation = orientation, UpperBoundaryRevetment = upperBoundaryRevetment, LowerBoundaryRevetment = lowerBoundaryRevetment, UpperBoundaryWaterLevels = upperBoundaryWaterLevels, LowerBoundaryWaterLevels = lowerBoundaryWaterLevels, StepSize = Convert.ToByte(stepSize), WaterLevelType = Convert.ToByte(waterLevelType) }; var collector = new ReadConversionCollector(); // Call WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector); // Assert Assert.AreEqual(name, calculation.Name); Assert.AreEqual(comments, calculation.Comments.Body); WaveConditionsInput calculationInput = calculation.InputParameters; Assert.AreEqual(useBreakWater, calculationInput.UseBreakWater); Assert.AreEqual(breakWaterType, calculationInput.BreakWater.Type); RoundedDoubleTestHelper.AssertRoundedDouble(breakWaterHeight, calculationInput.BreakWater.Height); Assert.AreEqual(useForeshore, calculationInput.UseForeshore); RoundedDoubleTestHelper.AssertRoundedDouble(orientation, calculationInput.Orientation); RoundedDoubleTestHelper.AssertRoundedDouble(upperBoundaryRevetment, calculationInput.UpperBoundaryRevetment); RoundedDoubleTestHelper.AssertRoundedDouble(lowerBoundaryRevetment, calculationInput.LowerBoundaryRevetment); RoundedDoubleTestHelper.AssertRoundedDouble(upperBoundaryWaterLevels, calculationInput.UpperBoundaryWaterLevels); RoundedDoubleTestHelper.AssertRoundedDouble(lowerBoundaryWaterLevels, calculationInput.LowerBoundaryWaterLevels); Assert.AreEqual(stepSize, calculationInput.StepSize); Assert.AreEqual(waterLevelType, calculationInput.WaterLevelType); Assert.IsNull(calculationInput.HydraulicBoundaryLocation); Assert.IsNull(calculationInput.ForeshoreProfile); Assert.IsNull(calculationInput.CalculationsTargetProbability); Assert.IsNull(calculation.Output); }
public void Read_ValidEntity_ReturnClosingStructuresCalculation() { // Setup var entity = new ClosingStructuresCalculationEntity { Name = "name", RelevantForScenario = Convert.ToByte(true), ScenarioContribution = 0.0, Comments = "comments", StructureNormalOrientation = 1.1, ModelFactorSuperCriticalFlowMean = 2.2, AllowedLevelIncreaseStorageMean = 3.3, AllowedLevelIncreaseStorageStandardDeviation = 4.4, StorageStructureAreaMean = 5.5, StorageStructureAreaCoefficientOfVariation = 6.6, FlowWidthAtBottomProtectionMean = 7.7, FlowWidthAtBottomProtectionStandardDeviation = 8.8, CriticalOvertoppingDischargeMean = 9.9, CriticalOvertoppingDischargeCoefficientOfVariation = 10.10, FailureProbabilityStructureWithErosion = 0.11, WidthFlowAperturesMean = 12.12, WidthFlowAperturesStandardDeviation = 13.13, StormDurationMean = 14.14, UseBreakWater = Convert.ToByte(true), BreakWaterType = Convert.ToByte(BreakWaterType.Wall), BreakWaterHeight = 15.15, UseForeshore = Convert.ToByte(true), InflowModelType = Convert.ToByte(ClosingStructureInflowModelType.LowSill), InsideWaterLevelMean = 16.16, InsideWaterLevelStandardDeviation = 17.17, DeviationWaveDirection = 18.18, DrainCoefficientMean = 19.19, DrainCoefficientStandardDeviation = 20.20, FactorStormDurationOpenStructure = 21.21, ThresholdHeightOpenWeirMean = 22.22, ThresholdHeightOpenWeirStandardDeviation = 23.23, AreaFlowAperturesMean = 24.24, AreaFlowAperturesStandardDeviation = 25.25, FailureProbabilityOpenStructure = 0.26, FailureProbabilityReparation = 0.27, IdenticalApertures = 28, LevelCrestStructureNotClosingMean = 29.29, LevelCrestStructureNotClosingStandardDeviation = 30.30, ProbabilityOpenStructureBeforeFlooding = 0.31 }; var collector = new ReadConversionCollector(); // Call StructuresCalculationScenario <ClosingStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreEqual(entity.Name, calculation.Name); Assert.AreEqual(Convert.ToBoolean(entity.RelevantForScenario), calculation.IsRelevant); RoundedDoubleTestHelper.AssertRoundedDouble(entity.ScenarioContribution, calculation.Contribution); Assert.AreEqual(entity.Comments, calculation.Comments.Body); ClosingStructuresInput inputParameters = calculation.InputParameters; Assert.IsNull(inputParameters.ForeshoreProfile); Assert.IsNull(inputParameters.Structure); Assert.IsNull(inputParameters.HydraulicBoundaryLocation); Assert.AreEqual(entity.StructureNormalOrientation, inputParameters.StructureNormalOrientation.Value); Assert.AreEqual(entity.ModelFactorSuperCriticalFlowMean, inputParameters.ModelFactorSuperCriticalFlow.Mean.Value); Assert.AreEqual(entity.AllowedLevelIncreaseStorageMean, inputParameters.AllowedLevelIncreaseStorage.Mean.Value); Assert.AreEqual(entity.AllowedLevelIncreaseStorageStandardDeviation, inputParameters.AllowedLevelIncreaseStorage.StandardDeviation.Value); Assert.AreEqual(entity.StorageStructureAreaMean, inputParameters.StorageStructureArea.Mean.Value); Assert.AreEqual(entity.StorageStructureAreaCoefficientOfVariation, inputParameters.StorageStructureArea.CoefficientOfVariation.Value); Assert.AreEqual(entity.FlowWidthAtBottomProtectionMean, inputParameters.FlowWidthAtBottomProtection.Mean.Value); Assert.AreEqual(entity.FlowWidthAtBottomProtectionStandardDeviation, inputParameters.FlowWidthAtBottomProtection.StandardDeviation.Value); Assert.AreEqual(entity.CriticalOvertoppingDischargeMean, inputParameters.CriticalOvertoppingDischarge.Mean.Value); Assert.AreEqual(entity.CriticalOvertoppingDischargeCoefficientOfVariation, inputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation.Value); Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, inputParameters.FailureProbabilityStructureWithErosion); Assert.AreEqual(entity.WidthFlowAperturesMean, inputParameters.WidthFlowApertures.Mean.Value); Assert.AreEqual(entity.WidthFlowAperturesStandardDeviation, inputParameters.WidthFlowApertures.StandardDeviation.Value); Assert.AreEqual(entity.StormDurationMean, inputParameters.StormDuration.Mean.Value); Assert.AreEqual(Convert.ToBoolean(entity.UseBreakWater), inputParameters.UseBreakWater); Assert.AreEqual((BreakWaterType)entity.BreakWaterType, inputParameters.BreakWater.Type); Assert.AreEqual(entity.BreakWaterHeight, inputParameters.BreakWater.Height.Value); Assert.AreEqual(Convert.ToBoolean(entity.UseForeshore), inputParameters.UseForeshore); Assert.AreEqual((ClosingStructureInflowModelType)entity.InflowModelType, inputParameters.InflowModelType); Assert.AreEqual(entity.InsideWaterLevelMean, inputParameters.InsideWaterLevel.Mean.Value); Assert.AreEqual(entity.InsideWaterLevelStandardDeviation, inputParameters.InsideWaterLevel.StandardDeviation.Value); Assert.AreEqual(entity.DeviationWaveDirection, inputParameters.DeviationWaveDirection.Value); Assert.AreEqual(entity.DrainCoefficientMean, inputParameters.DrainCoefficient.Mean.Value); Assert.AreEqual(entity.DrainCoefficientStandardDeviation, inputParameters.DrainCoefficient.StandardDeviation.Value); Assert.AreEqual(entity.FactorStormDurationOpenStructure, inputParameters.FactorStormDurationOpenStructure.Value); Assert.AreEqual(entity.ThresholdHeightOpenWeirMean, inputParameters.ThresholdHeightOpenWeir.Mean.Value); Assert.AreEqual(entity.ThresholdHeightOpenWeirStandardDeviation, inputParameters.ThresholdHeightOpenWeir.StandardDeviation.Value); Assert.AreEqual(entity.AreaFlowAperturesMean, inputParameters.AreaFlowApertures.Mean.Value); Assert.AreEqual(entity.AreaFlowAperturesStandardDeviation, inputParameters.AreaFlowApertures.StandardDeviation.Value); Assert.AreEqual(entity.FailureProbabilityOpenStructure, inputParameters.FailureProbabilityOpenStructure); Assert.AreEqual(entity.FailureProbabilityReparation, inputParameters.FailureProbabilityReparation); Assert.AreEqual(entity.IdenticalApertures, inputParameters.IdenticalApertures); Assert.AreEqual(entity.LevelCrestStructureNotClosingMean, inputParameters.LevelCrestStructureNotClosing.Mean.Value); Assert.AreEqual(entity.LevelCrestStructureNotClosingStandardDeviation, inputParameters.LevelCrestStructureNotClosing.StandardDeviation.Value); Assert.AreEqual(entity.ProbabilityOpenStructureBeforeFlooding, inputParameters.ProbabilityOpenStructureBeforeFlooding); Assert.IsFalse(calculation.HasOutput); }