Index: DamClients/DamUI/trunk/src/Dam/Tests/Forms/DamSpatialEditorDecoratorTest.cs
===================================================================
diff -u
--- DamClients/DamUI/trunk/src/Dam/Tests/Forms/DamSpatialEditorDecoratorTest.cs (revision 0)
+++ DamClients/DamUI/trunk/src/Dam/Tests/Forms/DamSpatialEditorDecoratorTest.cs (revision 2647)
@@ -0,0 +1,160 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of the application DAM - UI.
+//
+// DAM - UI is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Deltares.Dam.Data;
+using Deltares.Dam.Forms;
+using Deltares.DamEngine.Data.Standard;
+using Deltares.Geotechnics.Soils;
+using Deltares.Geometry;
+using Deltares.Geotechnics.GeotechnicalGeometry;
+using Deltares.Standard.EventPublisher;
+using Deltares.Standard.Forms;
+using Deltares.Standard.TestUtils;
+using NUnit.Framework;
+using CharacteristicPoint = Deltares.Geotechnics.SurfaceLines.CharacteristicPoint;
+using CharacteristicPointSet = Deltares.Geotechnics.SurfaceLines.CharacteristicPointSet;
+using CharacteristicPointType = Deltares.Geotechnics.SurfaceLines.CharacteristicPointType;
+using SurfaceLine2 = Deltares.Geotechnics.SurfaceLines.SurfaceLine2;
+
+namespace Deltares.Dam.Tests.Forms
+{
+ [TestFixture]
+ public class DamSpatialEditorDecoratorTest
+ {
+ [Test]
+ [Category(Categories.WorkInProgress)]
+ public void GivenDamSpatialEditorDecorator_WhenCharacteristicPointFiresAfterChangeEvent_ThenLocationUpdated()
+ {
+ const string dikeEmbankmentMaterial = "Material";
+ var soilList = new SoilList
+ {
+ Soils = new List
+ {
+ new Soil(dikeEmbankmentMaterial, 18, 18)
+ }
+ };
+
+ var characteristicPointCoordinate = new GeometryPoint(0.000, 0, 8.291);
+ var coordinates = new List
+ {
+ characteristicPointCoordinate,
+ new GeometryPoint(21.000, 0, 8.130),
+ new GeometryPoint(35.173, 0, 8.000),
+ new GeometryPoint(37.790, 0, 7.976),
+ new GeometryPoint(39.407, 0, 6.500),
+ new GeometryPoint(39.540, 0, 6.379),
+ new GeometryPoint(40.280, 0, 6.343),
+ new GeometryPoint(40.448, 0, 6.500),
+ new GeometryPoint(42.053, 0, 8.000),
+ new GeometryPoint(42.080, 0, 8.025),
+ new GeometryPoint(54.730, 0, 8.663),
+ new GeometryPoint(59.048, 0, 10.038),
+ new GeometryPoint(62.855, 0, 11.250),
+ new GeometryPoint(64.570, 0, 11.796),
+ new GeometryPoint(65.890, 0, 12.080),
+ new GeometryPoint(67.300, 0, 12.102),
+ new GeometryPoint(68.200, 0, 12.116),
+ new GeometryPoint(69.800, 0, 12.013),
+ new GeometryPoint(71.610, 0, 11.692),
+ new GeometryPoint(72.812, 0, 11.250),
+ new GeometryPoint(76.106, 0, 10.038),
+ new GeometryPoint(78.580, 0, 9.128),
+ new GeometryPoint(86.910, 0, 8.928),
+ new GeometryPoint(88.170, 0, 8.680),
+ new GeometryPoint(92.050, 0, 8.473),
+ new GeometryPoint(109.133, 0, 8.000),
+ new GeometryPoint(109.530, 0, 7.989),
+ new GeometryPoint(131.930, 0, 7.613)
+ };
+
+ var characteristicPointSet = new CharacteristicPointSet { Geometry = new LocalizedGeometryPointString() };
+ characteristicPointSet.Geometry.Points.AddRange(coordinates);
+ var characteristicPoint = new CharacteristicPoint(characteristicPointSet, characteristicPointCoordinate)
+ {
+ CharacteristicPointType = CharacteristicPointType.None
+ };
+
+ var surfaceLine = new SurfaceLine2
+ {
+ CharacteristicPoints = { characteristicPoint },
+ Geometry = new LocalizedGeometryPointString()
+ };
+ surfaceLine.Geometry.Points.AddRange(coordinates);
+
+ var location = new Location
+ {
+ LocalXZSurfaceLine2 = surfaceLine,
+ SurfaceLine2 = surfaceLine,
+ DikeEmbankmentMaterial = dikeEmbankmentMaterial,
+ SoilList = soilList,
+ SoildatabaseName = "DatabaseName"
+ };
+ var locationJob = new LocationJob
+ {
+ Location = location
+ };
+
+ // This disposable is needed to ensure that a DAM instance is not spawned when the test is run.
+ using (var form = new Form())
+ {
+ var editor = new SpatialEditor();
+ form.Controls.Add(editor);
+
+ new DamSpatialEditorDecorator(editor);
+
+ // Fire selection changed event to force the editor to draw the location
+ DataEventPublisher.SelectionChanged(locationJob);
+
+ // As a precondition check, check if the characteristic point in question is not present
+ // in the list of objects that is being generated.
+ //
+ // The main issue why the test currently does not pass, is because the shape collection contains
+ // only one element which represents the surface (I believe). Expected item would also be the
+ // surface line on top of the soil surface area.
+ CollectionAssert.DoesNotContain(editor.Shapes.Select(sh => sh.DataObject), characteristicPoint);
+
+ // Register the event listener. A shape created event should be fired when the characteristic point
+ // is created in the shape collection.
+ //
+ // Note: it is possible that the event isn't fired while the shape was redrawn. This is an additional
+ // check and could be removed. The most important check is to verify that the shape collection contains
+ // the items it should draw!
+ bool shapeCreatedFired = false;
+ editor.ShapeCreated += (sender, args) =>
+ {
+ shapeCreatedFired = true;
+ };
+
+ // Change the characteristic point type from NONE to an arbitrary characteristic point.
+ // This should force the editor to redraw the shapes.
+ characteristicPoint.CharacteristicPointType = CharacteristicPointType.BottomDitchDikeSide;
+
+ // Check if the event was fired and whether the shapes now contain the characteristic point
+ // that was set.
+ Assert.IsTrue(shapeCreatedFired);
+ CollectionAssert.Contains(editor.Shapes.Select(sh => sh.DataObject), characteristicPoint);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: DamClients/DamUI/trunk/src/Dam/Tests/Deltares.Dam.Tests.csproj
===================================================================
diff -u -r2632 -r2647
--- DamClients/DamUI/trunk/src/Dam/Tests/Deltares.Dam.Tests.csproj (.../Deltares.Dam.Tests.csproj) (revision 2632)
+++ DamClients/DamUI/trunk/src/Dam/Tests/Deltares.Dam.Tests.csproj (.../Deltares.Dam.Tests.csproj) (revision 2647)
@@ -92,6 +92,10 @@
False
..\..\..\lib\DSL-Core\Deltares.Standard.dll
+
+ False
+ ..\..\..\lib\DSL-FormsGeo\Deltares.Standard.Forms.dll
+
..\..\..\lib\DSL-Core\Deltares.Standard.TestUtils.dll
@@ -119,6 +123,7 @@
3.5
+
3.5
@@ -136,6 +141,7 @@
+