Index: Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs
===================================================================
diff -u -re71f7a8977226f7bdbc146c4e5aac1f13c39e3eb -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs (.../ShapeFileReaderBase.cs) (revision e71f7a8977226f7bdbc146c4e5aac1f13c39e3eb)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs (.../ShapeFileReaderBase.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -119,7 +119,7 @@
/// Adds shapefile feature attributes to a as metadata.
///
/// The whose metadata will be updated.
- /// The shapefile feature on which the is based.
+ /// The index of the feature in the shapefile on which the is based.
protected void CopyMetaDataIntoFeature(MapFeature targetFeature, int sourceFeatureIndex)
{
DataTable table = ShapeFile.GetAttributes(sourceFeatureIndex, 1);
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/DikeProfile.cs
===================================================================
diff -u -r5f0c498962317723017cf965a142e7cf4e67a915 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/DikeProfile.cs (.../DikeProfile.cs) (revision 5f0c498962317723017cf965a142e7cf4e67a915)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/DikeProfile.cs (.../DikeProfile.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -32,8 +32,6 @@
///
public class DikeProfile
{
- private readonly List foreshoreGeometry;
- private readonly List dikeGeometry;
private RoundedDouble orientation;
private RoundedDouble dikeHeight;
@@ -53,8 +51,8 @@
Name = Resources.DikeProfile_DefaultName;
Memo = "";
- dikeGeometry = new List();
- foreshoreGeometry = new List();
+ DikeGeometry = new List();
+ ForeshoreGeometry = new List();
WorldReferencePoint = worldCoordinate;
}
@@ -113,13 +111,7 @@
///
/// Gets the geometry of the foreshore.
///
- public IList ForeshoreGeometry
- {
- get
- {
- return foreshoreGeometry;
- }
- }
+ public List ForeshoreGeometry { get; set; }
///
/// Gets the geometry of the dike with roughness data.
@@ -130,13 +122,7 @@
/// and the succeeding . The roughness of the last
/// point is irrelevant.
///
- public IList DikeGeometry
- {
- get
- {
- return dikeGeometry;
- }
- }
+ public List DikeGeometry { get; set; }
///
/// Gets or sets the height of the dike [m+NAP].
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/DikeProfilesContext.cs
===================================================================
diff -u -r5546343f650bb277b3c1937f1abf3ee0b7a7dc89 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/DikeProfilesContext.cs (.../DikeProfilesContext.cs) (revision 5546343f650bb277b3c1937f1abf3ee0b7a7dc89)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/DikeProfilesContext.cs (.../DikeProfilesContext.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -33,7 +33,7 @@
/// This is a presentation object for for elements
/// of type .
///
- public class DikeProfilesContext : WrappedObjectContextBase>
+ public class DikeProfilesContext : ObservableWrappedObjectContextBase>
{
///
/// Initializes a new instance of the class.
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs
===================================================================
diff -u -r5a421e7bb0b0c52d5d1d9ca20d495cd11bfa10e8 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision 5a421e7bb0b0c52d5d1d9ca20d495cd11bfa10e8)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/DikeProfiles/DikeProfileLocationReader.cs (.../DikeProfileLocationReader.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -51,7 +51,11 @@
///
/// The shape file path.
/// is invalid.
- /// points to a file that does not exist.
+ ///
+ /// - points to a file that does not exist.
+ /// - does not only contain point features.
+ /// - does not contain all of the required attributes.
+ ///
public DikeProfileLocationReader(string shapeFilePath)
{
FileUtils.ValidateFilePath(shapeFilePath);
@@ -63,46 +67,47 @@
}
pointsShapeFileReader = OpenPointsShapeFile(shapeFilePath);
+
+ CheckRequiredAttributePresence();
}
///
- /// Retrieve a for each point feature in the shapefile.
+ /// Gets the number of dike profile locations present in the shapefile.
///
+ public int GetLocationCount {
+ get
+ {
+ return pointsShapeFileReader.GetNumberOfLines();
+ }
+ }
+
+ ///
+ /// Retrieve a based on the next point feature in the shapefile.
+ ///
///
- /// - Shapefile does not contain the required attributes
- /// - Shapefile misses values for required attributes
- /// - Shapefile has an attribute whose type is incorrect
+ /// - The shapefile misses a value for a required attribute.
+ /// - The shapefile has an attribute whose type is incorrect.
///
- /// A of objects.
- public IList GetDikeProfileLocations()
+ /// A based on the next point feature in the shapefile.
+ public DikeProfileLocation GetNextDikeProfileLocation()
{
- List dikeProfileLocations = new List();
+ MapPointData mapPointData = (MapPointData) pointsShapeFileReader.ReadLine();
- CheckRequiredAttributePresence();
+ IDictionary attributes = mapPointData.Features.First().MetaData;
- int dikeProfileLocationCount = pointsShapeFileReader.GetNumberOfLines();
- for (int i = 0; i < dikeProfileLocationCount; i++)
- {
- MapPointData mapPointData = (MapPointData) pointsShapeFileReader.ReadLine();
+ var attributeIdValue = GetIdAttributeValue(attributes);
+ var attributeNameValue = GetNameAttributeValue(attributes);
+ var attributeX0Value = GetOffsetAttributeValue(attributes);
- IDictionary attributes = mapPointData.Features.First().MetaData;
-
- var attributeIdValue = GetIdAttributeValue(attributes);
- var attributeNameValue = GetNameAttributeValue(attributes);
- var attributeX0Value = GetOffsetAttributeValue(attributes);
-
- Point2D point = mapPointData.Features.First().MapGeometries.First().PointCollections.First().First();
- try
- {
- dikeProfileLocations.Add(new DikeProfileLocation(attributeIdValue, attributeNameValue, attributeX0Value, point));
- }
- catch (ArgumentException exception)
- {
- throw new CriticalFileReadException(exception.Message);
- }
+ Point2D point = mapPointData.Features.First().MapGeometries.First().PointCollections.First().First();
+ try
+ {
+ return new DikeProfileLocation(attributeIdValue, attributeNameValue, attributeX0Value, point);
}
-
- return dikeProfileLocations;
+ catch (ArgumentException exception)
+ {
+ throw new CriticalFileReadException(exception.Message);
+ }
}
public void Dispose()
@@ -111,12 +116,13 @@
}
///
- /// Open a shapefile containing dike locations.
+ /// Open a shapefile containing dike locations as point features.
///
- /// Filepath of the shapefile containing dike locations.
+ /// Shape file path.
+ /// Thrown when is invalid.
/// Shapefile does not only contain point features.
/// Return an instance of .
- private PointShapeFileReader OpenPointsShapeFile(string shapeFilePath)
+ private static PointShapeFileReader OpenPointsShapeFile(string shapeFilePath)
{
try
{
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rb6a73e405591aa848377355d3f2d931cfbb91ff4 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b6a73e405591aa848377355d3f2d931cfbb91ff4)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -411,7 +411,7 @@
}
///
- /// Looks up a localized string similar to Fout bij het aanmaken van een dijk profiel locatie: offset is ongeldig..
+ /// Looks up a localized string similar to Fout bij het aanmaken van een dijk profiel locatie: X0 is ongeldig..
///
internal static string DikeProfileLocation_Constructor_Invalid_X0 {
get {
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx
===================================================================
diff -u -rb6a73e405591aa848377355d3f2d931cfbb91ff4 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision b6a73e405591aa848377355d3f2d931cfbb91ff4)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -127,7 +127,7 @@
Fout bij het aanmaken van een dijk profiel locatie: Punt is ongeldig.
- Fout bij het aanmaken van een dijk profiel locatie: offset is ongeldig.
+ Fout bij het aanmaken van een dijk profiel locatie: X0 is ongeldig.
Het bestand heeft een attribuut 'X0' zonder geldige waarde, welke vereist is om de locaties van de dijkprofielen in te lezen.
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,384 @@
+// 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.Collections.ObjectModel;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Common.Base.IO;
+using Core.Common.IO.Exceptions;
+using Core.Common.IO.Readers;
+using log4net;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionInwards.IO.DikeProfiles;
+using Ringtoets.GrassCoverErosionInwards.Plugin.Properties;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+
+namespace Ringtoets.GrassCoverErosionInwards.Plugin.FileImporter
+{
+ ///
+ /// Imports point shapefiles containing dike profile locations and text file containing the foreland/dike schematizations.
+ ///
+ public class DikeProfilesImporter : FileImporterBase
+ {
+ private readonly ILog log = LogManager.GetLogger(typeof(DikeProfilesImporter));
+
+ public override string Name
+ {
+ get
+ {
+ return "Dijkprofiel locaties";
+ }
+ }
+
+ public override string Category
+ {
+ get
+ {
+ return "Algemeen";
+ }
+ }
+
+ public override Bitmap Image
+ {
+ get
+ {
+ return Resources.DikeProfile;
+ }
+ }
+
+ public override string FileFilter
+ {
+ get
+ {
+ return string.Format("{0} {1} (*.shp)|*.shp",
+ "Dijkprofiel locaties", "Shape bestand");
+ }
+ }
+
+ public override ProgressChangedDelegate ProgressChanged { protected get; set; }
+
+ public override bool CanImportOn(object targetItem)
+ {
+ return base.CanImportOn(targetItem) && IsReferenceLineAvailable(targetItem);
+ }
+
+ public override bool Import(object targetItem, string filePath)
+ {
+ if (!IsReferenceLineAvailable(targetItem))
+ {
+ log.Error("Er is geen referentielijn beschikbaar. Geen data ingelezen.");
+ return false;
+ }
+
+ var dikeProfilesContext = (DikeProfilesContext) targetItem;
+ ReferenceLine referenceLine = dikeProfilesContext.ParentAssessmentSection.ReferenceLine;
+
+ ReadResult importDikeProfilesResult = ReadDikeProfileLocations(filePath, referenceLine);
+ if (importDikeProfilesResult.CriticalErrorOccurred)
+ {
+ return false;
+ }
+
+ if (ImportIsCancelled)
+ {
+ HandleUserCancellingImport();
+ return false;
+ }
+
+ string folder = Path.GetDirectoryName(filePath);
+ ReadResult importDikeProfileDataResult = ReadDikeProfileData(folder);
+ if (importDikeProfileDataResult.CriticalErrorOccurred)
+ {
+ return false;
+ }
+
+ if (ImportIsCancelled)
+ {
+ HandleUserCancellingImport();
+ return false;
+ }
+
+ ObservableList dikeProfiles = CreateDikeProfiles(importDikeProfilesResult.ImportedItems, importDikeProfileDataResult.ImportedItems);
+
+ foreach (DikeProfile dikeProfile in dikeProfiles)
+ {
+ dikeProfilesContext.WrappedData.Add(dikeProfile);
+ }
+
+ return true;
+ }
+
+ private ObservableList CreateDikeProfiles(ICollection dikeProfileCollection, ICollection dikeProfileDataCollection)
+ {
+ ObservableList dikeProfiles = new ObservableList();
+ foreach (DikeProfileLocation dikeProfileLocation in dikeProfileCollection)
+ {
+ string dikeProfileId = dikeProfileLocation.Id;
+
+ var matchingDikeProfileData = GetMatchingDikeProfileData(dikeProfileDataCollection, dikeProfileId);
+ if (matchingDikeProfileData != null)
+ {
+ DikeProfile dikeProfile = CreateDikeProfile(dikeProfileLocation, matchingDikeProfileData);
+ dikeProfiles.Add(dikeProfile);
+ }
+ }
+ return dikeProfiles;
+ }
+
+ private DikeProfileData GetMatchingDikeProfileData(ICollection dikeProfileDataCollection, string dikeProfileId)
+ {
+ IEnumerable dikeProfileData = dikeProfileDataCollection.Where(d => d.Id.Equals(dikeProfileId));
+ DikeProfileData[] filteredDikeProfileDataCollection = dikeProfileData as DikeProfileData[] ?? dikeProfileData.ToArray();
+ if (filteredDikeProfileDataCollection.Length == 0)
+ {
+ log.Error(string.Format("Kan geen dijkprofiel data vinden voor dijkprofiel locatie met Id: {0}", dikeProfileId));
+ return null;
+ }
+ if (filteredDikeProfileDataCollection.Length > 1)
+ {
+ log.Error(string.Format("Meerdere dijkprofiel data gevonden voor dijkprofiel locatie met Id: {0}. De eerste wordt gebruikt, de overigen worden overgeslagen.", dikeProfileId));
+ }
+ return filteredDikeProfileDataCollection[0];
+ }
+
+ private static DikeProfile CreateDikeProfile(DikeProfileLocation dikeProfileLocation, DikeProfileData dikeProfileData)
+ {
+ var dikeProfile = new DikeProfile(dikeProfileLocation.Point)
+ {
+ Name = dikeProfileData.Id,
+ Memo = dikeProfileData.Memo,
+ X0 = dikeProfileLocation.Offset,
+ Orientation = (RoundedDouble) dikeProfileData.Orientation,
+ ForeshoreGeometry = dikeProfileData.ForeshoreGeometry.Select(r => r.Point).ToList(),
+ DikeGeometry = dikeProfileData.DikeGeometry.ToList(),
+ DikeHeight = (RoundedDouble) dikeProfileData.DikeHeight
+ };
+
+ switch (dikeProfileData.DamType)
+ {
+ case DamType.None:
+ // Use default value
+ break;
+ case DamType.Caisson:
+ dikeProfile.BreakWater = new BreakWater(BreakWaterType.Caisson, dikeProfileData.DamHeight);
+ break;
+ case DamType.HarborDam:
+ dikeProfile.BreakWater = new BreakWater(BreakWaterType.Dam, dikeProfileData.DamHeight);
+ break;
+ case DamType.Vertical:
+ dikeProfile.BreakWater = new BreakWater(BreakWaterType.Wall, dikeProfileData.DamHeight);
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ return dikeProfile;
+ }
+
+ private ReadResult ReadDikeProfileData(string folder)
+ {
+ NotifyProgress("Inlezen van voorland of dijkprofiel data uit een prfl bestand.", 1, 1);
+ try
+ {
+ var dikeProfileDataReader = new DikeProfileDataReader();
+ return GetDikeProfileDataReadResult(dikeProfileDataReader, folder);
+ }
+ catch (CriticalFileReadException exception)
+ {
+ log.Error(exception.Message);
+ }
+ catch (ArgumentException exception)
+ {
+ log.Error(exception.Message);
+ }
+ return new ReadResult(true);
+ }
+
+ private ReadResult GetDikeProfileDataReadResult(DikeProfileDataReader dikeProfileDataReader, string folder)
+ {
+ string[] prflFilePaths;
+ try
+ {
+ prflFilePaths = Directory.GetFiles(folder, "*.prfl");
+ }
+ catch (Exception)
+ {
+ var message = string.Format("Niet in staat om naar prfl bestanden te zoeken in map: {0}", folder);
+ log.Error(message);
+ return new ReadResult(true);
+ }
+
+ var totalNumberOfSteps = prflFilePaths.Length;
+ var currentStep = 1;
+
+ var dikeProfileData = new Collection();
+ Dictionary> duplicates = new Dictionary>();
+
+ for (int i = 0; i < totalNumberOfSteps; i++)
+ {
+ if (ImportIsCancelled)
+ {
+ return new ReadResult(false);
+ }
+
+ try
+ {
+ NotifyProgress("Inlezen van voorland of dijkprofiel data.", currentStep++, totalNumberOfSteps);
+
+ DikeProfileData data = dikeProfileDataReader.ReadDikeProfileData(prflFilePaths[i]);
+ if (dikeProfileData.Any(d => d.Id.Equals(data.Id)))
+ {
+ if (!duplicates.ContainsKey(data.Id))
+ {
+ duplicates.Add(data.Id, new List());
+ }
+ duplicates[data.Id].Add(prflFilePaths[i]);
+ }
+ else
+ {
+ dikeProfileData.Add(data);
+ }
+ }
+ catch (CriticalFileReadException exception)
+ {
+ log.Error(exception.Message);
+ return new ReadResult(true);
+ }
+ }
+
+ LogDuplicateDikeProfileData(duplicates);
+
+ return new ReadResult(false)
+ {
+ ImportedItems = dikeProfileData
+ };
+ }
+
+ private void LogDuplicateDikeProfileData(Dictionary> duplicates)
+ {
+ foreach (KeyValuePair> keyValuePair in duplicates)
+ {
+ StringBuilder builder = new StringBuilder(string.Format("Meerdere dijkprofiel data bestanden gevonden met Id {0}. Alleen de eerste wordt gebruikt. De {1} overgeslagen bestanden zijn:", keyValuePair.Key, keyValuePair.Value.Count));
+ foreach (string filePath in keyValuePair.Value)
+ {
+ if (builder.Length + filePath.Length + Environment.NewLine.Length < builder.MaxCapacity)
+ {
+ builder.AppendLine(filePath);
+ }
+ }
+ string message = builder.ToString();
+ log.Error(message);
+ }
+ }
+
+ private void HandleUserCancellingImport()
+ {
+ log.Info("Dijkprofielen importeren is afgebroken. Geen data ingelezen.");
+ ImportIsCancelled = false;
+ }
+
+ private ReadResult ReadDikeProfileLocations(string filePath, ReferenceLine referenceLine)
+ {
+ NotifyProgress("Inlezen van dijkprofiel locaties uit een shape bestand.", 1, 1);
+ try
+ {
+ using (var dikeProfileLocationReader = new DikeProfileLocationReader(filePath))
+ {
+ return GetDikeProfileLocationReadResult(dikeProfileLocationReader, referenceLine);
+ }
+ }
+ catch (CriticalFileReadException exception)
+ {
+ log.Error(exception.Message);
+ }
+ catch (ArgumentException exception)
+ {
+ log.Error(exception.Message);
+ }
+ return new ReadResult(true);
+ }
+
+ private ReadResult GetDikeProfileLocationReadResult(DikeProfileLocationReader dikeProfileLocationReader, ReferenceLine referenceLine)
+ {
+ var totalNumberOfSteps = dikeProfileLocationReader.GetLocationCount;
+ var currentStep = 1;
+
+ var dikeProfileLocations = new Collection();
+ for (int i = 0; i < totalNumberOfSteps; i++)
+ {
+ if (ImportIsCancelled)
+ {
+ return new ReadResult(false);
+ }
+
+ try
+ {
+ NotifyProgress("Inlezen van dijkprofiel locatie.", currentStep++, totalNumberOfSteps);
+ AddNextDikeProfileLocation(dikeProfileLocationReader, referenceLine, dikeProfileLocations);
+ }
+ catch (CriticalFileReadException exception)
+ {
+ log.Error(exception.Message);
+ return new ReadResult(true);
+ }
+ }
+ return new ReadResult(false)
+ {
+ ImportedItems = dikeProfileLocations
+ };
+ }
+
+ private void AddNextDikeProfileLocation(DikeProfileLocationReader dikeProfileLocationReader, ReferenceLine referenceLine, Collection dikeProfileLocations)
+ {
+ DikeProfileLocation dikeProfileLocation = dikeProfileLocationReader.GetNextDikeProfileLocation();
+ double distanceToReferenceLine = GetDistanceToReferenceLine(dikeProfileLocation.Point, referenceLine);
+ if (distanceToReferenceLine > 1.0)
+ {
+ log.Error("Een dijkprofiel locatie ligt niet op de referentielijn. Locatie wordt overgeslagen.");
+ return;
+ }
+ dikeProfileLocations.Add(dikeProfileLocation);
+ }
+
+ private static bool IsReferenceLineAvailable(object targetItem)
+ {
+ return ((DikeProfilesContext) targetItem).ParentAssessmentSection.ReferenceLine != null;
+ }
+
+ private double GetDistanceToReferenceLine(Point2D point, ReferenceLine referenceLine)
+ {
+ return GetLineSegments(referenceLine.Points).Min(segment => segment.GetEuclideanDistanceToPoint(point));
+ }
+
+ private IEnumerable GetLineSegments(IEnumerable linePoints)
+ {
+ return Math2D.ConvertLinePointsToLineSegments(linePoints);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj
===================================================================
diff -u -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -32,6 +32,10 @@
AllRules.ruleset
+
+ ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll
+ True
+
@@ -41,6 +45,7 @@
Properties\GlobalAssembly.cs
+
@@ -75,6 +80,14 @@
Core.Common.Gui
False
+
+ {E344867E-9AC9-44C8-88A5-8185681679A9}
+ Core.Common.IO
+
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Utils
+
{c90b77da-e421-43cc-b82e-529651bc21ac}
Core.Common.Version
@@ -120,6 +133,10 @@
Ringtoets.GrassCoverErosionInwards.Forms
False
+
+ {F55CCA9C-3B25-417D-9AF4-797D1F5EB95E}
+ Ringtoets.GrassCoverErosionInwards.IO
+
{5D158D8E-A5EB-489C-A885-87E13BC0D3B3}
Ringtoets.GrassCoverErosionInwards.Service
@@ -134,6 +151,7 @@
+
Fisheye: Tag b5dda9752bc1d895c6c88427ef75c1771b671808 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/packages.config'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationReaderTest.cs
===================================================================
diff -u -r5a421e7bb0b0c52d5d1d9ca20d495cd11bfa10e8 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationReaderTest.cs (.../DikeProfileLocationReaderTest.cs) (revision 5a421e7bb0b0c52d5d1d9ca20d495cd11bfa10e8)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/DikeProfiles/DikeProfileLocationReaderTest.cs (.../DikeProfileLocationReaderTest.cs) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -120,51 +120,70 @@
}
[Test]
- [TestCase("Voorlanden 12-2.shp", 5)]
- [TestCase("Voorlanden_12-2_Alternative.shp", 9)]
- public void GetDikeProfileLocations_FileWithNLocations_ReturnNDikeProfileLocations(
- string fileName, int expectedNumberOfDikeProfileLocations)
+ [TestCase("Voorlanden_12-2_WithoutId.shp", "ID")]
+ [TestCase("Voorlanden_12-2_WithoutName.shp", "Naam")]
+ [TestCase("Voorlanden_12-2_WithoutX0.shp", "X0")]
+ public void Constructor_FileMissingAttributeColumn_ThrowCriticalFileReadException(
+ string fileName, string missingColumnName)
{
// Setup
+ string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", fileName));
+
+ // Call
+ TestDelegate call = () => new DikeProfileLocationReader(invalidFilePath);
+
+ // Assert
+ var expectedMessage = string.Format("Het bestand heeft geen attribuut '{0}' welke vereist is om de locaties van de dijkprofielen in te lezen.",
+ missingColumnName);
+ string message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void GetLocationCount_FileWithFivePoints_GetFive()
+ {
+ // Setup
string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
- Path.Combine("DikeProfiles", fileName));
+ Path.Combine("DikeProfiles", "Voorlanden 12-2.shp"));
using (var reader = new DikeProfileLocationReader(validFilePath))
{
// Call
- IList dikeProfileLocations = reader.GetDikeProfileLocations();
+ int count = reader.GetLocationCount;
// Assert
- Assert.AreEqual(expectedNumberOfDikeProfileLocations, dikeProfileLocations.Count);
+ Assert.AreEqual(5, count);
}
}
[Test]
- [TestCase("Voorlanden_12-2_WithoutId.shp", "ID")]
- [TestCase("Voorlanden_12-2_WithoutName.shp", "Naam")]
- [TestCase("Voorlanden_12-2_WithoutX0.shp", "X0")]
- public void GetDikeProfileLocations_FileMissingAttributeColumn_ThrowCriticalFileReadException(
- string fileName, string missingColumnName)
+ [TestCase("Voorlanden 12-2.shp", 5)]
+ [TestCase("Voorlanden_12-2_Alternative.shp", 9)]
+ public void GetDikeProfileLocation_FileWithNLocations_GetNDikeProfileLocations(
+ string fileName, int expectedNumberOfDikeProfileLocations)
{
// Setup
- string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
- Path.Combine("DikeProfiles", fileName));
+ string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", fileName));
+ IList dikeProfileLocations = new List();
- using (var reader = new DikeProfileLocationReader(invalidFilePath))
+ using (var reader = new DikeProfileLocationReader(validFilePath))
{
// Call
- TestDelegate call = () => reader.GetDikeProfileLocations();
+ int count = reader.GetLocationCount;
+ for (int i = 0; i < count; i++)
+ {
+ dikeProfileLocations.Add(reader.GetNextDikeProfileLocation());
+ }
// Assert
- var expectedMessage = string.Format("Het bestand heeft geen attribuut '{0}' welke vereist is om de locaties van de dijkprofielen in te lezen.",
- missingColumnName);
- string message = Assert.Throws(call).Message;
- Assert.AreEqual(expectedMessage, message);
+ Assert.AreEqual(expectedNumberOfDikeProfileLocations, dikeProfileLocations.Count);
}
}
[Test]
- public void GetDikeProfileLocations_FileWithNullId_ThrowCriticalFileReadException()
+ public void GetDikeProfileLocation_FileWithNullId_ThrowCriticalFileReadException()
{
// Setup
string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
@@ -173,7 +192,7 @@
using (var reader = new DikeProfileLocationReader(invalidFilePath))
{
// Call
- TestDelegate call = () => reader.GetDikeProfileLocations();
+ TestDelegate call = () => reader.GetNextDikeProfileLocation();
// Assert
var expectedMessage = "De locatie parameter 'Id' heeft geen waarde.";
@@ -183,7 +202,7 @@
}
[Test]
- public void GetDikeProfileLocations_FileWithNullX0_ThrowCriticalFileReadException()
+ public void GetDikeProfileLocation_FileWithNullX0_ThrowCriticalFileReadException()
{
// Setup
string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
@@ -192,7 +211,7 @@
using (var reader = new DikeProfileLocationReader(invalidFilePath))
{
// Call
- TestDelegate call = () => reader.GetDikeProfileLocations();
+ TestDelegate call = () => reader.GetNextDikeProfileLocation();
// Assert
var expectedMessage = "Het bestand heeft een attribuut 'X0' zonder geldige waarde, welke vereist is om de locaties van de dijkprofielen in te lezen.";
@@ -204,7 +223,7 @@
[Test]
[TestCase("Voorlanden_12-2_IdWithSymbol.shp")]
[TestCase("Voorlanden_12-2_IdWithWhitespace.shp")]
- public void GetDikeProfileLocations_FileWithIllegalCharactersInId_ThrowCriticalFileReadException(string fileName)
+ public void GetDikeProfileLocation_FileWithIllegalCharactersInId_ThrowCriticalFileReadException(string fileName)
{
// Setup
string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
@@ -213,7 +232,7 @@
using (var reader = new DikeProfileLocationReader(invalidFilePath))
{
// Call
- TestDelegate call = () => reader.GetDikeProfileLocations();
+ TestDelegate call = () => reader.GetNextDikeProfileLocation();
// Assert
var expectedMessage = "De locatie parameter 'Id' bevat meer dan letters en cijfers.";
@@ -223,117 +242,120 @@
}
[Test]
- public void GetDikeProfileLocations_FileWithNullAsNameAttribute_GetLocations()
+ public void GetDikeProfileLocation_FileWithNullAsNameAttribute_GetLocations()
{
// Setup
string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
Path.Combine("DikeProfiles", "Voorlanden_12-2_EmptyName.shp"));
+ IList dikeProfileLocations = new List();
using (var reader = new DikeProfileLocationReader(invalidFilePath))
{
// Call
- IEnumerable locations = reader.GetDikeProfileLocations();
+ int count = reader.GetLocationCount;
+ for (int i = 0; i < count; i++)
+ {
+ dikeProfileLocations.Add(reader.GetNextDikeProfileLocation());
+ }
// Assert
- Assert.AreEqual(5, locations.Count());
+ Assert.AreEqual(5, dikeProfileLocations.Count);
}
}
[Test]
- public void GetDikeProfileLocations_FileWithFivePoints_GetFiveLocations()
+ public void GetDikeProfileLocation_FileWithFivePoints_GetFiveLocationsWithCorrectAtrributes()
{
// Setup
string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
Path.Combine("DikeProfiles", "Voorlanden 12-2.shp"));
+ IList dikeProfileLocations = new List();
using (var reader = new DikeProfileLocationReader(validFilePath))
{
// Call
- IEnumerable locations = reader.GetDikeProfileLocations();
+ int count = reader.GetLocationCount;
+ for (int i = 0; i < count; i++)
+ {
+ dikeProfileLocations.Add(reader.GetNextDikeProfileLocation());
+ }
// Assert
- Assert.AreEqual(5, locations.Count());
- }
- }
+ Assert.AreEqual("profiel001", dikeProfileLocations[0].Id);
+ Assert.AreEqual("profiel002", dikeProfileLocations[1].Id);
+ Assert.AreEqual("profiel003", dikeProfileLocations[2].Id);
+ Assert.AreEqual("profiel004", dikeProfileLocations[3].Id);
+ Assert.AreEqual("profiel005", dikeProfileLocations[4].Id);
- [Test]
- public void GetDikeProfileLocations_FileWithFivePoints_GetFiveLocationsWithCorrectAtrributes()
- {
- // Setup
- string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
- Path.Combine("DikeProfiles", "Voorlanden 12-2.shp"));
+ Assert.AreEqual("profiel001", dikeProfileLocations[0].Name);
+ Assert.AreEqual("profiel002", dikeProfileLocations[1].Name);
+ Assert.AreEqual("profiel003", dikeProfileLocations[2].Name);
+ Assert.AreEqual("profiel004", dikeProfileLocations[3].Name);
+ Assert.AreEqual("profiel005", dikeProfileLocations[4].Name);
- using (var reader = new DikeProfileLocationReader(validFilePath))
- {
- // Call
- IList locations = reader.GetDikeProfileLocations();
-
- // Assert
- Assert.AreEqual("profiel001", locations[0].Id);
- Assert.AreEqual("profiel002", locations[1].Id);
- Assert.AreEqual("profiel003", locations[2].Id);
- Assert.AreEqual("profiel004", locations[3].Id);
- Assert.AreEqual("profiel005", locations[4].Id);
-
- Assert.AreEqual("profiel001", locations[0].Name);
- Assert.AreEqual("profiel002", locations[1].Name);
- Assert.AreEqual("profiel003", locations[2].Name);
- Assert.AreEqual("profiel004", locations[3].Name);
- Assert.AreEqual("profiel005", locations[4].Name);
-
- Assert.AreEqual(-10.61273321, locations[0].Offset);
- Assert.AreEqual(-9.4408575, locations[1].Offset);
- Assert.AreEqual(8.25860742, locations[2].Offset);
- Assert.AreEqual(-17.93475471, locations[3].Offset);
- Assert.AreEqual(15.56165507, locations[4].Offset);
+ Assert.AreEqual(-10.61273321, dikeProfileLocations[0].Offset);
+ Assert.AreEqual(-9.4408575, dikeProfileLocations[1].Offset);
+ Assert.AreEqual(8.25860742, dikeProfileLocations[2].Offset);
+ Assert.AreEqual(-17.93475471, dikeProfileLocations[3].Offset);
+ Assert.AreEqual(15.56165507, dikeProfileLocations[4].Offset);
}
}
[Test]
- public void GetDikeProfileLocations_FileWithFivePoints_GetFiveLocationsWithPoint2D()
+ public void GetDikeProfileLocation_FileWithFivePoints_GetFiveLocationsWithPoint2D()
{
// Setup
string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
Path.Combine("DikeProfiles", "Voorlanden 12-2.shp"));
+ IList dikeProfileLocations = new List();
using (var reader = new DikeProfileLocationReader(validFilePath))
{
// Call
- IList locations = reader.GetDikeProfileLocations();
+ int count = reader.GetLocationCount;
+ for (int i = 0; i < count; i++)
+ {
+ dikeProfileLocations.Add(reader.GetNextDikeProfileLocation());
+ }
// Assert
- Assert.IsInstanceOf(typeof(Point2D), locations[0].Point);
- Assert.IsInstanceOf(typeof(Point2D), locations[1].Point);
- Assert.IsInstanceOf(typeof(Point2D), locations[2].Point);
- Assert.IsInstanceOf(typeof(Point2D), locations[3].Point);
- Assert.IsInstanceOf(typeof(Point2D), locations[4].Point);
+ Assert.IsInstanceOf(typeof(Point2D), dikeProfileLocations[0].Point);
+ Assert.IsInstanceOf(typeof(Point2D), dikeProfileLocations[1].Point);
+ Assert.IsInstanceOf(typeof(Point2D), dikeProfileLocations[2].Point);
+ Assert.IsInstanceOf(typeof(Point2D), dikeProfileLocations[3].Point);
+ Assert.IsInstanceOf(typeof(Point2D), dikeProfileLocations[4].Point);
}
}
[Test]
- public void GetDikeProfileLocations_FileWithFivePoints_GetFivePoint2DsWithCorrectCoordinates()
+ public void GetDikeProfileLocation_FileWithFivePoints_GetFivePoint2DsWithCorrectCoordinates()
{
// Setup
string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
Path.Combine("DikeProfiles", "Voorlanden 12-2.shp"));
+ IList dikeProfileLocations = new List();
using (var reader = new DikeProfileLocationReader(validFilePath))
{
// Call
- IList locations = reader.GetDikeProfileLocations();
+ int count = reader.GetLocationCount;
+ for (int i = 0; i < count; i++)
+ {
+ dikeProfileLocations.Add(reader.GetNextDikeProfileLocation());
+ }
// Assert
- Assert.AreEqual(131223.21400000341, locations[0].Point.X);
- Assert.AreEqual(133854.31200000079, locations[1].Point.X);
- Assert.AreEqual(135561.0960000027, locations[2].Point.X);
- Assert.AreEqual(136432.12250000238, locations[3].Point.X);
- Assert.AreEqual(136039.49100000039, locations[4].Point.X);
+ Assert.AreEqual(131223.21400000341, dikeProfileLocations[0].Point.X);
+ Assert.AreEqual(133854.31200000079, dikeProfileLocations[1].Point.X);
+ Assert.AreEqual(135561.0960000027, dikeProfileLocations[2].Point.X);
+ Assert.AreEqual(136432.12250000238, dikeProfileLocations[3].Point.X);
+ Assert.AreEqual(136039.49100000039, dikeProfileLocations[4].Point.X);
- Assert.AreEqual(548393.43800000288, locations[0].Point.Y);
- Assert.AreEqual(545323.13749999879, locations[1].Point.Y);
- Assert.AreEqual(541920.34149999847, locations[2].Point.Y);
- Assert.AreEqual(538235.26300000318, locations[3].Point.Y);
- Assert.AreEqual(533920.28050000477, locations[4].Point.Y);
+ Assert.AreEqual(548393.43800000288, dikeProfileLocations[0].Point.Y);
+ Assert.AreEqual(545323.13749999879, dikeProfileLocations[1].Point.Y);
+ Assert.AreEqual(541920.34149999847, dikeProfileLocations[2].Point.Y);
+ Assert.AreEqual(538235.26300000318, dikeProfileLocations[3].Point.Y);
+ Assert.AreEqual(533920.28050000477, dikeProfileLocations[4].Point.Y);
}
}
}
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/Voorlanden 12-2.dbf
===================================================================
diff -u
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/Voorlanden 12-2.prj
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/Voorlanden 12-2.prj (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/Voorlanden 12-2.prj (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1 @@
+PROJCS["RD_New",GEOGCS["GCS_Amersfoort",DATUM["D_Amersfoort",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Double_Stereographic"],PARAMETER["False_Easting",155000.0],PARAMETER["False_Northing",463000.0],PARAMETER["Central_Meridian",5.38763888888889],PARAMETER["Scale_Factor",0.9999079],PARAMETER["Latitude_Of_Origin",52.15616055555555],UNIT["Meter",1.0]]
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/Voorlanden 12-2.shp
===================================================================
diff -u
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/Voorlanden 12-2.shx
===================================================================
diff -u
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel001 - Ringtoets.prfl
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel001 - Ringtoets.prfl (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel001 - Ringtoets.prfl (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,22 @@
+VERSIE 4.0
+ID profiel001
+
+RICHTING 330
+
+DAM 0
+DAMHOOGTE 0
+
+VOORLAND 0
+
+DAMWAND 0
+KRUINHOOGTE 6
+DIJK 2
+0.000 0.000 1.000
+18.000 6.000 1.000
+
+MEMO
+Verkenning prfl format:
+Basis:
+geen dam
+geen voorland
+recht talud
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel002 - Ringtoets.prfl
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel002 - Ringtoets.prfl (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel002 - Ringtoets.prfl (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,23 @@
+VERSIE 4.0
+ID profiel002
+
+RICHTING 330
+
+DAM 0
+DAMHOOGTE 0
+
+VOORLAND 0
+
+DAMWAND 0
+KRUINHOOGTE 6
+DIJK 4
+-18.000 -6.000 1.000
+-2.000 -0.100 0.500
+2.000 0.100 1.000
+18.000 6.000 1.000
+
+MEMO
+Verkenning prfl format:
+geen dam
+geen voorland
+talud met (ruwe) berm
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel003 - Ringtoets.prfl
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel003 - Ringtoets.prfl (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel003 - Ringtoets.prfl (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,23 @@
+VERSIE 4.0
+ID profiel003
+
+RICHTING 330
+
+DAM 3
+DAMHOOGTE 0.5
+
+VOORLAND 0
+
+DAMWAND 0
+KRUINHOOGTE 6
+DIJK 4
+-18.000 -6.000 1.000
+-2.000 -0.100 0.500
+2.000 0.100 1.000
+18.000 6.000 1.000
+
+MEMO
+Verkenning prfl format:
+dam: havendam
+geen voorland
+talud met (ruwe) berm
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel004 - Ringtoets.prfl
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel004 - Ringtoets.prfl (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel004 - Ringtoets.prfl (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,26 @@
+VERSIE 4.0
+ID profiel004
+
+RICHTING 330
+
+DAM 0
+DAMHOOGTE 0.5
+
+VOORLAND 3
+-150.000 -9.000 1.000
+-100.000 -6.000 1.000
+-18.000 -6.000 1.000
+
+DAMWAND 0
+KRUINHOOGTE 6
+DIJK 4
+-18.000 -6.000 1.000
+-2.000 -0.100 0.500
+2.000 0.100 1.000
+18.000 6.000 1.000
+
+MEMO
+Verkenning prfl format:
+geen dam
+voorland
+talud met (ruwe) berm
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel005 - Ringtoets.prfl
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel005 - Ringtoets.prfl (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/AllOkTestData/profiel005 - Ringtoets.prfl (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,26 @@
+VERSIE 4.0
+ID profiel005
+
+RICHTING 330
+
+DAM 3
+DAMHOOGTE 0.5
+
+VOORLAND 3
+-150.000 -9.000 1.000
+-100.000 -6.000 1.000
+-18.000 -6.000 1.000
+
+DAMWAND 0
+KRUINHOOGTE 6
+DIJK 4
+-18.000 -6.000 1.000
+-2.000 -0.100 0.500
+2.000 0.100 1.000
+18.000 6.000 1.000
+
+MEMO
+Verkenning prfl format:
+dam: havendam
+voorland
+talud met (ruwe) berm
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/Voorlanden_12-2_EmptyId.dbf
===================================================================
diff -u -raf83c5308c30a462589f45eecd5ba0dfac0cda00 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/Voorlanden_12-2_EmptyName.dbf
===================================================================
diff -u -raf83c5308c30a462589f45eecd5ba0dfac0cda00 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/Voorlanden_12-2_EmptyX0.dbf
===================================================================
diff -u -raf83c5308c30a462589f45eecd5ba0dfac0cda00 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/Voorlanden_12-2_IdWithSymbol.dbf
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/DikeProfiles/Voorlanden_12-2_IdWithWhitespace.dbf
===================================================================
diff -u -r0eafbd198165fdfb8a3f9fabfa29919dd573d274 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
Binary files differ
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporter/DikeProfilesImporterTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporter/DikeProfilesImporterTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporter/DikeProfilesImporterTest.cs (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -0,0 +1,534 @@
+// 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.IO;
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using Core.Common.Utils.Builders;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionInwards.Plugin.FileImporter;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+
+namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.FileImporter
+{
+ [TestFixture]
+ public class DikeProfilesImporterTest
+ {
+ private MockRepository mockRepository;
+ private int progress;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mockRepository = new MockRepository();
+ progress = 0;
+ }
+
+ [Test]
+ public void DefaultConstructor_ExpectedValues()
+ {
+ // Prepare
+ var expectedFileFilter = String.Format("{0} {1} (*.shp)|*.shp",
+ "Dijkprofiel locaties", "Shape bestand");
+
+ // Call
+ var importer = new DikeProfilesImporter();
+
+ // Assert
+ Assert.AreEqual("Dijkprofiel locaties", importer.Name);
+ Assert.AreEqual("Algemeen", importer.Category);
+ Assert.AreEqual(16, importer.Image.Width);
+ Assert.AreEqual(16, importer.Image.Height);
+ Assert.AreEqual(expectedFileFilter, importer.FileFilter);
+ }
+
+ [Test]
+ public void CanImportOn_ValidContext_ReturnTrue()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+ mocks.ReplayAll();
+
+ // Call
+ var canImport = dikeProfilesImporter.CanImportOn(targetContext);
+
+ // Assert
+ Assert.IsTrue(canImport);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanImportOn_ValidContextWithoutReferenceLine_ReturnFalse()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+ mocks.ReplayAll();
+
+ // Call
+ var canImport = dikeProfilesImporter.CanImportOn(targetContext);
+
+ // Assert
+ Assert.IsFalse(canImport);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void Import_FromInvalidEmptyPath_FalseAndLogError(string filePath)
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = new FileReaderErrorMessageBuilder(filePath)
+ .Build(CoreCommonUtilsResources.Error_Path_must_be_specified);
+ StringAssert.StartsWith(messageArray[0], message);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Import_FromPathContainingInvalidFileCharacters_FalseAndLogError()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ var filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils, "validFile.txt");
+ var invalidFileNameChars = Path.GetInvalidFileNameChars();
+ var invalidPath = filePath.Replace('d', invalidFileNameChars[0]);
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, invalidPath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = new FileReaderErrorMessageBuilder(invalidPath)
+ .Build(string.Format(CoreCommonUtilsResources.Error_Path_cannot_contain_Characters_0_, string.Join(", ", Path.GetInvalidFileNameChars())));
+ StringAssert.StartsWith(messageArray[0], message);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Import_FromDirectoryPath_FalseAndLogError()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ var folderPath = TestHelper.GetTestDataPath(TestDataPath.Core.Common.Utils) + Path.DirectorySeparatorChar;
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, folderPath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = new FileReaderErrorMessageBuilder(folderPath)
+ .Build(CoreCommonUtilsResources.Error_Path_must_not_point_to_folder);
+ StringAssert.StartsWith(messageArray[0], message);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("Multiple_Polygon_with_ID.shp")]
+ [TestCase("Multiple_PolyLine_with_ID.shp")]
+ [TestCase("Single_Multi-Polygon_with_ID.shp")]
+ [TestCase("Single_Multi-PolyLine_with_ID.shp")]
+ [TestCase("Single_Polygon_with_ID.shp")]
+ [TestCase("Single_PolyLine_with_ID.shp")]
+ public void Import_FromFileWithNonPointFeatures_FalseAndLogError(string shapeFileName)
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = new FileReaderErrorMessageBuilder(filePath)
+ .Build(string.Format("Fout bij het lezen van bestand '{0}': Het bestand mag uitsluitend punten bevatten.",
+ filePath));
+ StringAssert.EndsWith(messageArray[0], message);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("Voorlanden_12-2_WithoutId.shp", "ID")]
+ [TestCase("Voorlanden_12-2_WithoutName.shp", "Naam")]
+ [TestCase("Voorlanden_12-2_WithoutX0.shp", "X0")]
+ public void Import_FromFileMissingAttributeColumn_FalseAndLogError(
+ string shapeFileName, string missingColumnName)
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", shapeFileName));
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = string.Format("Het bestand heeft geen attribuut '{0}' welke vereist is om de locaties van de dijkprofielen in te lezen.",
+ missingColumnName);
+ Assert.AreEqual(message, messageArray[0]);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("Voorlanden_12-2_IdWithSymbol.shp")]
+ [TestCase("Voorlanden_12-2_IdWithWhitespace.shp")]
+ public void Import_FromFileWithIllegalCharactersInId_FalseAndLogError(string fileName)
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", fileName));
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = "De locatie parameter 'Id' bevat meer dan letters en cijfers.";
+ Assert.AreEqual(message, messageArray[0]);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Import_FromFileWithEmptyEntryForId_FalseAndLogError()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", "Voorlanden_12-2_EmptyId.shp"));
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = "De locatie parameter 'Id' heeft geen waarde.";
+ Assert.AreEqual(message, messageArray[0]);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Import_FromFileWithEmptyEntryForX0_FalseAndLogError()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", "Voorlanden_12-2_EmptyX0.shp"));
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mockRepository.ReplayAll();
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] messageArray = messages.ToArray();
+ string message = "Het bestand heeft een attribuut 'X0' zonder geldige waarde, welke vereist is om de locaties van de dijkprofielen in te lezen.";
+ Assert.AreEqual(message, messageArray[0]);
+ });
+ Assert.IsFalse(importResult);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Import_NoReferenceLine_CancelImportWithErrorMessage()
+ {
+ // Setup
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", "Voorlanden 12-2.shp"));
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var targetContextWithoutReferenceLine = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+ mocks.ReplayAll();
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContextWithoutReferenceLine, filePath);
+
+ // Assert
+ var expectedMessage = "Er is geen referentielijn beschikbaar. Geen data ingelezen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsFalse(importResult);
+ CollectionAssert.IsEmpty(targetContextWithoutReferenceLine.WrappedData);
+ Assert.AreEqual(0, progress);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Import_DikeProfileLocationsNotCloseEnoughToReferenceLine_TrueAndLogError()
+ {
+ // Setup
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp"));
+
+ var observer = mockRepository.StrictMock();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ var referencePoints = new List
+ {
+ new Point2D(141223.2,548393.4),
+ new Point2D(143854.3,545323.1),
+ new Point2D(145561.0,541920.3),
+ new Point2D(146432.1,538235.2),
+ new Point2D(146039.4,533920.2)
+ };
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(referencePoints);
+ mockRepository.ReplayAll();
+
+ var progressChangeNotifications = new List();
+ var dikeProfilesImporter = new DikeProfilesImporter
+ {
+ ProgressChanged = (description, step, steps) => { progressChangeNotifications.Add(new ProgressNotification(description, step, steps)); }
+ };
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+ targetContext.Attach(observer);
+
+ //Precondition
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ var expectedMessages = Enumerable.Repeat("Een dijkprofiel locatie ligt niet op de referentielijn. Locatie wordt overgeslagen.", 5).ToList();
+ TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, expectedMessages.Count);
+ Assert.IsTrue(importResult);
+ mockRepository.VerifyAll(); // 'observer' should not be notified
+ }
+
+ [Test]
+ public void Import_ValidTargetAndValidFile_TrueAndLogMessages()
+ {
+ // Setup
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO,
+ Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp"));
+
+ var observer = mockRepository.StrictMock();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ var assessmentSection = mockRepository.Stub();
+ var referencePoints = new List
+ {
+ new Point2D(131223.2,548393.4),
+ new Point2D(133854.3,545323.1),
+ new Point2D(135561.0,541920.3),
+ new Point2D(136432.1,538235.2),
+ new Point2D(136039.4,533920.2)
+ };
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(referencePoints);
+ mockRepository.ReplayAll();
+
+ var progressChangeNotifications = new List();
+ DikeProfilesImporter dikeProfilesImporter = new DikeProfilesImporter
+ {
+ ProgressChanged = (description, step, steps) => { progressChangeNotifications.Add(new ProgressNotification(description, step, steps)); }
+ };
+
+ var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection);
+ targetContext.Attach(observer);
+
+ // Call
+ bool importResult = dikeProfilesImporter.Import(targetContext, filePath);
+
+ // Assert
+ Assert.IsTrue(importResult);
+ List expectedProgressMessages = new List
+ {
+ new ProgressNotification("Inlezen van dijkprofiel locaties uit een shape bestand.", 1, 1),
+ new ProgressNotification("Inlezen van dijkprofiel locatie.", 1, 5),
+ new ProgressNotification("Inlezen van dijkprofiel locatie.", 2, 5),
+ new ProgressNotification("Inlezen van dijkprofiel locatie.", 3, 5),
+ new ProgressNotification("Inlezen van dijkprofiel locatie.", 4, 5),
+ new ProgressNotification("Inlezen van dijkprofiel locatie.", 5, 5),
+ new ProgressNotification("Inlezen van voorland of dijkprofiel data uit een prfl bestand.", 1, 1),
+ new ProgressNotification("Inlezen van voorland of dijkprofiel data.", 1, 5),
+ new ProgressNotification("Inlezen van voorland of dijkprofiel data.", 2, 5),
+ new ProgressNotification("Inlezen van voorland of dijkprofiel data.", 3, 5),
+ new ProgressNotification("Inlezen van voorland of dijkprofiel data.", 4, 5),
+ new ProgressNotification("Inlezen van voorland of dijkprofiel data.", 5, 5)
+ };
+ Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count);
+ for (var i = 0; i < expectedProgressMessages.Count; i++)
+ {
+ var notification = expectedProgressMessages[i];
+ var actualNotification = progressChangeNotifications[i];
+ Assert.AreEqual(notification.Text, actualNotification.Text);
+ Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep);
+ Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps);
+ }
+ mockRepository.VerifyAll(); // 'observer' should not be notified
+ }
+
+ private class ProgressNotification
+ {
+ public ProgressNotification(string description, int currentStep, int totalSteps)
+ {
+ Text = description;
+ CurrentStep = currentStep;
+ TotalSteps = totalSteps;
+ }
+
+ public string Text { get; private set; }
+ public int CurrentStep { get; private set; }
+ public int TotalSteps { get; private set; }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj
===================================================================
diff -u -r5150f97d1c5e019d39723b22ff200e48b2112e71 -r5bf1ff8f68f3b19d538edfe0550c39fc691a924b
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 5150f97d1c5e019d39723b22ff200e48b2112e71)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 5bf1ff8f68f3b19d538edfe0550c39fc691a924b)
@@ -51,6 +51,7 @@
+
@@ -78,6 +79,10 @@
{30e4c2ae-719e-4d70-9fa9-668a9767fbfa}
Core.Common.Gui
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Utils
+
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil