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 ConvertFrom_InvalidMacroStabilityInwardsGridDeterminationType_ThrowsInvalidEnumArgumentException() { // Setup const MacroStabilityInwardsGridDeterminationType invalidValue = (MacroStabilityInwardsGridDeterminationType)9999; var converter = new ConfigurationGridDeterminationTypeConverter(); // Call TestDelegate call = () => converter.ConvertFrom(invalidValue); // Assert string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(MacroStabilityInwardsGridDeterminationType)}'."; string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("value", parameterName); }
private void SetChartData() { MacroStabilityInwardsInput macroStabilityInwardsInput = data.InputParameters; MacroStabilityInwardsSurfaceLine surfaceLine = macroStabilityInwardsInput.SurfaceLine; IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> soilProfile = macroStabilityInwardsInput.StochasticSoilProfile?.SoilProfile; hydraulicLocationCalculationObserver.Observable = getHydraulicBoundaryLocationCalculationFunc(); SetSurfaceLineChartData(surfaceLine); SetSoilProfileChartData(surfaceLine, soilProfile); SetWaternetExtremeChartData(DerivedMacroStabilityInwardsInput.GetWaternetExtreme(macroStabilityInwardsInput, generalInput, GetEffectiveAssessmentLevel()), surfaceLine); SetWaternetDailyChartData(DerivedMacroStabilityInwardsInput.GetWaternetDaily(macroStabilityInwardsInput, generalInput), surfaceLine); MacroStabilityInwardsGridDeterminationType gridDeterminationType = macroStabilityInwardsInput.GridDeterminationType; MacroStabilityInwardsGrid leftGrid = macroStabilityInwardsInput.LeftGrid; MacroStabilityInwardsGrid rightGrid = macroStabilityInwardsInput.RightGrid; leftGridChartData.Points = MacroStabilityInwardsChartDataPointsFactory.CreateGridPoints(leftGrid, gridDeterminationType); rightGridChartData.Points = MacroStabilityInwardsChartDataPointsFactory.CreateGridPoints(rightGrid, gridDeterminationType); tangentLinesData.Lines = MacroStabilityInwardsChartDataPointsFactory.CreateTangentLines(macroStabilityInwardsInput.GridDeterminationType, macroStabilityInwardsInput.TangentLineDeterminationType, macroStabilityInwardsInput.TangentLineZBottom, macroStabilityInwardsInput.TangentLineZTop, macroStabilityInwardsInput.TangentLineNumber, macroStabilityInwardsInput.SurfaceLine); currentSoilProfile = soilProfile; if (surfaceLine != null) { if (currentSurfaceLine == null) { currentSurfaceLine = new MacroStabilityInwardsSurfaceLine(surfaceLine.Name); } currentSurfaceLine.CopyProperties(surfaceLine); } else { currentSurfaceLine = null; } }
/// <summary> /// Create tangent lines based on the provided amount <paramref name="tangentLineNumber"/> and /// range between <paramref name="tangentLineBottom"/> and <paramref name="tangentLineTop"/> /// within the boundaries of the <paramref name="surfaceLine"/>. /// </summary> /// <param name="gridDeterminationType">The grid determination type.</param> /// <param name="tangentLineDeterminationType">The tangent line determination type.</param> /// <param name="tangentLineBottom">The bottom boundary for the tangent lines.</param> /// <param name="tangentLineTop">The top boundary for the tangent lines.</param> /// <param name="tangentLineNumber">The amount of tangent lines to display.</param> /// <param name="surfaceLine">The surface line that determines the horizontal boundaries /// of the tangent lines.</param> /// <returns>A collection of collections of points in 2D space or an empty collection when: /// <list type="bullet"> /// <item><paramref name="gridDeterminationType"/> is <see cref="MacroStabilityInwardsGridDeterminationType.Automatic"/>;</item> /// <item><paramref name="tangentLineDeterminationType"/> is <see cref="MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated"/>;</item> /// <item><paramref name="surfaceLine"/> is <c>null</c>;</item> /// <item><paramref name="tangentLineBottom"/> is <see cref="double.NaN"/> or infinity;</item> /// <item><paramref name="tangentLineTop"/> is <see cref="double.NaN"/> or infinity.</item> /// </list> /// </returns> public static IEnumerable <IEnumerable <Point2D> > CreateTangentLines(MacroStabilityInwardsGridDeterminationType gridDeterminationType, MacroStabilityInwardsTangentLineDeterminationType tangentLineDeterminationType, RoundedDouble tangentLineBottom, RoundedDouble tangentLineTop, int tangentLineNumber, MacroStabilityInwardsSurfaceLine surfaceLine) { if (gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic || tangentLineDeterminationType == MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated || double.IsNaN(tangentLineBottom) || double.IsInfinity(tangentLineBottom) || double.IsNaN(tangentLineTop) || double.IsInfinity(tangentLineTop)) { return(Enumerable.Empty <IEnumerable <Point2D> >()); } return(CreateTangentLines(GetInterPolatedVerticalPositions(tangentLineTop, tangentLineBottom, tangentLineNumber), surfaceLine)); }
/// <summary> /// Creates grid points in 2D space based on the provided <paramref name="grid"/>. /// </summary> /// <param name="grid">The grid to create the grid points for.</param> /// <param name="gridDeterminationType">The grid determination type.</param> /// <returns>A collection of interpolated points in 2D space based on the provided /// <paramref name="grid"/> or an empty collection when: /// <list type="bullet"> /// <item><paramref name="grid"/> is <c>null</c>;</item> /// <item><paramref name="gridDeterminationType"/> is <see cref="MacroStabilityInwardsGridDeterminationType.Automatic"/>;</item> /// <item>The grid boundaries are <see cref="double.NaN"/>.</item> /// </list> /// </returns> public static IEnumerable <Point2D> CreateGridPoints(MacroStabilityInwardsGrid grid, MacroStabilityInwardsGridDeterminationType gridDeterminationType) { return(gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic ? new Point2D[0] : CreateGridPoints(grid)); }