public void Constructor_ExpectedValues() { // Setup var modelFactorStorageVolume = new LogNormalDistribution(2) { Mean = (RoundedDouble)1.00, StandardDeviation = (RoundedDouble)0.20 }; var modelFactorOvertoppingFlow = new LogNormalDistribution(3) { Mean = (RoundedDouble)0.09, StandardDeviation = (RoundedDouble)0.06 }; // Call var generalHeightStructuresInput = new GeneralHeightStructuresInput(); // Assert Assert.AreEqual(2, generalHeightStructuresInput.N.NumberOfDecimalPlaces); Assert.AreEqual(2.0, generalHeightStructuresInput.N, generalHeightStructuresInput.N.GetAccuracy()); Assert.IsFalse(generalHeightStructuresInput.ApplyLengthEffectInSection); Assert.AreEqual(2, generalHeightStructuresInput.GravitationalAcceleration.NumberOfDecimalPlaces); Assert.AreEqual(9.81, generalHeightStructuresInput.GravitationalAcceleration, generalHeightStructuresInput.GravitationalAcceleration.GetAccuracy()); DistributionAssert.AreEqual(modelFactorOvertoppingFlow, generalHeightStructuresInput.ModelFactorOvertoppingFlow); DistributionAssert.AreEqual(modelFactorStorageVolume, generalHeightStructuresInput.ModelFactorStorageVolume); Assert.AreEqual(2, generalHeightStructuresInput.ModelFactorInflowVolume.NumberOfDecimalPlaces); Assert.AreEqual(1, generalHeightStructuresInput.ModelFactorInflowVolume, generalHeightStructuresInput.ModelFactorInflowVolume.GetAccuracy()); }
public void Constructor_ExpectedValues() { // Setup var random = new Random(21); var failureMechanism = new HeightStructuresFailureMechanism { InAssembly = random.NextBoolean() }; // Call var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Assert Assert.IsInstanceOf <HeightStructuresFailureMechanismPropertiesBase>(properties); Assert.AreEqual(failureMechanism.Name, properties.Name); Assert.AreEqual(failureMechanism.Code, properties.Code); Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); Assert.AreEqual(generalInput.N, properties.N, properties.N.GetAccuracy()); Assert.AreEqual(generalInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); }
public void N_SetValidValue_UpdatesValue(double value) { // Setup var generalHeightStructuresInput = new GeneralHeightStructuresInput(); // Call generalHeightStructuresInput.N = (RoundedDouble)value; // Assert Assert.AreEqual(2, generalHeightStructuresInput.N.NumberOfDecimalPlaces); Assert.AreEqual(value, generalHeightStructuresInput.N, generalHeightStructuresInput.N.GetAccuracy()); }
public void N_SetValueOutsideValidRange_ThrowArgumentOutOfRangeException(double value) { // Setup var generalHeightStructuresInput = new GeneralHeightStructuresInput(); // Call TestDelegate test = () => generalHeightStructuresInput.N = (RoundedDouble)value; // Assert const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(test, expectedMessage); }
public void Read_Always_ReturnGeneralHeightStructuresInput() { // Setup var entity = new HeightStructuresFailureMechanismMetaEntity { N = new Random(39).NextRoundedDouble(1.0, 20.0) }; // Call GeneralHeightStructuresInput generalInput = entity.Read(); // Assert Assert.AreEqual(entity.N, generalInput.N, generalInput.N.GetAccuracy()); }
public void Constructor_ExpectedValues() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); // Call var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Assert Assert.IsInstanceOf <HeightStructuresFailureMechanismPropertiesBase>(properties); Assert.AreSame(failureMechanism, properties.Data); Assert.AreEqual(failureMechanism.Name, properties.Name); Assert.AreEqual(failureMechanism.Code, properties.Code); GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(generalInput.GravitationalAcceleration, properties.GravitationalAcceleration); Assert.AreEqual(generalInput.ModelFactorOvertoppingFlow.Mean, properties.ModelFactorOvertoppingFlow.Mean); Assert.AreEqual(generalInput.ModelFactorOvertoppingFlow.StandardDeviation, properties.ModelFactorOvertoppingFlow.StandardDeviation); Assert.AreEqual(generalInput.ModelFactorStorageVolume.Mean, properties.ModelFactorStorageVolume.Mean); Assert.AreEqual(generalInput.ModelFactorStorageVolume.StandardDeviation, properties.ModelFactorStorageVolume.StandardDeviation); }
public void Calculate_VariousCalculationsWithBreakWater_InputPropertiesCorrectlySentToCalculator(BreakWaterType breakWaterType) { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); var mockRepository = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mockRepository); var calculator = new TestStructuresCalculator <StructuresOvertoppingCalculationInput>(); var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>(); calculatorFactory.Expect(cf => cf.CreateStructuresCalculator <StructuresOvertoppingCalculationInput>(null)) .IgnoreArguments() .Return(calculator); mockRepository.ReplayAll(); var calculation = new TestHeightStructuresCalculationScenario { InputParameters = { HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), ForeshoreProfile = new TestForeshoreProfile(true) { BreakWater = { Type = breakWaterType } } } }; using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call new HeightStructuresCalculationService().Calculate(calculation, failureMechanism.GeneralInput, CreateCalculationSettings()); // Assert StructuresOvertoppingCalculationInput[] overtoppingCalculationInputs = calculator.ReceivedInputs.ToArray(); Assert.AreEqual(1, overtoppingCalculationInputs.Length); GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; HeightStructuresInput input = calculation.InputParameters; var expectedInput = new StructuresOvertoppingCalculationInput( 1300001, input.StructureNormalOrientation, input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)), new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height), generalInput.GravitationalAcceleration, generalInput.ModelFactorOvertoppingFlow.Mean, generalInput.ModelFactorOvertoppingFlow.StandardDeviation, input.LevelCrestStructure.Mean, input.LevelCrestStructure.StandardDeviation, input.StructureNormalOrientation, input.ModelFactorSuperCriticalFlow.Mean, input.ModelFactorSuperCriticalFlow.StandardDeviation, input.AllowedLevelIncreaseStorage.Mean, input.AllowedLevelIncreaseStorage.StandardDeviation, generalInput.ModelFactorStorageVolume.Mean, generalInput.ModelFactorStorageVolume.StandardDeviation, input.StorageStructureArea.Mean, input.StorageStructureArea.CoefficientOfVariation, generalInput.ModelFactorInflowVolume, input.FlowWidthAtBottomProtection.Mean, input.FlowWidthAtBottomProtection.StandardDeviation, input.CriticalOvertoppingDischarge.Mean, input.CriticalOvertoppingDischarge.CoefficientOfVariation, input.FailureProbabilityStructureWithErosion, input.WidthFlowApertures.Mean, input.WidthFlowApertures.StandardDeviation, input.DeviationWaveDirection, input.StormDuration.Mean, input.StormDuration.CoefficientOfVariation); StructuresOvertoppingCalculationInput actualInput = overtoppingCalculationInputs[0]; HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput); Assert.IsFalse(calculator.IsCanceled); } mockRepository.VerifyAll(); }