public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new ObservablePropertyChangeHandler(calculation, input); var properties = new MacroStabilityInwardsDrainageProperties(input, handler); var random = new Random(21); bool constructionPresent = random.NextBoolean(); double xCoordinateDrainageConstruction = random.NextDouble(); double zCoordinateDrainageConstruction = random.NextDouble(); // When properties.DrainageConstructionPresent = constructionPresent; properties.XCoordinateDrainageConstruction = (RoundedDouble)xCoordinateDrainageConstruction; properties.ZCoordinateDrainageConstruction = (RoundedDouble)zCoordinateDrainageConstruction; // Then Assert.AreEqual(constructionPresent, input.DrainageConstructionPresent); Assert.AreEqual(xCoordinateDrainageConstruction, input.XCoordinateDrainageConstruction, input.XCoordinateDrainageConstruction.GetAccuracy()); Assert.AreEqual(zCoordinateDrainageConstruction, input.ZCoordinateDrainageConstruction, input.ZCoordinateDrainageConstruction.GetAccuracy()); }
private void UpdateInputChartData() { MacroStabilityInwardsInput input = data.InputParameters; MacroStabilityInwardsSurfaceLine surfaceLine = input.SurfaceLine; IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> soilProfile = input.StochasticSoilProfile?.SoilProfile; if (!ReferenceEquals(currentSoilProfile, soilProfile) || !ReferenceEquals(currentSurfaceLine, surfaceLine)) { currentSoilProfile = soilProfile; currentSurfaceLine = surfaceLine; SetSoilProfileChartData(); } SetWaternetExtremeChartData(DerivedMacroStabilityInwardsInput.GetWaternetExtreme(input, generalInput, GetEffectiveAssessmentLevel())); SetWaternetDailyChartData(DerivedMacroStabilityInwardsInput.GetWaternetDaily(input, generalInput)); if (data.Output != null) { SetSurfaceLineChartData(surfaceLine); SetSoilLayerAreas(); SetWaternetDatas(surfaceLine); } else { SetSurfaceLineChartData(null); SetEmptySoilLayerAreas(); SetEmptyWaternets(); } soilProfileChartData.Collection.ForEachElementDo(sp => sp.NotifyObservers()); waternetZonesDailyChartData.Collection.ForEachElementDo(cd => cd.NotifyObservers()); waternetZonesExtremeChartData.Collection.ForEachElementDo(cd => cd.NotifyObservers()); }
public void DynamicReadOnlyValidationMethod_DrainageConstructionPresent_DependsOnSoilScenario( [Values(true, false)] bool drainageConstructionPresent, [Values(MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand, MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay, MacroStabilityInwardsDikeSoilScenario.SandDikeOnSand, MacroStabilityInwardsDikeSoilScenario.SandDikeOnClay)] MacroStabilityInwardsDikeSoilScenario soilScenario) { // Setup var mocks = new MockRepository(); var handler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { DrainageConstructionPresent = drainageConstructionPresent, DikeSoilScenario = soilScenario }; var properties = new MacroStabilityInwardsDrainageProperties(input, handler); // Call bool result = properties.DynamicReadOnlyValidationMethod(nameof(properties.DrainageConstructionPresent)); // Assert bool isClayDike = input.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay || input.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand; Assert.AreEqual(isClayDike, result); }
public void ParameteredConstructor_CalculationNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var calculationInput = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); var surfaceLines = new[] { new MacroStabilityInwardsSurfaceLine(string.Empty) }; MacroStabilityInwardsStochasticSoilModel[] stochasticSoilModels = { MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel() }; var failureMechanism = new MacroStabilityInwardsFailureMechanism(); // Call TestDelegate call = () => new MacroStabilityInwardsInputContext(calculationInput, null, surfaceLines, stochasticSoilModels, failureMechanism, assessmentSection); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("calculation", exception.ParamName); mocks.VerifyAll(); }
private static bool ValidateSurfaceLineIsNearSoilProfile(MacroStabilityInwardsInput inputParameters, MacroStabilityInwardsSoilProfile2D soilProfile2D) { IEnumerable <double> discretizedSurfaceLineXCoordinates = GetClippedDiscretizedXCoordinatesOfSurfaceLine(inputParameters.SurfaceLine.LocalGeometry, soilProfile2D); IEnumerable <Point2D> surfaceLineWithInterpolations = GetSurfaceLineWithInterpolations(inputParameters, discretizedSurfaceLineXCoordinates); IEnumerable <IEnumerable <Segment2D> > layerPolygons = GetLayerPolygons(soilProfile2D); foreach (Point2D surfaceLinePoint in surfaceLineWithInterpolations) { IEnumerable <Point2D> intersectingCoordinates = layerPolygons.SelectMany(lp => Math2D.SegmentsIntersectionWithVerticalLine(lp, surfaceLinePoint.X)); if (!intersectingCoordinates.Any()) { return(false); } double maxYCoordinate = intersectingCoordinates.Select(p => p.Y).Max(); if (Math.Abs(surfaceLinePoint.Y - maxYCoordinate) - withinSurfaceLineLevelLimit >= 1e-5) { return(false); } } return(true); }
public void Create_WithValidData_ReturnsPersistableWaternetCreatorSettingsCollection() { // Setup MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput( new TestHydraulicBoundaryLocation()); MacroStabilityInwardsInput input = calculation.InputParameters; RoundedDouble normativeAssessmentLevel = RoundedDouble.NaN; var idFactory = new IdFactory(); var registry = new MacroStabilityInwardsExportRegistry(); PersistableGeometryFactory.Create(input.SoilProfileUnderSurfaceLine, idFactory, registry); // Call IEnumerable <PersistableWaternetCreatorSettings> waternetCreatorSettingsCollection = PersistableWaternetCreatorSettingsFactory.Create(input, normativeAssessmentLevel, idFactory, registry); // Assert var stages = new[] { MacroStabilityInwardsExportStageType.Daily, MacroStabilityInwardsExportStageType.Extreme }; PersistableDataModelTestHelper.AssertWaternetCreatorSettings(input, waternetCreatorSettingsCollection, normativeAssessmentLevel, stages); AssertRegistry(registry, stages, waternetCreatorSettingsCollection); }
public void SetMatchingStochasticSoilModel_CurrentSoilModelNotInOverlappingMultipleSoilModels_ClearsModel() { // Setup MacroStabilityInwardsStochasticSoilModel nonOverlappingSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("A"); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { StochasticSoilModel = nonOverlappingSoilModel }; MacroStabilityInwardsStochasticSoilModel soilModel1 = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("A"); MacroStabilityInwardsStochasticSoilModel soilModel2 = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("C"); // Call MacroStabilityInwardsInputService.SetMatchingStochasticSoilModel(input, new[] { soilModel1, soilModel2 }); // Assert Assert.IsNull(input.StochasticSoilModel); }
public void RemoveStochasticSoilProfileFromInput_NoCalculationsWithProfile_ReturnNoAffectedObjects() { // Setup MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations(); IEnumerable <MacroStabilityInwardsCalculationScenario> calculations = failureMechanism.Calculations .Cast <MacroStabilityInwardsCalculationScenario>(); MacroStabilityInwardsStochasticSoilProfile profileToDelete = null; foreach (MacroStabilityInwardsCalculationScenario calculationScenario in calculations) { MacroStabilityInwardsInput input = calculationScenario.InputParameters; MacroStabilityInwardsStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; } if (profileToDelete != null && ReferenceEquals(profileToDelete, currentProfile)) { input.StochasticSoilProfile = null; } } // Call IEnumerable <IObservable> affected = MacroStabilityInwardsDataSynchronizationService.RemoveStochasticSoilProfileFromInput(failureMechanism, profileToDelete); // Assert CollectionAssert.IsEmpty(affected); }
public void Read_EntityWithStochasticSoilModel_ReturnCalculationScenarioWithInputObjectWithStochasticSoilModelPropertiesSet() { // Setup var random = new Random(21); MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(); var stochasticSoilModelEntity = new StochasticSoilModelEntity(); var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(), MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D()); var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity { StochasticSoilModelEntity = stochasticSoilModelEntity }; var collector = new ReadConversionCollector(); collector.Read(stochasticSoilModelEntity, stochasticSoilModel); collector.Read(stochasticSoilProfileEntity, stochasticSoilProfile); MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); entity.MacroStabilityInwardsStochasticSoilProfileEntity = stochasticSoilProfileEntity; // Call MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector); // Assert MacroStabilityInwardsInput inputParameters = calculation.InputParameters; Assert.AreSame(stochasticSoilModel, inputParameters.StochasticSoilModel); Assert.AreSame(stochasticSoilProfile, inputParameters.StochasticSoilProfile); }
public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine("Surface line"); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 0), new Point3D(1, 1, 1) }); MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(); MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = stochasticSoilModel.StochasticSoilProfiles.First(); // Precondition Assert.IsNotNull(stochasticSoilProfile); var original = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); MacroStabilityInwardsTestDataGenerator.SetRandomMacroStabilityInwardsInput(original); // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones); }
public void Constructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var propertyChangeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); // Call var properties = new MacroStabilityInwardsWaterStressesProperties(input, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel(), propertyChangeHandler); // Assert Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsInput> >(properties); Assert.AreSame(input, properties.Data); TestHelper.AssertTypeConverter <MacroStabilityInwardsWaterStressesProperties, ExpandableObjectConverter>( nameof(MacroStabilityInwardsWaterStressesProperties.Drainage)); TestHelper.AssertTypeConverter <MacroStabilityInwardsWaterStressesProperties, ExpandableObjectConverter>( nameof(MacroStabilityInwardsWaterStressesProperties.LocationDaily)); TestHelper.AssertTypeConverter <MacroStabilityInwardsWaterStressesProperties, ExpandableObjectConverter>( nameof(MacroStabilityInwardsWaterStressesProperties.LocationExtreme)); TestHelper.AssertTypeConverter <MacroStabilityInwardsWaterStressesProperties, ExpandableObjectConverter>( nameof(MacroStabilityInwardsWaterStressesProperties.WaterStressLines)); mocks.VerifyAll(); }
public void ClearStochasticSoilProfileDependentData_NoCalculationsWithOutputWithProfile_ReturnInput() { // Setup MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations(); IEnumerable <MacroStabilityInwardsCalculationScenario> calculations = failureMechanism.Calculations .Cast <MacroStabilityInwardsCalculationScenario>(); MacroStabilityInwardsStochasticSoilProfile profileToDelete = null; var expectedInputs = new List <MacroStabilityInwardsInput>(); foreach (MacroStabilityInwardsCalculationScenario calculationScenario in calculations) { MacroStabilityInwardsInput input = calculationScenario.InputParameters; MacroStabilityInwardsStochasticSoilProfile currentProfile = input.StochasticSoilProfile; if (profileToDelete == null) { profileToDelete = currentProfile; } if (profileToDelete != null && ReferenceEquals(profileToDelete, currentProfile)) { calculationScenario.ClearOutput(); expectedInputs.Add(input); } } // Call IEnumerable <IObservable> affected = MacroStabilityInwardsDataSynchronizationService.ClearStochasticSoilProfileDependentData(failureMechanism, profileToDelete); // Assert CollectionAssert.AreEquivalent(expectedInputs, affected); CollectionAssert.IsEmpty(affected.Cast <MacroStabilityInwardsInput>().Where(a => a.StochasticSoilProfile == null)); }
public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnGrid() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; MacroStabilityInwardsGrid grid = input.LeftGrid; var handler = new ObservablePropertyChangeHandler(calculation, input); var properties = new MacroStabilityInwardsGridProperties(grid, handler, false); var random = new Random(21); RoundedDouble xLeft = random.NextRoundedDouble(); var xRight = (RoundedDouble)(1 + random.NextDouble()); var zTop = (RoundedDouble)(1 + random.NextDouble()); RoundedDouble zBottom = random.NextRoundedDouble(); int numberOfHorizontalPoints = random.Next(1, 100); int numberOfVerticalPoints = random.Next(1, 100); // When properties.XLeft = xLeft; properties.XRight = xRight; properties.ZTop = zTop; properties.ZBottom = zBottom; properties.NumberOfHorizontalPoints = numberOfHorizontalPoints; properties.NumberOfVerticalPoints = numberOfVerticalPoints; // Then Assert.AreEqual(xLeft, grid.XLeft, grid.XLeft.GetAccuracy()); Assert.AreEqual(xRight, grid.XRight, grid.XRight.GetAccuracy()); Assert.AreEqual(zTop, grid.ZTop, grid.ZTop.GetAccuracy()); Assert.AreEqual(zBottom, grid.ZBottom, grid.ZBottom.GetAccuracy()); Assert.AreEqual(numberOfHorizontalPoints, grid.NumberOfHorizontalPoints); Assert.AreEqual(numberOfVerticalPoints, grid.NumberOfVerticalPoints); }
private static IEnumerable <string> ValidateZoneBoundaries(MacroStabilityInwardsInput inputParameters) { if (!inputParameters.CreateZones || inputParameters.ZoningBoundariesDeterminationType == MacroStabilityInwardsZoningBoundariesDeterminationType.Automatic) { yield break; } RoundedDouble zoneBoundaryLeft = inputParameters.ZoneBoundaryLeft; RoundedDouble zoneBoundaryRight = inputParameters.ZoneBoundaryRight; if (zoneBoundaryLeft > zoneBoundaryRight) { yield return(Resources.MacroStabilityInwardsInputValidator_ValidateZoneBoundaries_ZoneBoundaries_BoundaryLeft_should_be_smaller_than_or_equal_to_BoundaryRight); } MacroStabilityInwardsSurfaceLine surfaceLine = inputParameters.SurfaceLine; if (!surfaceLine.ValidateInRange(zoneBoundaryLeft) || !surfaceLine.ValidateInRange(zoneBoundaryRight)) { var validityRange = new Range <double>(surfaceLine.LocalGeometry.First().X, surfaceLine.LocalGeometry.Last().X); yield return(string.Format(Resources.MacroStabilityInwardsInputValidator_ValidateZoneBoundaries_ZoneBoundaries_must_be_in_Range_0, validityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture))); } }
public void DynamicReadOnly_TangentLineDeterminationType_ReturnsExpectedResult( [Values(true, false)] bool isTangentlineDeterminationTypeLayerSeparated, [Values(true, false)] bool isGridDeterminationTypeAutomatic, [Values(nameof(MacroStabilityInwardsGridSettingsProperties.TangentLineZTop), nameof(MacroStabilityInwardsGridSettingsProperties.TangentLineZBottom), nameof(MacroStabilityInwardsGridSettingsProperties.TangentLineNumber))] string propertyName) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { TangentLineDeterminationType = isTangentlineDeterminationTypeLayerSeparated ? MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated : MacroStabilityInwardsTangentLineDeterminationType.Specified, GridDeterminationType = isGridDeterminationTypeAutomatic ? MacroStabilityInwardsGridDeterminationType.Automatic : MacroStabilityInwardsGridDeterminationType.Manual }; var properties = new MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Call bool result = properties.DynamicReadOnlyValidationMethod(propertyName); // Assert Assert.AreEqual(isTangentlineDeterminationTypeLayerSeparated || isGridDeterminationTypeAutomatic, result); }
private static void SetPropertyAndVerifyNotificationsForCalculation(Action <MacroStabilityInwardsGridSettingsProperties> setProperty, MacroStabilityInwardsCalculation calculation) { // Setup var mocks = new MockRepository(); var observable = mocks.StrictMock <IObservable>(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] { observable }); var properties = new MacroStabilityInwardsGridSettingsProperties(input, handler); // Call setProperty(properties); // Assert Assert.IsTrue(handler.Called); mocks.VerifyAll(); }
public void GetProperties_WithData_ReturnExpectedValues( MacroStabilityInwardsGridDeterminationType gridDeterminationType) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { GridDeterminationType = gridDeterminationType }; // Call var properties = new MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Assert Assert.AreEqual(input.MoveGrid, properties.MoveGrid); Assert.AreEqual(input.GridDeterminationType, properties.GridDeterminationType); Assert.AreEqual(input.TangentLineDeterminationType, properties.TangentLineDeterminationType); Assert.AreEqual(input.TangentLineZTop, properties.TangentLineZTop); Assert.AreEqual(input.TangentLineZBottom, properties.TangentLineZBottom); Assert.AreEqual(input.TangentLineNumber, properties.TangentLineNumber); bool gridIsReadOnly = gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic; Assert.AreSame(input.LeftGrid, properties.LeftGrid.Data); Assert.AreEqual(gridIsReadOnly, properties.LeftGrid.DynamicReadOnlyValidationMethod(string.Empty)); Assert.AreSame(input.RightGrid, properties.RightGrid.Data); Assert.AreEqual(gridIsReadOnly, properties.RightGrid.DynamicReadOnlyValidationMethod(string.Empty)); mocks.VerifyAll(); }
public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new ObservablePropertyChangeHandler(calculation, input); var properties = new MacroStabilityInwardsGridSettingsProperties(input, handler); var random = new Random(21); bool moveGrid = random.NextBoolean(); var gridDeterminationType = random.NextEnumValue <MacroStabilityInwardsGridDeterminationType>(); var tangentLineDeterminationType = random.NextEnumValue <MacroStabilityInwardsTangentLineDeterminationType>(); double tangentLineZTop = random.NextDouble(2.0, 3.0); double tangentLineZBottom = random.NextDouble(0.0, 1.0); int tangentLineNumber = random.Next(1, 51); // When properties.MoveGrid = moveGrid; properties.GridDeterminationType = gridDeterminationType; properties.TangentLineDeterminationType = tangentLineDeterminationType; properties.TangentLineZTop = (RoundedDouble)tangentLineZTop; properties.TangentLineZBottom = (RoundedDouble)tangentLineZBottom; properties.TangentLineNumber = tangentLineNumber; // Then Assert.AreEqual(moveGrid, input.MoveGrid); Assert.AreEqual(gridDeterminationType, input.GridDeterminationType); Assert.AreEqual(tangentLineDeterminationType, input.TangentLineDeterminationType); Assert.AreEqual(tangentLineZTop, input.TangentLineZTop, input.TangentLineZTop.GetAccuracy()); Assert.AreEqual(tangentLineZBottom, input.TangentLineZBottom, input.TangentLineZBottom.GetAccuracy()); Assert.AreEqual(tangentLineNumber, input.TangentLineNumber); }
/// <summary> /// Gets a <see cref="MacroStabilityInwardsCalculationScenario"/> with <c>double.NaN</c> values set. /// </summary> /// <returns>A <see cref="MacroStabilityInwardsCalculationScenario"/> with <c>double.NaN</c> values.</returns> public static MacroStabilityInwardsCalculationScenario GetMacroStabilityInwardsCalculationScenarioWithNaNs() { MacroStabilityInwardsCalculationScenario calculation = GetMacroStabilityInwardsCalculationScenarioWithAssessmentLevel(); MacroStabilityInwardsInput input = calculation.InputParameters; input.WaterLevelRiverAverage = RoundedDouble.NaN; input.XCoordinateDrainageConstruction = RoundedDouble.NaN; input.ZCoordinateDrainageConstruction = RoundedDouble.NaN; input.MinimumLevelPhreaticLineAtDikeTopPolder = RoundedDouble.NaN; input.MinimumLevelPhreaticLineAtDikeTopRiver = RoundedDouble.NaN; input.LeakageLengthInwardsPhreaticLine3 = RoundedDouble.NaN; input.LeakageLengthOutwardsPhreaticLine3 = RoundedDouble.NaN; input.LeakageLengthInwardsPhreaticLine4 = RoundedDouble.NaN; input.LeakageLengthOutwardsPhreaticLine4 = RoundedDouble.NaN; input.PiezometricHeadPhreaticLine2Inwards = RoundedDouble.NaN; input.PiezometricHeadPhreaticLine2Outwards = RoundedDouble.NaN; input.AssessmentLevel = RoundedDouble.NaN; input.SlipPlaneMinimumDepth = RoundedDouble.NaN; input.SlipPlaneMinimumLength = RoundedDouble.NaN; input.MaximumSliceWidth = RoundedDouble.NaN; input.TangentLineZTop = RoundedDouble.NaN; input.TangentLineZBottom = RoundedDouble.NaN; input.LeftGrid.XLeft = RoundedDouble.NaN; input.LeftGrid.XRight = RoundedDouble.NaN; input.LeftGrid.ZTop = RoundedDouble.NaN; input.LeftGrid.ZBottom = RoundedDouble.NaN; input.RightGrid.XLeft = RoundedDouble.NaN; input.RightGrid.XRight = RoundedDouble.NaN; input.RightGrid.ZTop = RoundedDouble.NaN; input.RightGrid.ZBottom = RoundedDouble.NaN; IMacroStabilityInwardsLocationInputDaily inputDaily = input.LocationInputDaily; inputDaily.WaterLevelPolder = RoundedDouble.NaN; inputDaily.PhreaticLineOffsetBelowDikeTopAtRiver = RoundedDouble.NaN; inputDaily.PhreaticLineOffsetBelowDikeTopAtPolder = RoundedDouble.NaN; inputDaily.PhreaticLineOffsetBelowShoulderBaseInside = RoundedDouble.NaN; inputDaily.PhreaticLineOffsetBelowDikeToeAtPolder = RoundedDouble.NaN; IMacroStabilityInwardsLocationInputExtreme inputExtreme = input.LocationInputExtreme; inputExtreme.PenetrationLength = RoundedDouble.NaN; inputExtreme.WaterLevelPolder = RoundedDouble.NaN; inputExtreme.PhreaticLineOffsetBelowDikeTopAtRiver = RoundedDouble.NaN; inputExtreme.PhreaticLineOffsetBelowDikeTopAtPolder = RoundedDouble.NaN; inputExtreme.PhreaticLineOffsetBelowShoulderBaseInside = RoundedDouble.NaN; inputExtreme.PhreaticLineOffsetBelowDikeToeAtPolder = RoundedDouble.NaN; input.ZoneBoundaryLeft = RoundedDouble.NaN; input.ZoneBoundaryRight = RoundedDouble.NaN; return(calculation); }
public void Convert_MacroStabilityInwardsGridDeterminationTypeAutomatic_ReturnUpliftVanSlipPlane() { // Setup var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties { TangentLineZTop = 1, TangentLineZBottom = 0 }) { GridDeterminationType = MacroStabilityInwardsGridDeterminationType.Automatic, TangentLineDeterminationType = MacroStabilityInwardsTangentLineDeterminationType.Specified, TangentLineNumber = 10 }; // Precondition Assert.IsNotNull(input.LeftGrid); Assert.IsNotNull(input.RightGrid); // Call UpliftVanSlipPlane slipPlane = UpliftVanSlipPlaneConverter.Convert(input); // Assert Assert.IsTrue(slipPlane.GridAutomaticDetermined); Assert.IsNull(slipPlane.LeftGrid); Assert.IsNull(slipPlane.RightGrid); Assert.IsTrue(slipPlane.TangentLinesAutomaticAtBoundaries); Assert.IsNaN(slipPlane.TangentZTop); Assert.IsNaN(slipPlane.TangentZBottom); Assert.AreEqual(0, slipPlane.TangentLineNumber); }
public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new ObservablePropertyChangeHandler(calculation, input); var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler); var random = new Random(21); bool createZones = random.NextBoolean(); var determinationType = random.NextEnumValue <MacroStabilityInwardsZoningBoundariesDeterminationType>(); RoundedDouble boundaryLeft = random.NextRoundedDouble(); RoundedDouble boundaryRight = random.NextRoundedDouble(); // When properties.CreateZones = createZones; properties.ZoningBoundariesDeterminationType = determinationType; properties.ZoneBoundaryLeft = boundaryLeft; properties.ZoneBoundaryRight = boundaryRight; // Then Assert.AreEqual(createZones, input.CreateZones); Assert.AreEqual(determinationType, input.ZoningBoundariesDeterminationType); Assert.AreEqual(boundaryLeft, input.ZoneBoundaryLeft, input.ZoneBoundaryLeft.GetAccuracy()); Assert.AreEqual(boundaryRight, input.ZoneBoundaryRight, input.ZoneBoundaryRight.GetAccuracy()); }
public void DynamicReadOnlyValidationMethod_WithCreateZonesAndZoningBoundariesDeterminationType_ReturnsExpectedValues( bool createZones, MacroStabilityInwardsZoningBoundariesDeterminationType zoningBoundariesDeterminationType, bool expectedDeterminationTypeReadOnly, bool expectedZoneBoundariesReadOnly) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { CreateZones = createZones, ZoningBoundariesDeterminationType = zoningBoundariesDeterminationType }; var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Call bool isZoningBoundariesDeterminationTypeReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoningBoundariesDeterminationType)); bool isZoneBoundaryLeftReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryLeft)); bool isZoneBoundaryRightReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryRight)); // Assert Assert.AreEqual(expectedDeterminationTypeReadOnly, isZoningBoundariesDeterminationTypeReadOnly); Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryLeftReadOnly); Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryRightReadOnly); }
public void DynamicReadOnlyValidationMethod_OtherDikeSoilScenario_ReturnsExpectedReadOnly(MacroStabilityInwardsDikeSoilScenario dikeSoilScenario) { // Setup var mocks = new MockRepository(); var propertyChangeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { DikeSoilScenario = dikeSoilScenario }; var properties = new MacroStabilityInwardsWaterStressesProperties(input, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel(), propertyChangeHandler); // Call & Assert Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.AdjustPhreaticLine3And4ForUplift))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine3))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine3))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthInwardsPhreaticLine4))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.LeakageLengthOutwardsPhreaticLine4))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Inwards))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.PiezometricHeadPhreaticLine2Outwards))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.WaterLevelRiverAverage))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopPolder))); Assert.IsFalse(properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsWaterStressesProperties.MinimumLevelPhreaticLineAtDikeTopRiver))); }
public void Constructor_ValidData_PropertiesHaveExpectedAttributeValues() { // Setup var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); // Call var properties = new MacroStabilityInwardsWaterStressLinesProperties(input, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel()); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(2, dynamicProperties.Count); const string waterStressesCategoryName = "Waterspanningen"; PropertyDescriptor waternetExtremeProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waternetExtremeProperty, waterStressesCategoryName, "Extreme omstandigheden", "Eigenschappen van de waterspanningslijnen bij extreme omstandigheden.", true); PropertyDescriptor waternetDailyProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waternetDailyProperty, waterStressesCategoryName, "Dagelijkse omstandigheden", "Eigenschappen van de waterspanningslijnen bij dagelijkse omstandigheden.", true); }
private static IEnumerable <string> ValidateTangentLines(MacroStabilityInwardsInput inputParameters) { if (inputParameters.TangentLineZTop == inputParameters.TangentLineZBottom && inputParameters.TangentLineNumber != 1) { yield return(Resources.MacroStabilityInwardsInputValidator_ValidateTangentLines_TangentLineNumber_must_be_one_when_TangentLineTop_equals_TangentLineBottom); } }
private static IEnumerable <IObservable> ClearSurfaceLine(MacroStabilityInwardsInput input) { input.SurfaceLine = null; return(new[] { input }); }
private static void SetSurfaceLineToInput(MacroStabilityInwardsInput inputParameters, MacroStabilityInwardsCalculationEntity entity, ReadConversionCollector collector) { if (entity.SurfaceLineEntity != null) { inputParameters.SurfaceLine = entity.SurfaceLineEntity.ReadAsMacroStabilityInwardsSurfaceLine(collector); } }
/// <summary> /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/> /// are clones. /// </summary> /// <param name="original">The original object.</param> /// <param name="clone">The cloned object.</param> /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and /// <paramref name="clone"/> are not clones.</exception> public static void AreClones(MacroStabilityInwardsInput original, MacroStabilityInwardsInput clone) { Assert.AreSame(original.HydraulicBoundaryLocation, clone.HydraulicBoundaryLocation); Assert.AreSame(original.StochasticSoilModel, clone.StochasticSoilModel); Assert.AreSame(original.StochasticSoilProfile, clone.StochasticSoilProfile); Assert.AreSame(original.SurfaceLine, clone.SurfaceLine); Assert.AreEqual(original.AssessmentLevel, clone.AssessmentLevel); Assert.AreEqual(original.UseAssessmentLevelManualInput, clone.UseAssessmentLevelManualInput); Assert.AreEqual(original.SlipPlaneMinimumDepth, clone.SlipPlaneMinimumDepth); Assert.AreEqual(original.SlipPlaneMinimumLength, clone.SlipPlaneMinimumLength); Assert.AreEqual(original.MaximumSliceWidth, clone.MaximumSliceWidth); Assert.AreEqual(original.MoveGrid, clone.MoveGrid); Assert.AreEqual(original.DikeSoilScenario, clone.DikeSoilScenario); Assert.AreEqual(original.WaterLevelRiverAverage, clone.WaterLevelRiverAverage); Assert.AreEqual(original.DrainageConstructionPresent, clone.DrainageConstructionPresent); Assert.AreEqual(original.XCoordinateDrainageConstruction, clone.XCoordinateDrainageConstruction); Assert.AreEqual(original.ZCoordinateDrainageConstruction, clone.ZCoordinateDrainageConstruction); Assert.AreEqual(original.MinimumLevelPhreaticLineAtDikeTopRiver, clone.MinimumLevelPhreaticLineAtDikeTopRiver); Assert.AreEqual(original.MinimumLevelPhreaticLineAtDikeTopPolder, clone.MinimumLevelPhreaticLineAtDikeTopPolder); CoreCloneAssert.AreObjectClones((MacroStabilityInwardsLocationInputExtreme)original.LocationInputExtreme, clone.LocationInputExtreme, AreClones); CoreCloneAssert.AreObjectClones((MacroStabilityInwardsLocationInputDaily)original.LocationInputDaily, clone.LocationInputDaily, AreClones); Assert.AreEqual(original.AdjustPhreaticLine3And4ForUplift, clone.AdjustPhreaticLine3And4ForUplift); Assert.AreEqual(original.LeakageLengthOutwardsPhreaticLine3, clone.LeakageLengthOutwardsPhreaticLine3); Assert.AreEqual(original.LeakageLengthInwardsPhreaticLine3, clone.LeakageLengthInwardsPhreaticLine3); Assert.AreEqual(original.LeakageLengthOutwardsPhreaticLine4, clone.LeakageLengthOutwardsPhreaticLine4); Assert.AreEqual(original.LeakageLengthInwardsPhreaticLine4, clone.LeakageLengthInwardsPhreaticLine4); Assert.AreEqual(original.PiezometricHeadPhreaticLine2Outwards, clone.PiezometricHeadPhreaticLine2Outwards); Assert.AreEqual(original.PiezometricHeadPhreaticLine2Inwards, clone.PiezometricHeadPhreaticLine2Inwards); Assert.AreEqual(original.GridDeterminationType, clone.GridDeterminationType); Assert.AreEqual(original.TangentLineDeterminationType, clone.TangentLineDeterminationType); Assert.AreEqual(original.TangentLineZTop, clone.TangentLineZTop); Assert.AreEqual(original.TangentLineZBottom, clone.TangentLineZBottom); Assert.AreEqual(original.TangentLineNumber, clone.TangentLineNumber); CoreCloneAssert.AreObjectClones(original.LeftGrid, clone.LeftGrid, AreClones); CoreCloneAssert.AreObjectClones(original.RightGrid, clone.RightGrid, AreClones); Assert.AreEqual(original.CreateZones, clone.CreateZones); Assert.AreEqual(original.ZoningBoundariesDeterminationType, clone.ZoningBoundariesDeterminationType); Assert.AreEqual(original.ZoneBoundaryLeft, clone.ZoneBoundaryLeft); Assert.AreEqual(original.ZoneBoundaryRight, clone.ZoneBoundaryRight); }
private static IEnumerable <IObservable> ClearStochasticSoilProfile(MacroStabilityInwardsInput input) { input.StochasticSoilProfile = null; return(new[] { input }); }
public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; var propertyChangeHandler = new ObservablePropertyChangeHandler(calculation, input); var properties = new MacroStabilityInwardsWaterStressesProperties(input, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel(), propertyChangeHandler); var random = new Random(21); double waterLevelRiverAverage = random.NextDouble(); double minimumLevelPhreaticLineAtDikeTopRiver = random.NextDouble(); double minimumLevelPhreaticLineAtDikeTopPolder = random.NextDouble(); bool adjustPhreaticLine3And4ForUplift = random.NextBoolean(); double leakageLengthOutwardsPhreaticLine3 = random.NextDouble(); double leakageLengthInwardsPhreaticLine3 = random.NextDouble(); double leakageLengthOutwardsPhreaticLine4 = random.NextDouble(); double leakageLengthInwardsPhreaticLine4 = random.NextDouble(); double piezometricHeadPhreaticLine2Outwards = random.NextDouble(); double piezometricHeadPhreaticLine2Inwards = random.NextDouble(); // When properties.WaterLevelRiverAverage = (RoundedDouble)waterLevelRiverAverage; properties.MinimumLevelPhreaticLineAtDikeTopRiver = (RoundedDouble)minimumLevelPhreaticLineAtDikeTopRiver; properties.MinimumLevelPhreaticLineAtDikeTopPolder = (RoundedDouble)minimumLevelPhreaticLineAtDikeTopPolder; properties.AdjustPhreaticLine3And4ForUplift = adjustPhreaticLine3And4ForUplift; properties.LeakageLengthOutwardsPhreaticLine3 = (RoundedDouble)leakageLengthOutwardsPhreaticLine3; properties.LeakageLengthInwardsPhreaticLine3 = (RoundedDouble)leakageLengthInwardsPhreaticLine3; properties.LeakageLengthOutwardsPhreaticLine4 = (RoundedDouble)leakageLengthOutwardsPhreaticLine4; properties.LeakageLengthInwardsPhreaticLine4 = (RoundedDouble)leakageLengthInwardsPhreaticLine4; properties.PiezometricHeadPhreaticLine2Outwards = (RoundedDouble)piezometricHeadPhreaticLine2Outwards; properties.PiezometricHeadPhreaticLine2Inwards = (RoundedDouble)piezometricHeadPhreaticLine2Inwards; // Then Assert.AreEqual(waterLevelRiverAverage, input.WaterLevelRiverAverage, input.WaterLevelRiverAverage.GetAccuracy()); Assert.AreEqual(minimumLevelPhreaticLineAtDikeTopRiver, input.MinimumLevelPhreaticLineAtDikeTopRiver, input.MinimumLevelPhreaticLineAtDikeTopRiver.GetAccuracy()); Assert.AreEqual(minimumLevelPhreaticLineAtDikeTopPolder, input.MinimumLevelPhreaticLineAtDikeTopPolder, input.MinimumLevelPhreaticLineAtDikeTopPolder.GetAccuracy()); Assert.AreEqual(adjustPhreaticLine3And4ForUplift, input.AdjustPhreaticLine3And4ForUplift); Assert.AreEqual(leakageLengthOutwardsPhreaticLine3, input.LeakageLengthOutwardsPhreaticLine3, input.LeakageLengthOutwardsPhreaticLine3.GetAccuracy()); Assert.AreEqual(leakageLengthInwardsPhreaticLine3, input.LeakageLengthInwardsPhreaticLine3, input.LeakageLengthInwardsPhreaticLine3.GetAccuracy()); Assert.AreEqual(leakageLengthOutwardsPhreaticLine4, input.LeakageLengthOutwardsPhreaticLine4, input.LeakageLengthOutwardsPhreaticLine4.GetAccuracy()); Assert.AreEqual(leakageLengthInwardsPhreaticLine4, input.LeakageLengthInwardsPhreaticLine4, input.LeakageLengthInwardsPhreaticLine4.GetAccuracy()); Assert.AreEqual(piezometricHeadPhreaticLine2Outwards, input.PiezometricHeadPhreaticLine2Outwards, input.PiezometricHeadPhreaticLine2Outwards.GetAccuracy()); Assert.AreEqual(piezometricHeadPhreaticLine2Inwards, input.PiezometricHeadPhreaticLine2Inwards, input.PiezometricHeadPhreaticLine2Inwards.GetAccuracy()); }