Index: Core/Common/src/Core.Common.Gui/Settings/SettingsHelper.cs
===================================================================
diff -u -re12dd6e3a4e1190e0a4cbf404d5efcf1f00d574e -r37235d0863116292cc4b095dcf2d19cf6d14c6b2
--- Core/Common/src/Core.Common.Gui/Settings/SettingsHelper.cs (.../SettingsHelper.cs) (revision e12dd6e3a4e1190e0a4cbf404d5efcf1f00d574e)
+++ Core/Common/src/Core.Common.Gui/Settings/SettingsHelper.cs (.../SettingsHelper.cs) (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -78,14 +78,5 @@
return appSettingsDirectoryPath;
}
-
- ///
- /// Gets the common documents directory.
- ///
- /// Directory path where the common documents can be found.
- public static string GetCommonDocumentsDirectory()
- {
- return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "WTI", "NBPW");
- }
}
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs
===================================================================
diff -u -re12dd6e3a4e1190e0a4cbf404d5efcf1f00d574e -r37235d0863116292cc4b095dcf2d19cf6d14c6b2
--- Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs (.../SettingsHelperTest.cs) (revision e12dd6e3a4e1190e0a4cbf404d5efcf1f00d574e)
+++ Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs (.../SettingsHelperTest.cs) (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -74,18 +74,5 @@
// Assert
Assert.AreEqual(appSettingsDirectoryPath, pathFromSettings);
}
-
- [Test]
- public void GetCommonDocumentsDirectory_ReturnsCommonDocumentsDirectory()
- {
- // Setup
- var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "WTI", "NBPW");
-
- // Call
- var pathFromSettings = SettingsHelper.GetCommonDocumentsDirectory();
-
- // Assert
- Assert.AreEqual(path, pathFromSettings);
- }
}
}
\ No newline at end of file
Fisheye: Tag 37235d0863116292cc4b095dcf2d19cf6d14c6b2 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/AssessmentSectionFromFileCommandHandler.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -0,0 +1,167 @@
+// 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.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.IO.Exceptions;
+using log4net;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.IO;
+using Ringtoets.Common.IO.Exceptions;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.Properties;
+
+namespace Ringtoets.Integration.Forms.Commands
+{
+ ///
+ /// This class provides concrete implementation for .
+ ///
+ public class AssessmentSectionFromFileCommandHandler
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(AssessmentSectionFromFileCommandHandler));
+
+ private readonly IWin32Window dialogParent;
+ private IEnumerable settings;
+ private IEnumerable referenceLineMetas = new List();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The parent of the dialog.
+ public AssessmentSectionFromFileCommandHandler(IWin32Window dialogParent)
+ {
+ this.dialogParent = dialogParent;
+ }
+
+ ///
+ /// Creates a new , based upon the in a dialog selected , which is derived from the shape file in .
+ ///
+ /// The path to the folder where a shape file should be read.
+ ///
+ /// Thrown when:
+ ///
+ /// The shape file does not contain any polylines.
+ /// The shape file does not contain the required attributes.
+ /// The assessment section ids in the shape file are not unique or are missing.
+ ///
+ /// Thrown when:
+ ///
+ /// points to an invalid directory.
+ /// The path does not contain any shape files.
+ ///
+ public IAssessmentSection CreateAssessmentSectionFromFile(string folderpath)
+ {
+ ValidateAssessmentSectionSettings();
+ ValidateReferenceLineMetas(folderpath);
+
+ using (var dialog = CreateReferenceLineMetaSelectionDialogWithItems())
+ {
+ if (dialog.ShowDialog() != DialogResult.OK)
+ {
+ return null;
+ }
+ var selectedItem = dialog.SelectedReferenceLineMeta;
+ return selectedItem == null ? null : CreateAssessmentSection(selectedItem, dialog.SelectedLimitValue);
+ }
+ }
+
+ private IAssessmentSection CreateAssessmentSection(ReferenceLineMeta selectedItem, int? selectedLimitValue)
+ {
+ IAssessmentSection assessmentSection;
+ var settingOfSelectedAssessmentSection = settings.FirstOrDefault(s => s.AssessmentSectionId == selectedItem.AssessmentSectionId);
+ if (settingOfSelectedAssessmentSection == null)
+ {
+ log.Warn(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_No_settings_found_for_AssessmentSection);
+ assessmentSection = CreateDikeAssessmentSection();
+ }
+ else
+ {
+ assessmentSection = (settingOfSelectedAssessmentSection.IsDune) ?
+ CreateDuneAssessmentSection() :
+ CreateDikeAssessmentSection(settingOfSelectedAssessmentSection);
+ }
+
+ assessmentSection.Id = selectedItem.AssessmentSectionId;
+ assessmentSection.ReferenceLine = selectedItem.ReferenceLine;
+
+ if (selectedLimitValue.HasValue)
+ {
+ assessmentSection.FailureMechanismContribution.Norm = selectedLimitValue.Value;
+ }
+ return assessmentSection;
+ }
+
+ private static void SetFailureMechanismsValueN(AssessmentSection assessmentSection, int n)
+ {
+ assessmentSection.GrassCoverErosionInwards.GeneralInput.N = n;
+ assessmentSection.HeightStructures.GeneralInput.N = n;
+ }
+
+ private ReferenceLineMetaSelectionDialog CreateReferenceLineMetaSelectionDialogWithItems()
+ {
+ return new ReferenceLineMetaSelectionDialog(dialogParent, referenceLineMetas);
+ }
+
+ #region Create AssessmentSection
+
+ private static AssessmentSection CreateDikeAssessmentSection()
+ {
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ return assessmentSection;
+ }
+
+ private static AssessmentSection CreateDikeAssessmentSection(AssessmentSectionSettings settings)
+ {
+ var assessmentSection = CreateDikeAssessmentSection();
+ SetFailureMechanismsValueN(assessmentSection, settings.N);
+ return assessmentSection;
+ }
+
+ private static IAssessmentSection CreateDuneAssessmentSection()
+ {
+ return new AssessmentSection(AssessmentSectionComposition.Dune);
+ }
+
+ #endregion
+
+ #region Validators
+
+ private void ValidateReferenceLineMetas(string folderpath)
+ {
+ var importer = new ReferenceLineMetaImporter(folderpath);
+ referenceLineMetas = importer.GetReferenceLineMetas().ToArray();
+
+ if (!referenceLineMetas.Any())
+ {
+ throw new CriticalFileValidationException(Resources.AssessmentSectionFromFileCommandHandler_ValidateReferenceLineMetas_No_referenceLines_in_file);
+ }
+ }
+
+ private void ValidateAssessmentSectionSettings()
+ {
+ var reader = new AssessmentSectionSettingsReader();
+ settings = reader.ReadSettings();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r1e5d9b5cfc66cb8187d534d891afef1c9080378b -r37235d0863116292cc4b095dcf2d19cf6d14c6b2
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 1e5d9b5cfc66cb8187d534d891afef1c9080378b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -46,7 +46,7 @@
Properties\GlobalAssembly.cs
-
+
@@ -66,6 +66,7 @@
ReferenceLineMetaSelectionDialog.cs
+ UserControl
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/RingtoetsSettingsHelper.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/RingtoetsSettingsHelper.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/RingtoetsSettingsHelper.cs (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -0,0 +1,46 @@
+// 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.IO;
+
+namespace Ringtoets.Integration.Forms
+{
+ ///
+ /// Class that defines helper methods related to Ringtoets settings.
+ ///
+ public static class RingtoetsSettingsHelper
+ {
+ ///
+ /// Gets the common documents directory.
+ ///
+ /// Directory path where the common documents can be found.
+ public static string GetCommonDocumentsRingtoetsShapeFileDirectory()
+ {
+ return Path.Combine(GetCommonDocumentsRingtoetsDirectory(), "NBPW");
+ }
+
+ public static string GetCommonDocumentsRingtoetsDirectory()
+ {
+ return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "WTI", "Ringtoets");
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -re12dd6e3a4e1190e0a4cbf404d5efcf1f00d574e -r37235d0863116292cc4b095dcf2d19cf6d14c6b2
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision e12dd6e3a4e1190e0a4cbf404d5efcf1f00d574e)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -23,7 +23,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
-using System.IO;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base.Data;
@@ -35,7 +34,6 @@
using Core.Common.Gui.Forms;
using Core.Common.Gui.Forms.ProgressDialog;
using Core.Common.Gui.Plugin;
-using Core.Common.Gui.Settings;
using Core.Common.IO.Exceptions;
using log4net;
using Ringtoets.Common.Data;
@@ -60,6 +58,7 @@
using Ringtoets.Integration.Data.StandAlone;
using Ringtoets.Integration.Data.StandAlone.SectionResults;
using Ringtoets.Integration.Forms;
+using Ringtoets.Integration.Forms.Commands;
using Ringtoets.Integration.Forms.PresentationObjects;
using Ringtoets.Integration.Forms.PropertyClasses;
using Ringtoets.Integration.Forms.Views;
@@ -332,7 +331,7 @@
try
{
var assessmentSectionHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow);
- var path = SettingsHelper.GetCommonDocumentsDirectory();
+ var path = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory();
assessmentSection = assessmentSectionHandler.CreateAssessmentSectionFromFile(path);
}
catch (CriticalFileValidationException exception)
Fisheye: Tag 37235d0863116292cc4b095dcf2d19cf6d14c6b2 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/AssessmentSectionFromFileCommandHandlerTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -0,0 +1,327 @@
+// 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.IO;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.DataGrid;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.IO.Exceptions;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Forms.Commands;
+
+namespace Ringtoets.Integration.Forms.Test.Commands
+{
+ [TestFixture]
+ public class AssessmentSectionFromFileCommandHandlerTest : NUnitFormTest
+ {
+ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "ReferenceLineMetaImporter");
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_InvalidDirectory_ThrowsCriticalFileReadException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+ AssessmentSectionFromFileCommandHandler assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+
+ string pathToNonExistingFolder = Path.Combine(testDataPath, "I do not exist");
+
+ // Call
+ TestDelegate call = () => assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathToNonExistingFolder);
+
+ // Assert
+ Assert.Throws(call);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_validDirectoryWithEmptyShapeFile_ThrowsCriticalFileValidationException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+ AssessmentSectionFromFileCommandHandler assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+
+ string pathValidFolder = Path.Combine(testDataPath, "EmptyShapeFile");
+
+ // Call
+ TestDelegate call = () => assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathValidFolder);
+
+ // Assert
+ CriticalFileValidationException exception = Assert.Throws(call);
+ Assert.AreEqual("Er kunnen geen trajecten gelezen worden uit het shape bestand.", exception.Message);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_ValidDirectoryUserClicksCancel_ReturnsNull()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+ string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
+ new ButtonTester("Cancel", selectionDialog).Click();
+ };
+
+ // Call
+ IAssessmentSection assessmentSection = assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathValidFolder);
+
+ // Assert
+ Assert.IsNull(assessmentSection);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_ValidDirectoryOkClicked_ReturnsFirstReadAssessmentSection()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+ string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");
+
+ int rowCount = 0;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
+ var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
+ rowCount = grid.GetRows().Count;
+ new ButtonTester("Ok", selectionDialog).Click();
+ };
+
+ // Call
+ var assessmentSection = (AssessmentSection) assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathValidFolder);
+
+ // Assert
+ Assert.AreEqual(3, rowCount);
+ Assert.IsNotNull(assessmentSection);
+ AssertAssessmentSection(TestAssessmentSection1_2(true), assessmentSection);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_ValidDirectoryLowLimitSelectedOkClicked_ReturnsFirstReadAssessmentSectionWithLowLimit()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+ string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
+ var combobox = (ComboBox) new ComboBoxTester("SignalingLowerLimitComboBox", selectionDialog).TheObject;
+ combobox.SelectedIndex = 1;
+ new ButtonTester("Ok", selectionDialog).Click();
+ };
+
+ // Call
+ var assessmentSection = (AssessmentSection) assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathValidFolder);
+
+ // Assert
+ Assert.IsNotNull(assessmentSection);
+ AssertAssessmentSection(TestAssessmentSection1_2(false), assessmentSection);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_SecondRowSelectedOkClicked_ReturnsSecondReadAssessmentSection()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+ string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");
+
+ int rowCount = 0;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
+ var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
+ rowCount = grid.GetRows().Count;
+ var dataGridView = grid.Controls.OfType().First();
+ dataGridView[0, 1].Selected = true;
+
+ new ButtonTester("Ok", selectionDialog).Click();
+ };
+
+ // Call
+ AssessmentSection assessmentSection = (AssessmentSection) assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathValidFolder);
+
+ // Assert
+ Assert.AreEqual(3, rowCount);
+ Assert.IsNotNull(assessmentSection);
+ AssertAssessmentSection(TestAssessmentSection2_1(), assessmentSection);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssessmentSectionFromFile_ThirdRowSelectedOkClicked_ReturnsThirdReadAssessmentSection()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var parentDialog = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var assessmentSectionFromFile = new AssessmentSectionFromFileCommandHandler(parentDialog);
+ string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
+ var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
+ var dataGridView = grid.Controls.OfType().First();
+ dataGridView[0, 2].Selected = true;
+
+ new ButtonTester("Ok", selectionDialog).Click();
+ };
+
+ AssessmentSection assessmentSection = null;
+
+ // Call
+ Action call = () => assessmentSection = (AssessmentSection) assessmentSectionFromFile.CreateAssessmentSectionFromFile(pathValidFolder);
+
+ // Assert
+ const string expectedMessage = @"Er zijn geen instellingen gevonden voor het geselecteerde traject. Standaardinstellingen zullen gebruikt worden.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage);
+ Assert.IsNotNull(assessmentSection);
+ AssertAssessmentSection(TestAssessmentSection3_3(), assessmentSection);
+ mockRepository.VerifyAll();
+ }
+
+ #region Test Assessment Sections
+
+ private static AssessmentSection TestAssessmentSection1_2(bool useSignalingValue)
+ {
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ Id = "1-2",
+ FailureMechanismContribution =
+ {
+ Norm = (useSignalingValue) ? 3000 : 1000
+ }
+ };
+ assessmentSection.GrassCoverErosionInwards.GeneralInput.N = 2;
+ assessmentSection.HeightStructures.GeneralInput.N = 2;
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(new[]
+ {
+ new Point2D(160679.9250, 475072.583),
+ new Point2D(160892.0751, 474315.4917)
+ });
+
+ return assessmentSection;
+ }
+
+ private static AssessmentSection TestAssessmentSection2_1()
+ {
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dune)
+ {
+ Id = "2-1",
+ FailureMechanismContribution =
+ {
+ Norm = 300
+ }
+ };
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(new[]
+ {
+ new Point2D(155556.9191, 464341.1281),
+ new Point2D(155521.4761, 464360.7401)
+ });
+
+ return assessmentSection;
+ }
+
+ private static AssessmentSection TestAssessmentSection3_3()
+ {
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ Id = "3-3",
+ FailureMechanismContribution =
+ {
+ Norm = 300
+ }
+ };
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(new[]
+ {
+ new Point2D(147367.32190, 476902.91571),
+ new Point2D(147410.0515, 476938.9447)
+ });
+
+ return assessmentSection;
+ }
+
+ #endregion
+
+ #region Asserts
+
+ private static void AssertAssessmentSection(AssessmentSection expected, AssessmentSection actual)
+ {
+ Assert.AreEqual(expected.Id, actual.Id);
+ Assert.AreEqual(expected.FailureMechanismContribution.Norm, actual.FailureMechanismContribution.Norm);
+ Assert.AreEqual(expected.Composition, actual.Composition);
+
+ Assert.AreEqual(expected.GrassCoverErosionInwards.GeneralInput.N, actual.GrassCoverErosionInwards.GeneralInput.N);
+ Assert.AreEqual(expected.HeightStructures.GeneralInput.N, actual.HeightStructures.GeneralInput.N);
+
+ AssertReferenceLine(expected.ReferenceLine, actual.ReferenceLine);
+ }
+
+ private static void AssertReferenceLine(ReferenceLine expected, ReferenceLine actual)
+ {
+ Assert.IsNotNull(expected);
+ Assert.IsNotNull(actual);
+ Point2D[] expectedPoints = expected.Points.ToArray();
+ Point2D[] actualPoints = actual.Points.ToArray();
+ CollectionAssert.AreEqual(expectedPoints, actualPoints,
+ new Point2DComparerWithTolerance(1e-6),
+ "Unexpected geometry found in ReferenceLine");
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r1e5d9b5cfc66cb8187d534d891afef1c9080378b -r37235d0863116292cc4b095dcf2d19cf6d14c6b2
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 1e5d9b5cfc66cb8187d534d891afef1c9080378b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -58,14 +58,15 @@
-
+
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/RingtoetsSettingsHelperTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/RingtoetsSettingsHelperTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/RingtoetsSettingsHelperTest.cs (revision 37235d0863116292cc4b095dcf2d19cf6d14c6b2)
@@ -0,0 +1,57 @@
+// 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.IO;
+using NUnit.Framework;
+
+namespace Ringtoets.Integration.Forms.Test
+{
+ [TestFixture]
+ public class RingtoetsSettingsHelperTest
+ {
+ [Test]
+ public void GetCommonDocumentsRingtoetsDirectory_ReturnsExpectedDirectory()
+ {
+ // Setup
+ var expectedPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "WTI", "Ringtoets");
+
+ // Call
+ var pathFromSettings = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsDirectory();
+
+ // Assert
+ Assert.AreEqual(expectedPath, pathFromSettings);
+ }
+
+ [Test]
+ public void GetCommonDocumentsRingtoetsShapeFileDirectory_ReturnsExpectedDirectory()
+ {
+ // Setup
+ var expectedPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), "WTI", "Ringtoets", "NBPW");
+
+ // Call
+ var pathFromSettings = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory();
+
+ // Assert
+ Assert.AreEqual(expectedPath, pathFromSettings);
+ }
+ }
+}
\ No newline at end of file