private PipingSurfaceLine CreateSurfaceLine(Random random) { var surfaceLine = new PipingSurfaceLine(nameof(PipingSurfaceLine)) { ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble()) }; var geometryPoints = new Point3D[10]; for (var i = 0; i < 10; i++) { geometryPoints[i] = new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()); } surfaceLine.SetGeometry(geometryPoints); surfaceLine.SetBottomDitchDikeSideAt(geometryPoints[1]); surfaceLine.SetBottomDitchPolderSideAt(geometryPoints[2]); surfaceLine.SetDikeToeAtPolderAt(geometryPoints[3]); surfaceLine.SetDikeToeAtRiverAt(geometryPoints[4]); surfaceLine.SetDitchDikeSideAt(geometryPoints[5]); surfaceLine.SetDitchPolderSideAt(geometryPoints[7]); return(surfaceLine); }
internal static PipingSurfaceLine GetSurfaceLine() { var surfaceLine = new PipingSurfaceLine(string.Empty); var firstCharacteristicPointLocation = new Point3D(0.2, 0.0, bottom + 3 * top / 4); var secondCharacteristicPointLocation = new Point3D(0.3, 0.0, bottom + 2 * top / 4); var thirdCharacteristicPointLocation = new Point3D(0.4, 0.0, bottom + top / 4); var fourthCharacteristicPointLocation = new Point3D(0.5, 0.0, bottom + 2 * top / 4); var fifthCharacteristicPointLocation = new Point3D(0.6, 0.0, bottom + 3 * top / 4); surfaceLine.SetGeometry(new[] { new Point3D(0.0, 0.0, 0.0), firstCharacteristicPointLocation, secondCharacteristicPointLocation, thirdCharacteristicPointLocation, fourthCharacteristicPointLocation, fifthCharacteristicPointLocation, new Point3D(1.0, 0.0, top) }); surfaceLine.SetDikeToeAtPolderAt(firstCharacteristicPointLocation); surfaceLine.SetDitchDikeSideAt(secondCharacteristicPointLocation); surfaceLine.SetBottomDitchDikeSideAt(thirdCharacteristicPointLocation); surfaceLine.SetBottomDitchPolderSideAt(fourthCharacteristicPointLocation); surfaceLine.SetDitchPolderSideAt(fifthCharacteristicPointLocation); surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0); return(surfaceLine); }
private static PipingSurfaceLine CreateSurfaceLineWithCharacteristicPoints(string name = "Name A") { var surfaceLine = new PipingSurfaceLine(name) { ReferenceLineIntersectionWorldPoint = new Point2D(0, 0) }; var geometry = new[] { new Point3D(0, 0, 0), new Point3D(1, 0, 2), new Point3D(2, 0, 3), new Point3D(3, 0, 0), new Point3D(4, 0, 2), new Point3D(5, 0, 3) }; surfaceLine.SetGeometry(geometry); surfaceLine.SetBottomDitchDikeSideAt(geometry[0]); surfaceLine.SetBottomDitchPolderSideAt(geometry[1]); surfaceLine.SetDikeToeAtPolderAt(geometry[2]); surfaceLine.SetDikeToeAtRiverAt(geometry[3]); surfaceLine.SetDitchDikeSideAt(geometry[4]); surfaceLine.SetDitchPolderSideAt(geometry[5]); return(surfaceLine); }
public void Create_SurfaceLineWithCharacteristicPointsOnSameGeometryPoint_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences() { // Setup var random = new Random(31); var registry = new PersistenceRegistry(); var geometry = new[] { new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()) }; var surfaceLine = new PipingSurfaceLine("Test") { ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble()) }; surfaceLine.SetGeometry(geometry); surfaceLine.SetBottomDitchDikeSideAt(geometry[0]); surfaceLine.SetBottomDitchPolderSideAt(geometry[0]); surfaceLine.SetDikeToeAtPolderAt(geometry[0]); surfaceLine.SetDikeToeAtRiverAt(geometry[0]); surfaceLine.SetDitchDikeSideAt(geometry[0]); surfaceLine.SetDitchPolderSideAt(geometry[0]); // Call SurfaceLineEntity entity = surfaceLine.Create(registry, 0); // Assert Assert.AreEqual(surfaceLine.Name, entity.Name); Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.X, entity.ReferenceLineIntersectionX); Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.Y, entity.ReferenceLineIntersectionY); string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry); Assert.AreEqual(expectedXml, entity.PointsXml); Assert.AreEqual(6, entity.PipingCharacteristicPointEntities.Count); CollectionAssert.AreEquivalent(new[] { (byte)PipingCharacteristicPointType.DikeToeAtRiver, (byte)PipingCharacteristicPointType.DikeToeAtPolder, (byte)PipingCharacteristicPointType.DitchDikeSide, (byte)PipingCharacteristicPointType.BottomDitchDikeSide, (byte)PipingCharacteristicPointType.BottomDitchPolderSide, (byte)PipingCharacteristicPointType.DitchPolderSide }, entity.PipingCharacteristicPointEntities .Select(cpe => cpe.Type)); foreach (PipingCharacteristicPointEntity characteristicPointEntity in entity.PipingCharacteristicPointEntities) { Assert.AreEqual(geometry[0].X, characteristicPointEntity.X); Assert.AreEqual(geometry[0].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[0].Z, characteristicPointEntity.Z); } }
/// <summary> /// Tries to set the <see cref="PipingSurfaceLine.BottomDitchPolderSide"/> at the location of /// <paramref name="point"/>. /// </summary> /// <param name="surfaceLine">The <see cref="PipingSurfaceLine"/> to set the /// <see cref="PipingSurfaceLine.BottomDitchPolderSide"/> for.</param> /// <param name="point">The point at which to set the <see cref="PipingSurfaceLine.BottomDitchPolderSide"/>.</param> private static void TrySetBottomDitchPolderSide(this PipingSurfaceLine surfaceLine, Point3D point) { if (point != null) { try { surfaceLine.SetBottomDitchPolderSideAt(point); } catch (ArgumentException e) { LogError(surfaceLine, e); } } }
public static void CalculateEffectiveThicknessCoverageLayer_WithMultipleCharacteristicTypesOnSamePoint_ReturnsThickness() { // Setup var surfaceLine = new PipingSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 10), new Point3D(20, 0, 10) }); surfaceLine.SetDikeToeAtRiverAt(surfaceLine.Points.ElementAt(0)); surfaceLine.SetDikeToeAtPolderAt(surfaceLine.Points.ElementAt(0)); surfaceLine.SetDitchDikeSideAt(surfaceLine.Points.ElementAt(0)); surfaceLine.SetBottomDitchPolderSideAt(surfaceLine.Points.ElementAt(1)); surfaceLine.SetBottomDitchDikeSideAt(surfaceLine.Points.ElementAt(1)); surfaceLine.SetDitchPolderSideAt(surfaceLine.Points.ElementAt(1)); var stochasticSoilProfile = new PipingStochasticSoilProfile( 0.0, new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(5) { IsAquifer = true }, new PipingSoilLayer(20) { IsAquifer = false } }, SoilProfileType.SoilProfile1D)); var input = new TestPipingInput { ExitPointL = (RoundedDouble)10, SurfaceLine = surfaceLine, StochasticSoilProfile = stochasticSoilProfile }; var generalInput = new GeneralPipingInput(); // Call double thickness = InputParameterCalculationService.CalculateEffectiveThicknessCoverageLayer( generalInput.WaterVolumetricWeight, PipingDesignVariableFactory.GetPhreaticLevelExit(input).GetDesignValue(), input.ExitPointL, input.SurfaceLine, input.StochasticSoilProfile.SoilProfile); // Assert Assert.AreEqual(5, thickness); }
public void CreateBottomDitchPolderSidePoint_GivenSurfaceLineWithBottomDitchPolderSide_ReturnsBottomDitchPolderSidePointsArray() { // Setup var bottomDitchPolderSide = new Point3D(1.2, 2.3, 4.0); PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetBottomDitchPolderSideAt(bottomDitchPolderSide); // Call Point2D[] points = PipingChartDataPointsFactory.CreateBottomDitchPolderSidePoint(surfaceLine); // Assert AssertEqualLocalPointCollection(bottomDitchPolderSide, surfaceLine, points); }
/// <summary> /// Sets the characteristic point and its coordinate to the <paramref name="surfaceLine"/>. /// </summary> /// <param name="surfaceLine">The surface line to set the characteristic point on.</param> /// <param name="type">The type of characteristic point.</param> /// <param name="geometryPoint">The point associated with the characteristic point.</param> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="type"/> is not /// a valid <see cref="PipingCharacteristicPointType"/>.</exception> /// <exception cref="NotSupportedException">Thrown when <paramref name="type"/> is not supported.</exception> private static void SetCharacteristicPoint(PipingSurfaceLine surfaceLine, PipingCharacteristicPointType type, Point3D geometryPoint) { if (!Enum.IsDefined(typeof(PipingCharacteristicPointType), type)) { throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(PipingCharacteristicPointType)); } switch (type) { case PipingCharacteristicPointType.DikeToeAtRiver: surfaceLine.SetDikeToeAtRiverAt(geometryPoint); break; case PipingCharacteristicPointType.DikeToeAtPolder: surfaceLine.SetDikeToeAtPolderAt(geometryPoint); break; case PipingCharacteristicPointType.DitchDikeSide: surfaceLine.SetDitchDikeSideAt(geometryPoint); break; case PipingCharacteristicPointType.BottomDitchDikeSide: surfaceLine.SetBottomDitchDikeSideAt(geometryPoint); break; case PipingCharacteristicPointType.BottomDitchPolderSide: surfaceLine.SetBottomDitchPolderSideAt(geometryPoint); break; case PipingCharacteristicPointType.DitchPolderSide: surfaceLine.SetDitchPolderSideAt(geometryPoint); break; default: throw new NotSupportedException(); } }
public void Data_WithSurfaceLineAndSoilProfile_DataUpdatedToCollectionOfFilledChartData() { // Setup using (var view = new PipingInputView()) { PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDitchDikeSideAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetBottomDitchDikeSideAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetDitchPolderSideAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetBottomDitchPolderSideAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetDikeToeAtPolderAt(new Point3D(1.2, 2.3, 4.0)); surfaceLine.SetDikeToeAtRiverAt(new Point3D(1.2, 2.3, 4.0)); PipingStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile(); var calculation = new TestPipingCalculationScenario(new TestPipingInput()) { InputParameters = { SurfaceLine = surfaceLine, StochasticSoilProfile = stochasticSoilProfile } }; // Call view.Data = calculation; // Assert Assert.AreSame(calculation, view.Data); ChartDataCollection chartData = view.Chart.Data; Assert.IsInstanceOf <ChartDataCollection>(chartData); Assert.AreEqual(10, chartData.Collection.Count()); AssertSoilProfileChartData(stochasticSoilProfile, chartData.Collection.ElementAt(soilProfileIndex), true); AssertSurfaceLineChartData(surfaceLine, chartData.Collection.ElementAt(surfaceLineIndex)); AssertEntryPointLPointchartData(calculation.InputParameters, surfaceLine, chartData.Collection.ElementAt(entryPointIndex)); AssertExitPointLPointchartData(calculation.InputParameters, surfaceLine, chartData.Collection.ElementAt(exitPointIndex)); AssertCharacteristicPoints(surfaceLine, chartData.Collection.ToList()); } }
public void GetProperties_WithData_ReturnExpectedValues() { // Setup const string expectedName = "<some nice name>"; var point1 = new Point3D(1.1, 2.2, 3.3); var point2 = new Point3D(2.1, 2.2, 3.3); var surfaceLine = new PipingSurfaceLine(expectedName); surfaceLine.SetGeometry(new[] { point1, point2 }); surfaceLine.SetDikeToeAtRiverAt(point1); surfaceLine.SetDikeToeAtPolderAt(point2); surfaceLine.SetDitchDikeSideAt(point1); surfaceLine.SetBottomDitchDikeSideAt(point1); surfaceLine.SetBottomDitchPolderSideAt(point2); surfaceLine.SetDitchPolderSideAt(point2); var properties = new PipingSurfaceLineProperties { Data = surfaceLine }; // Call & Assert Assert.AreEqual(expectedName, properties.Name); CollectionAssert.AreEqual(surfaceLine.Points, properties.Points); Assert.AreEqual(point1, properties.DikeToeAtRiver); Assert.AreEqual(point2, properties.DikeToeAtPolder); Assert.AreEqual(point1, properties.DitchDikeSide); Assert.AreEqual(point1, properties.BottomDitchDikeSide); Assert.AreEqual(point2, properties.BottomDitchPolderSide); Assert.AreEqual(point2, properties.DitchPolderSide); }
public void UpdateObserver_CalculationSurfaceLineUpdated_ChartDataUpdated() { // Setup var mocks = new MockRepository(); var observer = mocks.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()).Repeat.Times(9); mocks.ReplayAll(); using (var view = new PipingInputView()) { var characteristicPoint = new Point3D(1.2, 2.3, 4.0); PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); surfaceLine.SetDitchDikeSideAt(characteristicPoint); surfaceLine.SetBottomDitchDikeSideAt(characteristicPoint); surfaceLine.SetDitchPolderSideAt(characteristicPoint); surfaceLine.SetBottomDitchPolderSideAt(characteristicPoint); surfaceLine.SetDikeToeAtPolderAt(characteristicPoint); surfaceLine.SetDikeToeAtRiverAt(characteristicPoint); var calculation = new TestPipingCalculationScenario(new TestPipingInput()) { InputParameters = { SurfaceLine = surfaceLine } }; view.Data = calculation; List <ChartData> chartDataList = view.Chart.Data.Collection.ToList(); var surfaceLineChartData = (ChartLineData)chartDataList[surfaceLineIndex]; var entryPointChartData = (ChartPointData)chartDataList[entryPointIndex]; var exitPointChartData = (ChartPointData)chartDataList[exitPointIndex]; var ditchDikeSideData = (ChartPointData)chartDataList[ditchDikeSideIndex]; var bottomDitchDikeSideData = (ChartPointData)chartDataList[bottomDitchDikeSideIndex]; var ditchPolderSideData = (ChartPointData)chartDataList[ditchPolderSideIndex]; var bottomDitchPolderSideData = (ChartPointData)chartDataList[bottomDitchPolderSideIndex]; var dikeToeAtPolderData = (ChartPointData)chartDataList[dikeToeAtPolderIndex]; var dikeToeAtRiverData = (ChartPointData)chartDataList[dikeToeAtRiverIndex]; surfaceLineChartData.Attach(observer); entryPointChartData.Attach(observer); exitPointChartData.Attach(observer); ditchDikeSideData.Attach(observer); bottomDitchDikeSideData.Attach(observer); ditchPolderSideData.Attach(observer); bottomDitchPolderSideData.Attach(observer); dikeToeAtPolderData.Attach(observer); dikeToeAtRiverData.Attach(observer); var characteristicPoint2 = new Point3D(3.5, 2.3, 8.0); PipingSurfaceLine surfaceLine2 = GetSecondSurfaceLineWithGeometry(); surfaceLine2.SetDitchDikeSideAt(characteristicPoint2); surfaceLine2.SetBottomDitchDikeSideAt(characteristicPoint2); surfaceLine2.SetDitchPolderSideAt(characteristicPoint2); surfaceLine2.SetBottomDitchPolderSideAt(characteristicPoint2); surfaceLine2.SetDikeToeAtPolderAt(characteristicPoint2); surfaceLine2.SetDikeToeAtRiverAt(characteristicPoint2); calculation.InputParameters.SurfaceLine = surfaceLine2; // Call calculation.InputParameters.NotifyObservers(); // Assert chartDataList = view.Chart.Data.Collection.ToList(); Assert.AreSame(surfaceLineChartData, (ChartLineData)chartDataList[surfaceLineIndex]); Assert.AreSame(entryPointChartData, (ChartPointData)chartDataList[entryPointIndex]); Assert.AreSame(exitPointChartData, (ChartPointData)chartDataList[exitPointIndex]); Assert.AreSame(ditchDikeSideData, (ChartPointData)chartDataList[ditchDikeSideIndex]); Assert.AreSame(bottomDitchDikeSideData, (ChartPointData)chartDataList[bottomDitchDikeSideIndex]); Assert.AreSame(ditchPolderSideData, (ChartPointData)chartDataList[ditchPolderSideIndex]); Assert.AreSame(bottomDitchPolderSideData, (ChartPointData)chartDataList[bottomDitchPolderSideIndex]); Assert.AreSame(dikeToeAtPolderData, (ChartPointData)chartDataList[dikeToeAtPolderIndex]); Assert.AreSame(dikeToeAtRiverData, (ChartPointData)chartDataList[dikeToeAtRiverIndex]); AssertSurfaceLineChartData(surfaceLine2, surfaceLineChartData); AssertEntryPointLPointchartData(calculation.InputParameters, surfaceLine2, entryPointChartData); AssertExitPointLPointchartData(calculation.InputParameters, surfaceLine2, exitPointChartData); AssertCharacteristicPoints(surfaceLine2, chartDataList); mocks.VerifyAll(); } }
protected override void SetCharacteristicPoint(PipingSurfaceLine surfaceLine, Point3D point) { surfaceLine.SetBottomDitchPolderSideAt(point); }
public void Create_SurfaceLineWithGeometryAndCharacteristicPoints_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences() { // Setup var registry = new PersistenceRegistry(); var random = new Random(31); var geometry = new[] { new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()), new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()) }; var surfaceLine = new PipingSurfaceLine("Test") { ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble()) }; surfaceLine.SetGeometry(geometry); const int bottomDitchDikeIndex = 1; surfaceLine.SetBottomDitchDikeSideAt(geometry[bottomDitchDikeIndex]); const int bottomDitchPolderIndex = 2; surfaceLine.SetBottomDitchPolderSideAt(geometry[bottomDitchPolderIndex]); const int toePolderIndex = 3; surfaceLine.SetDikeToeAtPolderAt(geometry[toePolderIndex]); const int toeDikeIndex = 4; surfaceLine.SetDikeToeAtRiverAt(geometry[toeDikeIndex]); const int ditchDikeIndex = 5; surfaceLine.SetDitchDikeSideAt(geometry[ditchDikeIndex]); const int ditchPolderIndex = 6; surfaceLine.SetDitchPolderSideAt(geometry[ditchPolderIndex]); // Call SurfaceLineEntity entity = surfaceLine.Create(registry, 0); // Assert Assert.AreEqual(surfaceLine.Name, entity.Name); Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.X, entity.ReferenceLineIntersectionX); Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.Y, entity.ReferenceLineIntersectionY); string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry); Assert.AreEqual(expectedXml, entity.PointsXml); Assert.AreEqual(6, entity.PipingCharacteristicPointEntities.Count); foreach (PipingCharacteristicPointEntity characteristicPointEntity in entity.PipingCharacteristicPointEntities) { switch (characteristicPointEntity.Type) { case (byte)PipingCharacteristicPointType.BottomDitchDikeSide: Assert.AreEqual(geometry[bottomDitchDikeIndex].X, characteristicPointEntity.X); Assert.AreEqual(geometry[bottomDitchDikeIndex].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[bottomDitchDikeIndex].Z, characteristicPointEntity.Z); break; case (byte)PipingCharacteristicPointType.BottomDitchPolderSide: Assert.AreEqual(geometry[bottomDitchPolderIndex].X, characteristicPointEntity.X); Assert.AreEqual(geometry[bottomDitchPolderIndex].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[bottomDitchPolderIndex].Z, characteristicPointEntity.Z); break; case (byte)PipingCharacteristicPointType.DikeToeAtPolder: Assert.AreEqual(geometry[toePolderIndex].X, characteristicPointEntity.X); Assert.AreEqual(geometry[toePolderIndex].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[toePolderIndex].Z, characteristicPointEntity.Z); break; case (byte)PipingCharacteristicPointType.DikeToeAtRiver: Assert.AreEqual(geometry[toeDikeIndex].X, characteristicPointEntity.X); Assert.AreEqual(geometry[toeDikeIndex].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[toeDikeIndex].Z, characteristicPointEntity.Z); break; case (byte)PipingCharacteristicPointType.DitchDikeSide: Assert.AreEqual(geometry[ditchDikeIndex].X, characteristicPointEntity.X); Assert.AreEqual(geometry[ditchDikeIndex].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[ditchDikeIndex].Z, characteristicPointEntity.Z); break; case (byte)PipingCharacteristicPointType.DitchPolderSide: Assert.AreEqual(geometry[ditchPolderIndex].X, characteristicPointEntity.X); Assert.AreEqual(geometry[ditchPolderIndex].Y, characteristicPointEntity.Y); Assert.AreEqual(geometry[ditchPolderIndex].Z, characteristicPointEntity.Z); break; default: Assert.Fail("Invalid characteristic point type found: {0}", characteristicPointEntity.Type); break; } } }