Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r63f8b9c87db76c0aac38ac9a47530962d06849ae -r53060003d1d7516c3918ec29d12ed6cbdd868a6d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 63f8b9c87db76c0aac38ac9a47530962d06849ae) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 53060003d1d7516c3918ec29d12ed6cbdd868a6d) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -1830,6 +1830,15 @@ } /// + /// Looks up a localized string similar to Stochastisch ondergrondmodellen. + /// + public static string StochasticSoilModelCollection { + get { + return ResourceManager.GetString("StochasticSoilModelCollection", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap StochasticSoilModelIcon { Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx =================================================================== diff -u -r63f8b9c87db76c0aac38ac9a47530962d06849ae -r53060003d1d7516c3918ec29d12ed6cbdd868a6d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision 63f8b9c87db76c0aac38ac9a47530962d06849ae) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision 53060003d1d7516c3918ec29d12ed6cbdd868a6d) @@ -742,4 +742,7 @@ Bijdrage ondergrond profiel in % + + Stochastisch ondergrondmodellen + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs =================================================================== diff -u -r473efe5f1b2aff98ffc7ad1d826c3ef90f77a7a6 -r53060003d1d7516c3918ec29d12ed6cbdd868a6d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision 473efe5f1b2aff98ffc7ad1d826c3ef90f77a7a6) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision 53060003d1d7516c3918ec29d12ed6cbdd868a6d) @@ -21,7 +21,6 @@ using System.Linq; using System.Windows.Forms; - using Core.Common.Base; using Core.Components.Gis.Data; using Core.Components.Gis.Forms; @@ -43,6 +42,7 @@ private MapData hydraulicBoundaryDatabaseLocations; private MapData referenceLineData; private MapData surfaceLinesMapData; + private MapData stochasticSoilModelMapData; private MapData sectionsMapData; private MapData sectionsStartPointsMapData; private MapData sectionsEndPointMapData; @@ -114,8 +114,9 @@ { // Bottom most layer referenceLineData = AddOrUpdateMapData(referenceLineData, GetReferenceLineMapData()); - surfaceLinesMapData = AddOrUpdateMapData(surfaceLinesMapData, GetSurfaceLinesMapData()); sectionsMapData = AddOrUpdateMapData(sectionsMapData, GetSectionsMapData()); + stochasticSoilModelMapData = AddOrUpdateMapData(stochasticSoilModelMapData, GetStochasticSoilModelMapData()); + surfaceLinesMapData = AddOrUpdateMapData(surfaceLinesMapData, GetSurfaceLinesMapData()); sectionsStartPointsMapData = AddOrUpdateMapData(sectionsStartPointsMapData, GetSectionsStartPointsMapData()); sectionsEndPointMapData = AddOrUpdateMapData(sectionsEndPointMapData, GetSectionsEndPointsMapData()); hydraulicBoundaryDatabaseLocations = AddOrUpdateMapData(hydraulicBoundaryDatabaseLocations, GetHydraulicBoundaryLocationsMapData()); @@ -166,6 +167,15 @@ return PipingMapDataFactory.Create(data.WrappedData.SurfaceLines); } + private MapData GetStochasticSoilModelMapData() + { + if (data == null || data.WrappedData == null || data.WrappedData.StochasticSoilModels == null || !data.WrappedData.StochasticSoilModels.Any()) + { + return PipingMapDataFactory.CreateEmptyLineData(PipingFormsResources.StochasticSoilModelCollection); + } + return PipingMapDataFactory.Create(data.WrappedData.StochasticSoilModels); + } + private MapData GetSectionsMapData() { if (data == null || data.WrappedData == null || data.WrappedData.Sections == null || !data.WrappedData.Sections.Any()) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r53060003d1d7516c3918ec29d12ed6cbdd868a6d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs (.../PipingMapDataFactory.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingMapDataFactory.cs (.../PipingMapDataFactory.cs) (revision 53060003d1d7516c3918ec29d12ed6cbdd868a6d) @@ -29,10 +29,10 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.HydraRing.Data; +using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Primitives; @@ -68,6 +68,30 @@ } /// + /// Create with default styling based on the . + /// + /// The collection for which to create . + /// based on . + /// is null. + public static MapData Create(IEnumerable stochasticSoilModels) + { + if (stochasticSoilModels == null) + { + throw new ArgumentNullException("stochasticSoilModels"); + } + + var mapFeatures = new List + { + new MapFeature(stochasticSoilModels.Select(stochasticSoilModel => new MapGeometry(stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y))))) + }; + + return new MapLineData(mapFeatures, Resources.StochasticSoilModelCollection) + { + Style = new LineStyle(Color.SaddleBrown, 5, DashStyle.Solid) + }; + } + + /// /// Create with default styling based on the . /// /// The collection for which to create . Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs =================================================================== diff -u -rf1bd17ba95b3fbae5928d4240523d50d8b83b64d -r53060003d1d7516c3918ec29d12ed6cbdd868a6d --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision f1bd17ba95b3fbae5928d4240523d50d8b83b64d) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismViewTest.cs (.../PipingFailureMechanismViewTest.cs) (revision 53060003d1d7516c3918ec29d12ed6cbdd868a6d) @@ -45,14 +45,6 @@ [TestFixture] public class PipingFailureMechanismViewTest { - - private const int referenceLineLayerIndex = 0; - private const int surfaceLinesLayerIndex = 1; - private const int sectionsLayerIndex = 2; - private const int sectionStartsLayerIndex = 3; - private const int sectionEndsLayerIndex = 4; - private const int hydraulicLocationsLayerIndex = 5; - [Test] public void DefaultConstructor_DefaultValues() { @@ -87,7 +79,7 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var mocks = new MockRepository(); var assessmentSectionMock = mocks.Stub(); @@ -103,7 +95,7 @@ // Assert var mapData = map.Data; - Assert.AreEqual(6, mapData.List.Count); + Assert.AreEqual(7, mapData.List.Count); var referenceLineData = mapData.List[referenceLineLayerIndex] as FeatureBasedMapData; Assert.NotNull(referenceLineData); @@ -135,6 +127,11 @@ Assert.IsEmpty(hydraulicLocationsData.Features); Assert.AreEqual("Hydraulische randvoorwaarden", hydraulicLocationsData.Name); + var stochasticSoilModelsData = mapData.List[stochasticSoilModelsLayerIndex] as FeatureBasedMapData; + Assert.NotNull(stochasticSoilModelsData); + Assert.IsEmpty(stochasticSoilModelsData.Features); + Assert.AreEqual("Stochastisch ondergrondmodellen", stochasticSoilModelsData.Name); + mocks.VerifyAll(); } @@ -143,13 +140,13 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var refereceGeometryPoints = new[] { - new Point2D(0.0, 0.0), - new Point2D(2.0, 0.0), - new Point2D(4.0, 4.0), + new Point2D(0.0, 0.0), + new Point2D(2.0, 0.0), + new Point2D(4.0, 4.0), new Point2D(6.0, 4.0) }; @@ -169,11 +166,19 @@ assessmentSectionMock.ReferenceLine = referenceLine; mocks.ReplayAll(); + var stochasticSoilModel = new StochasticSoilModel(0, "", ""); + stochasticSoilModel.Geometry.AddRange(new[] + { + new Point2D(1.0, 2.0), + new Point2D(1.1, 2.2) + }); + var pipingFailureMechanism = new PipingFailureMechanism(); pipingFailureMechanism.SurfaceLines.Add(new RingtoetsPipingSurfaceLine()); pipingFailureMechanism.AddSection(new FailureMechanismSection("A", refereceGeometryPoints.Take(2))); pipingFailureMechanism.AddSection(new FailureMechanismSection("B", refereceGeometryPoints.Skip(1).Take(2))); pipingFailureMechanism.AddSection(new FailureMechanismSection("C", refereceGeometryPoints.Skip(2).Take(2))); + pipingFailureMechanism.StochasticSoilModels.Add(stochasticSoilModel); var pipingContext = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSectionMock); @@ -186,13 +191,14 @@ var mapData = map.Data; Assert.IsNotNull(mapData); - Assert.AreEqual(6, mapData.List.Count); + Assert.AreEqual(7, mapData.List.Count); AssertReferenceMapData(assessmentSectionMock.ReferenceLine, mapData.List[referenceLineLayerIndex]); AssertSurfacelinesMapData(pipingFailureMechanism.SurfaceLines, mapData.List[surfaceLinesLayerIndex]); AssertFailureMechanismSectionsMapData(pipingFailureMechanism.Sections, mapData.List[sectionsLayerIndex]); AssertFailureMechanismSectionsStartPointMapData(pipingFailureMechanism.Sections, mapData.List[sectionStartsLayerIndex]); AssertFailureMechanismSectionsEndPointMapData(pipingFailureMechanism.Sections, mapData.List[sectionEndsLayerIndex]); AssertHydraulicBoundaryLocationsMapData(assessmentSectionMock.HydraulicBoundaryDatabase, mapData.List[hydraulicLocationsLayerIndex]); + AssertStochasticSoilModelsMapData(pipingFailureMechanism.StochasticSoilModels, mapData.List[stochasticSoilModelsLayerIndex]); mocks.VerifyAll(); } @@ -202,7 +208,7 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var hydraulicBoundaryDatabase1 = new HydraulicBoundaryDatabase(); hydraulicBoundaryDatabase1.Locations.Add(new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)); @@ -248,7 +254,7 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var points = new List { @@ -301,7 +307,7 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var mocks = new MockRepository(); var assessmentSectionMock = mocks.Stub(); @@ -312,13 +318,13 @@ var pipingContext = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSectionMock); view.Data = pipingContext; - var oldSurfaceLineData = (FeatureBasedMapData)map.Data.List.ElementAt(surfaceLinesLayerIndex); + var oldSurfaceLineData = (FeatureBasedMapData) map.Data.List.ElementAt(surfaceLinesLayerIndex); var surfaceLine = new RingtoetsPipingSurfaceLine(); surfaceLine.SetGeometry(new Collection { - new Point3D(1,2,3), - new Point3D(1,2,3) + new Point3D(1, 2, 3), + new Point3D(1, 2, 3) }); pipingFailureMechanism.SurfaceLines.Add(surfaceLine); @@ -338,7 +344,7 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var mocks = new MockRepository(); var assessmentSectionMock = mocks.Stub(); @@ -349,14 +355,14 @@ var pipingContext = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSectionMock); view.Data = pipingContext; - var oldSectionsData = (FeatureBasedMapData)map.Data.List.ElementAt(sectionsLayerIndex); - var oldSectionStartsData = (FeatureBasedMapData)map.Data.List.ElementAt(sectionStartsLayerIndex); - var oldSectionEndsData = (FeatureBasedMapData)map.Data.List.ElementAt(sectionEndsLayerIndex); + var oldSectionsData = (FeatureBasedMapData) map.Data.List.ElementAt(sectionsLayerIndex); + var oldSectionStartsData = (FeatureBasedMapData) map.Data.List.ElementAt(sectionStartsLayerIndex); + var oldSectionEndsData = (FeatureBasedMapData) map.Data.List.ElementAt(sectionEndsLayerIndex); - var section = new FailureMechanismSection(string.Empty, new [] + var section = new FailureMechanismSection(string.Empty, new[] { - new Point2D(1,2), - new Point2D(1,2) + new Point2D(1, 2), + new Point2D(1, 2) }); pipingFailureMechanism.AddSection(section); @@ -366,7 +372,7 @@ // Assert var sectionsData = (FeatureBasedMapData) map.Data.List.ElementAt(sectionsLayerIndex); var sectionStartsData = (FeatureBasedMapData) map.Data.List.ElementAt(sectionStartsLayerIndex); - var sectionEndsData = (FeatureBasedMapData)map.Data.List.ElementAt(sectionEndsLayerIndex); + var sectionEndsData = (FeatureBasedMapData) map.Data.List.ElementAt(sectionEndsLayerIndex); Assert.AreNotEqual(oldSectionsData, sectionsData); Assert.AreNotEqual(oldSectionStartsData, sectionStartsData); Assert.AreNotEqual(oldSectionEndsData, sectionEndsData); @@ -376,12 +382,48 @@ } [Test] - public void UpdateObserver_OtherAssessmentSectionUpdated_MapDataNotUpdated() + public void UpdateObserver_StochasticSoilModelsUpdated_SetNewMapData() { // Setup var view = new PipingFailureMechanismView(); var map = (MapControl)view.Controls[0]; + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.Stub(); + mocks.ReplayAll(); + + var pipingFailureMechanism = new PipingFailureMechanism(); + var pipingContext = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSectionMock); + + view.Data = pipingContext; + var oldStochasticSoilModelData = (FeatureBasedMapData)map.Data.List.ElementAt(stochasticSoilModelsLayerIndex); + + var stochasticSoilModel = new StochasticSoilModel(0,"",""); + stochasticSoilModel.Geometry.AddRange(new[] + { + new Point2D(1, 2), + new Point2D(1, 2) + }); + pipingFailureMechanism.StochasticSoilModels.Add(stochasticSoilModel); + + // Call + pipingFailureMechanism.NotifyObservers(); + + // Assert + var stochasticSoilModelData = (FeatureBasedMapData)map.Data.List.ElementAt(stochasticSoilModelsLayerIndex); + Assert.AreNotEqual(oldStochasticSoilModelData, stochasticSoilModelData); + Assert.IsInstanceOf(map.Data); + + mocks.VerifyAll(); + } + + [Test] + public void UpdateObserver_OtherAssessmentSectionUpdated_MapDataNotUpdated() + { + // Setup + var view = new PipingFailureMechanismView(); + var map = (MapControl) view.Controls[0]; + var assessmentSection = new TestAssessmentSection { HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(), @@ -394,7 +436,14 @@ new Point2D(2.0, 1.0) }); + var stochasticSoilModel = new StochasticSoilModel(0, "", ""); + stochasticSoilModel.Geometry.AddRange(new[] + { + new Point2D(1.0, 2.0), + new Point2D(1.1, 2.2) + }); var pipingFailureMechanism = new PipingFailureMechanism(); + pipingFailureMechanism.StochasticSoilModels.AddRange(new[]{stochasticSoilModel}); var pipingContext = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSection); view.Data = pipingContext; @@ -424,7 +473,7 @@ { // Setup var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; var assessmentSection = new TestAssessmentSection { @@ -438,7 +487,18 @@ new Point2D(2.0, 1.0) }); + var stochasticSoilModel = new StochasticSoilModel(0, "", ""); + stochasticSoilModel.Geometry.AddRange(new[] + { + new Point2D(1.0, 2.0), + new Point2D(1.1, 2.2) + }); + var pipingFailureMechanism = new PipingFailureMechanism(); + pipingFailureMechanism.StochasticSoilModels.AddRange(new[] + { + stochasticSoilModel + }); var pipingContext = new PipingFailureMechanismContext(pipingFailureMechanism, assessmentSection); view.Data = pipingContext; @@ -470,14 +530,14 @@ newAssessmentSectionMock.ReferenceLine = new ReferenceLine(); newAssessmentSectionMock.ReferenceLine.SetGeometry(new[] { - new Point2D(2,4), - new Point2D(3,4) + new Point2D(2, 4), + new Point2D(3, 4) }); var oldPipingFailureMechanismContext = new PipingFailureMechanismContext(new PipingFailureMechanism(), oldAssessmentSectionMock); var newPipingFailureMechanismContext = new PipingFailureMechanismContext(new PipingFailureMechanism(), newAssessmentSectionMock); var view = new PipingFailureMechanismView(); - var map = (MapControl)view.Controls[0]; + var map = (MapControl) view.Controls[0]; view.Data = oldPipingFailureMechanismContext; view.Data = newPipingFailureMechanismContext; @@ -492,10 +552,18 @@ Assert.AreEqual(dataBeforeUpdate, map.Data); } + private const int referenceLineLayerIndex = 0; + private const int sectionsLayerIndex = 1; + private const int stochasticSoilModelsLayerIndex = 2; + private const int surfaceLinesLayerIndex = 3; + private const int sectionStartsLayerIndex = 4; + private const int sectionEndsLayerIndex = 5; + private const int hydraulicLocationsLayerIndex = 6; + private void AssertReferenceMapData(ReferenceLine referenceLine, MapData mapData) { Assert.IsInstanceOf(mapData); - var referenceLineData = (MapLineData)mapData; + var referenceLineData = (MapLineData) mapData; if (referenceLine == null) { CollectionAssert.IsEmpty(referenceLineData.Features.First().MapGeometries.First().Points); @@ -510,7 +578,7 @@ private void AssertHydraulicBoundaryLocationsMapData(HydraulicBoundaryDatabase database, MapData mapData) { Assert.IsInstanceOf(mapData); - var hydraulicLocationsMapData = (MapPointData)mapData; + var hydraulicLocationsMapData = (MapPointData) mapData; if (database == null) { CollectionAssert.IsEmpty(hydraulicLocationsMapData.Features.First().MapGeometries.First().Points); @@ -525,7 +593,7 @@ private void AssertFailureMechanismSectionsMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsMapLinesData = (MapLineData)mapData; + var sectionsMapLinesData = (MapLineData) mapData; var sectionMapLinesFeatures = sectionsMapLinesData.Features.ToArray(); Assert.AreEqual(1, sectionMapLinesFeatures.Length); @@ -544,26 +612,26 @@ private void AssertFailureMechanismSectionsStartPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetStart()), sectionsStartPointData.Features.First().MapGeometries.First().Points); Assert.AreEqual("Vakindeling (startpunten)", mapData.Name); } private void AssertFailureMechanismSectionsEndPointMapData(IEnumerable sections, MapData mapData) { Assert.IsInstanceOf(mapData); - var sectionsStartPointData = (MapPointData)mapData; + var sectionsStartPointData = (MapPointData) mapData; CollectionAssert.AreEqual(sections.Select(s => s.GetLast()), sectionsStartPointData.Features.First().MapGeometries.First().Points); Assert.AreEqual("Vakindeling (eindpunten)", mapData.Name); } private void AssertSurfacelinesMapData(IEnumerable surfaceLines, MapData mapData) { Assert.IsInstanceOf(mapData); - var surfacelinesMapData = (MapLineData)mapData; + var surfacelinesMapData = (MapLineData) mapData; var surfacelineFeatures = surfacelinesMapData.Features.ToArray(); Assert.AreEqual(1, surfacelineFeatures.Length); - + var geometries = surfacelineFeatures.First().MapGeometries.ToArray(); var surfaceLinesArray = surfaceLines.ToArray(); Assert.AreEqual(surfaceLinesArray.Length, geometries.Length); @@ -576,6 +644,25 @@ Assert.AreEqual("Profielschematisaties", mapData.Name); } + private void AssertStochasticSoilModelsMapData(IEnumerable soilModels, MapData mapData) + { + Assert.IsInstanceOf(mapData); + var soilModelsMapData = (MapLineData) mapData; + var soilModelsFeatures = soilModelsMapData.Features.ToArray(); + Assert.AreEqual(1, soilModelsFeatures.Length); + + var geometries = soilModelsFeatures.First().MapGeometries.ToArray(); + var stochasticSoilModelsArray = soilModels.ToArray(); + Assert.AreEqual(stochasticSoilModelsArray.Length, geometries.Length); + + for (int index = 0; index < stochasticSoilModelsArray.Length; index++) + { + var stochasticSoilModel = stochasticSoilModelsArray[index]; + CollectionAssert.AreEquivalent(geometries[index].Points, stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y))); + } + Assert.AreEqual("Stochastisch ondergrondmodellen", mapData.Name); + } + private class TestAssessmentSection : Observable, IAssessmentSection { public string Name { get; set; } @@ -585,6 +672,8 @@ public FailureMechanismContribution FailureMechanismContribution { get; private set; } public HydraulicBoundaryDatabase HydraulicBoundaryDatabase { get; set; } + public long StorageId { get; set; } + public IEnumerable GetFailureMechanisms() { yield break; @@ -594,8 +683,6 @@ { throw new NotImplementedException(); } - - public long StorageId { get; set; } } } -} +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r53060003d1d7516c3918ec29d12ed6cbdd868a6d --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs (.../PipingMapDataFactoryTest.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingMapDataFactoryTest.cs (.../PipingMapDataFactoryTest.cs) (revision 53060003d1d7516c3918ec29d12ed6cbdd868a6d) @@ -1,4 +1,25 @@ -using System; +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; @@ -8,10 +29,10 @@ using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; using NUnit.Framework; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.HydraRing.Data; +using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Forms.Views; using Ringtoets.Piping.Primitives; @@ -98,6 +119,54 @@ } [Test] + public void Create_GivenStochasticSoilModels_ReturnsMapFeaturesWithDefaultStyling() + { + // Setup + var pointsOne = new[] + { + new Point2D(1.2, 2.3), + new Point2D(2.7, 2.0) + }; + var pointsTwo = new[] + { + new Point2D(3.2, 23.3), + new Point2D(7.7, 12.6) + }; + var stochasticSoilModels = new[] + { + new StochasticSoilModel(1, "StochasticSoilModelName1", "StochasticSoilModelSegmentName1"), + new StochasticSoilModel(2, "StochasticSoilModelName2", "StochasticSoilModelSegmentName2") + }; + stochasticSoilModels[0].Geometry.AddRange(pointsOne); + stochasticSoilModels[1].Geometry.AddRange(pointsTwo); + + // Call + MapData data = PipingMapDataFactory.Create(stochasticSoilModels); + + // Assert + Assert.IsInstanceOf(data); + var mapLineData = (MapLineData) data; + Assert.AreEqual(1, mapLineData.Features.Count()); + Assert.AreEqual(2, mapLineData.Features.ElementAt(0).MapGeometries.Count()); + AssertEqualPointCollections(pointsOne, mapLineData.Features.ElementAt(0).MapGeometries.ElementAt(0)); + AssertEqualPointCollections(pointsTwo, mapLineData.Features.ElementAt(0).MapGeometries.ElementAt(1)); + Assert.AreEqual(Resources.StochasticSoilModelCollection, data.Name); + + AssertEqualStyle(mapLineData.Style, Color.SaddleBrown, 5, DashStyle.Solid); + } + + [Test] + public void Create_NoStochasticSoilModels_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => PipingMapDataFactory.Create((IEnumerable) null); + + // Assert + var parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("stochasticSoilModels", parameter); + } + + [Test] public void Create_GivenSections_ReturnsMapFeaturesWithDefaultStyling() { // Setup @@ -300,7 +369,7 @@ // Assert Assert.IsInstanceOf(data); - var mapPointData = (MapPointData)data; + var mapPointData = (MapPointData) data; Assert.AreEqual(1, mapPointData.Features.Count()); Assert.AreEqual(1, mapPointData.Features.ElementAt(0).MapGeometries.Count()); AssertEqualPointCollections(pointsOne, mapPointData.Features.ElementAt(0).MapGeometries.ElementAt(0));