Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilDatabaseQueryBuilder.cs
===================================================================
diff -u -r64c21c2c91a3cef9df279e58efda8e45a9d598f7 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision 64c21c2c91a3cef9df279e58efda8e45a9d598f7)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilDatabaseQueryBuilder.cs (.../SoilDatabaseQueryBuilder.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -105,6 +105,26 @@
}
///
+ /// Returns the query to get the amount of SoilProfile1D and SoilProfile2D
+ /// that can be read from the database.
+ ///
+ /// The query to get the amount of SoilProfile1D and SoilProfile2D
+ /// that can be read from the database.
+ public static string GetPipingSoilProfileCountQuery()
+ {
+ return String.Format(
+ "SELECT " +
+ "(SELECT COUNT('1') " +
+ "FROM Mechanism AS m " +
+ "JOIN MechanismPointLocation AS mpl USING(ME_ID) " +
+ "JOIN SoilProfile2D AS p2 USING(SP2D_ID) " +
+ "WHERE m.{0} = @{0}) " +
+ " + " +
+ "(SELECT COUNT('1') " +
+ "FROM SoilProfile1D) AS {1};", MechanismDatabaseColumns.MechanismName, SoilProfileDatabaseColumns.ProfileCount);
+ }
+
+ ///
/// Returns the SQL query to execute to check if version of the DSoil-Model database is as expected.
///
/// The SQL query to execute.
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs
===================================================================
diff -u -rd82fa09fe9ae053ce7702ba89ef23ae029640d1b -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision d82fa09fe9ae053ce7702ba89ef23ae029640d1b)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -25,6 +25,7 @@
using Core.Common.IO.Exceptions;
using Core.Common.IO.Readers;
using Core.Common.Utils.Builders;
+using Ringtoets.Piping.IO.Builders;
using Ringtoets.Piping.IO.Exceptions;
using Ringtoets.Piping.IO.Properties;
using Ringtoets.Piping.Primitives;
@@ -222,17 +223,7 @@
/// A query could not be executed on the database schema.
private void PrepareReader()
{
- string countQuery = string.Format(string.Join(
- " ",
- "SELECT",
- "(SELECT COUNT(*)",
- "FROM Mechanism as m",
- "JOIN MechanismPointLocation as mpl ON mpl.ME_ID = m.ME_ID",
- "JOIN SoilProfile2D as p2 ON p2.SP2D_ID = mpl.SP2D_ID",
- "WHERE m.ME_Name = @{0})",
- " + ",
- "(SELECT COUNT(*)",
- "FROM SoilProfile1D) as {1};"), mechanismParameterName, SoilProfileDatabaseColumns.ProfileCount);
+ string countQuery = SoilDatabaseQueryBuilder.GetPipingSoilProfileCountQuery();
string materialPropertiesQuery = string.Format(
string.Join(" ",
@@ -355,7 +346,13 @@
DbType = DbType.String,
Value = pipingMechanismName,
ParameterName = mechanismParameterName
- });
+ }, new SQLiteParameter
+ {
+ DbType = DbType.String,
+ ParameterName = String.Format("@{0}", MechanismDatabaseColumns.MechanismName),
+ Value = pipingMechanismName
+ }
+ );
}
private void GetCount()
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs
===================================================================
diff -u -rfab2798bdc0feb4454b6384aefbe9db3f9a294fb -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs (.../SoilProfileDatabaseColumns.cs) (revision fab2798bdc0feb4454b6384aefbe9db3f9a294fb)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs (.../SoilProfileDatabaseColumns.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -27,7 +27,7 @@
internal static class SoilProfileDatabaseColumns
{
internal const string SoilProfileId = "SoilProfileId";
- internal const string ProfileCount = "ProfileCount";
+ internal const string ProfileCount = "nrOfRows";
internal const string Dimension = "Dimension";
internal const string IsAquifer = "IsAquifer";
internal const string ProfileName = "ProfileName";
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs
===================================================================
diff -u -r64c21c2c91a3cef9df279e58efda8e45a9d598f7 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 64c21c2c91a3cef9df279e58efda8e45a9d598f7)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -75,6 +75,7 @@
/// instance of the information.
///
/// The next from the database, or null if no more soil models can be read.
+ /// Thrown when the database returned incorrect values for required properties.
/// Thrown when the database returned incorrect values for required properties.
public StochasticSoilModel ReadStochasticSoilModel()
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs
===================================================================
diff -u -r2ee142712e588101a958207e041c3e9342e5a7fa -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 2ee142712e588101a958207e041c3e9342e5a7fa)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -178,14 +178,9 @@
log.WarnFormat(RingtoetsPluginResources.PipingSoilProfilesImporter_ValidateStochasticSoilModel_No_profiles_found_in_stochastic_soil_model_0, stochasticSoilModel.Name);
return false;
}
- if (stochasticSoilModel.Geometry.Count == 0)
- {
- log.WarnFormat("Er zijn geen coordinaten gevonden in het stochastich ondersgrondmodel '{0}', deze wordt overgeslagen.", stochasticSoilModel.Name);
- return false;
- }
if (!stochasticSoilModel.StochasticSoilProfiles.Where(s => s.SoilProfile != null).Sum(s => s.Probability).Equals(1.0))
{
- log.WarnFormat("De som van de kans van voorkomen in het stochastich ondersgrondmodel '{0}' is niet gelijk aan 1.", stochasticSoilModel.Name);
+ log.WarnFormat(RingtoetsPluginResources.PipingSoilProfilesImporter_ValidateStochasticSoilModel_Sum_of_probabilities_of_stochastic_soil_model_0_is_not_correct, stochasticSoilModel.Name);
}
return true;
}
@@ -242,23 +237,14 @@
}
try
{
- NotifyProgress("Inlezen van de ondergrondsmodellen uit de D-Soil Model database.", currentStep++, totalNumberOfSteps);
+ NotifyProgress(RingtoetsPluginResources.PipingSoilProfilesImporter_GetStochasticSoilModelReadResult_Reading_stochastic_soil_models_from_database, currentStep++, totalNumberOfSteps);
soilModels.Add(stochasticSoilModelReader.ReadStochasticSoilModel());
}
- catch (PipingSoilProfileReadException e)
+ catch (StochasticSoilProfileReadException e)
{
- var message = string.Format("{0} " +
- "Dit ondergrondsmodel wordt overgeslagen.",
- e.Message);
+ var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_GetStochasticSoilModelReadResult_Error_0_stochastic_soil_model_skipped, e.Message);
log.Error(message);
}
- catch (CriticalFileReadException e)
- {
- var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped,
- path, e.Message);
- log.Error(message);
- return new ReadResult(true);
- }
}
return new ReadResult(false)
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -re4c1ee9fe5170ccf7794006d572461d3f88e7740 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e4c1ee9fe5170ccf7794006d572461d3f88e7740)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -109,6 +109,26 @@
}
///
+ /// Looks up a localized string similar to {0} Dit stochastisch ondergrondmodel wordt overgeslagen..
+ ///
+ public static string PipingSoilProfilesImporter_GetStochasticSoilModelReadResult_Error_0_stochastic_soil_model_skipped {
+ get {
+ return ResourceManager.GetString("PipingSoilProfilesImporter_GetStochasticSoilModelReadResult_Error_0_stochastic_so" +
+ "il_model_skipped", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Inlezen van de stochastische ondergrondmodellen..
+ ///
+ public static string PipingSoilProfilesImporter_GetStochasticSoilModelReadResult_Reading_stochastic_soil_models_from_database {
+ get {
+ return ResourceManager.GetString("PipingSoilProfilesImporter_GetStochasticSoilModelReadResult_Reading_stochastic_so" +
+ "il_models_from_database", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Ondergrondschematiseringen importeren afgebroken. Geen data ingelezen..
///
public static string PipingSoilProfilesImporter_Import_Import_cancelled {
@@ -166,6 +186,16 @@
}
///
+ /// Looks up a localized string similar to De som van de kans van voorkomen in het stochastich ondergrondmodel '{0}' is niet gelijk aan 100%..
+ ///
+ public static string PipingSoilProfilesImporter_ValidateStochasticSoilModel_Sum_of_probabilities_of_stochastic_soil_model_0_is_not_correct {
+ get {
+ return ResourceManager.GetString("PipingSoilProfilesImporter_ValidateStochasticSoilModel_Sum_of_probabilities_of_st" +
+ "ochastic_soil_model_0_is_not_correct", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Karakteristieke punten gevonden zonder bijbehorende profielmeting voor locatie '{0}'..
///
public static string PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Characteristic_points_found_for_unknown_SurfaceLine_0_ {
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx
===================================================================
diff -u -re4c1ee9fe5170ccf7794006d572461d3f88e7740 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision e4c1ee9fe5170ccf7794006d572461d3f88e7740)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -224,4 +224,13 @@
Er zijn geen profielen gevonden in het stochastich ondersgrondmodel '{0}', deze wordt overgeslagen.
+
+ Inlezen van de stochastische ondergrondmodellen.
+
+
+ De som van de kans van voorkomen in het stochastich ondergrondmodel '{0}' is niet gelijk aan 100%.
+
+
+ {0} Dit stochastisch ondergrondmodel wordt overgeslagen.
+
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj
===================================================================
diff -u -re4c1ee9fe5170ccf7794006d572461d3f88e7740 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision e4c1ee9fe5170ccf7794006d572461d3f88e7740)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -72,7 +72,7 @@
-
+
Fisheye: Tag 0c4e4faf0839d9ad90af4ff556357fc27c1f333a refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingSoilProfileCollectionTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/StochasticSoilModelContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/StochasticSoilModelContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/StochasticSoilModelContextTreeNodeInfoTest.cs (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -0,0 +1,220 @@
+// 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.Drawing;
+using System.Linq;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Forms.PresentationObjects;
+using Ringtoets.Piping.Forms.Properties;
+using Ringtoets.Piping.Plugin;
+using Ringtoets.Piping.Primitives;
+
+namespace Ringtoets.Piping.Forms.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class StochasticSoilModelContextTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private PipingGuiPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new PipingGuiPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StochasticSoilModelContext));
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(StochasticSoilModelContext), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsTextFromResource()
+ {
+ // Setup
+ var failureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
+ mocks.ReplayAll();
+
+ // Call
+ var text = info.Text(stochasticSoilModelContextMock);
+
+ // Assert
+ Assert.AreEqual(Resources.PipingSoilProfilesCollection_DisplayName, text);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ var failureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
+ mocks.ReplayAll();
+
+ // Call
+ var image = info.Image(stochasticSoilModelContextMock);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(Resources.FolderIcon, image);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_CollectionWithoutSoilProfiles_ReturnsGrayText()
+ {
+ // Setup
+ var failureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
+ mocks.ReplayAll();
+
+ // Call
+ var foreColor = info.ForeColor(stochasticSoilModelContextMock);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ForeColor_CollectionWithSoilProfiles_ReturnsControlText()
+ {
+ // Setup
+ var failureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
+ failureMechanismMock.StochasticSoilModels.Add(new StochasticSoilModel(0, "Name", "Name"));
+ mocks.ReplayAll();
+
+ // Call
+ var foreColor = info.ForeColor(stochasticSoilModelContextMock);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ChildNodeObjects_Always_ReturnsChildsOnData()
+ {
+ // Setup
+ var pipingSoilProfile1 = new PipingSoilProfile("", 0, new List
+ {
+ new PipingSoilLayer(10)
+ }, 0);
+ var pipingSoilProfile2 = new PipingSoilProfile("", 0, new List
+ {
+ new PipingSoilLayer(10)
+ }, 0);
+ var stochasticSoilProfile1 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1)
+ {
+ SoilProfile = pipingSoilProfile1
+ };
+ var stochasticSoilProfile2 = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 1)
+ {
+ SoilProfile = pipingSoilProfile2
+ };
+
+ var stochasticSoilModel = new StochasticSoilModel(0, "Name", "Name");
+ stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile1);
+ stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile2);
+
+ var failureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var stochasticSoilModelContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
+ failureMechanismMock.StochasticSoilModels.Add(stochasticSoilModel);
+
+ mocks.ReplayAll();
+
+ // Call
+ var objects = info.ChildNodeObjects(stochasticSoilModelContextMock);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ pipingSoilProfile1,
+ pipingSoilProfile2
+ }, objects);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var gui = mocks.StrictMultiMock();
+ var treeViewControl = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ gui.Expect(g => g.Get(null, treeViewControl)).Return(menuBuilderMock);
+
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilDatabaseQueryBuilderTest.cs
===================================================================
diff -u -r64c21c2c91a3cef9df279e58efda8e45a9d598f7 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision 64c21c2c91a3cef9df279e58efda8e45a9d598f7)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilDatabaseQueryBuilderTest.cs (.../SoilDatabaseQueryBuilderTest.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -61,6 +61,27 @@
}
[Test]
+ public void GetPipingSoilProfileCountQuery_Always_ReturnsExpectedValues()
+ {
+ // Setup
+ const string expectedQuery = "SELECT " +
+ "(SELECT COUNT('1') " +
+ "FROM Mechanism AS m " +
+ "JOIN MechanismPointLocation AS mpl USING(ME_ID) " +
+ "JOIN SoilProfile2D AS p2 USING(SP2D_ID) " +
+ "WHERE m.ME_Name = @ME_Name) " +
+ " + " +
+ "(SELECT COUNT('1') " +
+ "FROM SoilProfile1D) AS nrOfRows;";
+
+ // Call
+ string query = SoilDatabaseQueryBuilder.GetPipingSoilProfileCountQuery();
+
+ // Assert
+ Assert.AreEqual(expectedQuery, query);
+ }
+
+ [Test]
public void GetStochasticSoilModelOfMechanismCountQuery_Always_ReturnsExpectedValues()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/incorrectProbability.soil
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/invalidStochasticSoilProfiles.soil
===================================================================
diff -u
Binary files differ
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs
===================================================================
diff -u -re4c1ee9fe5170ccf7794006d572461d3f88e7740 -r0c4e4faf0839d9ad90af4ff556357fc27c1f333a
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision e4c1ee9fe5170ccf7794006d572461d3f88e7740)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision 0c4e4faf0839d9ad90af4ff556357fc27c1f333a)
@@ -22,11 +22,13 @@
public class PipingSoilProfilesImporterTest
{
private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "PipingSoilProfilesReader");
+ private MockRepository mockRepository;
private int progress;
[SetUp]
public void SetUp()
{
+ mockRepository = new MockRepository();
progress = 0;
}
@@ -56,12 +58,11 @@
var file = "nonexisting.soil";
string validFilePath = Path.Combine(testDataPath, file);
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -90,7 +91,7 @@
CollectionAssert.IsEmpty(context.FailureMechanism.StochasticSoilModels);
Assert.AreEqual(1, progress);
- mocks.VerifyAll(); // 'observer' should not be notified
+ mockRepository.VerifyAll(); // 'observer' should not be notified
}
[Test]
@@ -100,12 +101,11 @@
var file = "/";
string invalidFilePath = Path.Combine(testDataPath, file);
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -134,7 +134,7 @@
CollectionAssert.IsEmpty(context.FailureMechanism.StochasticSoilModels);
Assert.AreEqual(1, progress);
- mocks.VerifyAll(); // 'observer' should not be notified
+ mockRepository.VerifyAll(); // 'observer' should not be notified
}
[Test]
@@ -144,11 +144,10 @@
var file = "file";
string invalidFilePath = Path.Combine(testDataPath, file);
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var expectedMessage = "Er is geen referentielijn beschikbaar. Geen data ingelezen.";
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
@@ -172,20 +171,20 @@
CollectionAssert.IsEmpty(context.FailureMechanism.StochasticSoilModels);
Assert.AreEqual(0, progress);
- mocks.VerifyAll(); // 'observer' should not be notified
+ mockRepository.VerifyAll(); // 'observer' should not be notified
}
[Test]
- public void Import_ImportingToValidTargetWithValidFile_ImportSoilProfilesToCollection()
+ public void Import_ImportingToValidTargetWithValidFile_ImportSoilModelToCollection()
{
// Setup
string validFilePath = Path.Combine(testDataPath, "complete.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
+
+ var observer = mockRepository.StrictMock();
var pipingFailureMechanism = new PipingFailureMechanism();
- var assessmentSection = mocks.Stub();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var importer = new PipingSoilProfilesImporter
{
@@ -202,20 +201,20 @@
Assert.IsTrue(importResult);
Assert.AreEqual(34, progress);
- mocks.VerifyAll();
+ mockRepository.VerifyAll();
}
[Test]
- public void Import_ImportingToValidTargetWithValidFileTwice_AddsSoilProfilesToCollectionLogWarning()
+ public void Import_ImportingToValidTargetWithValidFileTwice_AddsSoilModelToCollectionLogWarning()
{
// Setup
string validFilePath = Path.Combine(testDataPath, "complete.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
+
+ var observer = mockRepository.StrictMock();
var pipingFailureMechanism = new PipingFailureMechanism();
- var assessmentSection = mocks.Stub();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var importer = new PipingSoilProfilesImporter
{
@@ -241,7 +240,7 @@
Assert.IsTrue(importResult);
Assert.AreEqual(34*2, progress);
- mocks.VerifyAll();
+ mockRepository.VerifyAll();
}
[Test]
@@ -250,12 +249,11 @@
// Setup
string validFilePath = Path.Combine(testDataPath, "complete.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -282,23 +280,22 @@
CollectionAssert.IsEmpty(context.FailureMechanism.StochasticSoilModels);
Assert.AreEqual(1, progress);
- mocks.VerifyAll(); // 'observer' should not be notified
+ mockRepository.VerifyAll(); // 'observer' should not be notified
}
[Test]
- public void Import_ReuseOfCancelledImportToValidTargetWithValidFile_ImportSurfaceLinesToCollection()
+ public void Import_ReuseOfCancelledImportToValidTargetWithValidFile_ImportSoilModelToCollection()
{
// Setup
string validFilePath = Path.Combine(testDataPath, "complete.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
+ var observer = mockRepository.StrictMock();
observer.Expect(o => o.UpdateObserver());
- var assessmentSection = mocks.Stub();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -331,12 +328,11 @@
// Setup
string corruptPath = Path.Combine(testDataPath, "empty.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -361,7 +357,7 @@
"No items should be added to collection when import is aborted.");
Assert.AreEqual(1, progress);
- mocks.VerifyAll(); // Expect no calls on 'observer'
+ mockRepository.VerifyAll(); // Expect no calls on 'observer'
}
[Test]
@@ -370,12 +366,11 @@
// Setup
string corruptPath = Path.Combine(testDataPath, "invalidAtX2dProperty.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -408,7 +403,7 @@
Assert.AreEqual(0, context.FailureMechanism.StochasticSoilModels.Count);
Assert.AreEqual(6, progress);
- mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver
+ mockRepository.VerifyAll(); // Ensure there are no calls to UpdateObserver
}
[Test]
@@ -417,12 +412,11 @@
// Setup
string corruptPath = Path.Combine(testDataPath, "incorrectValue2dProperty.soil");
- var mocks = new MockRepository();
- var observer = mocks.StrictMock();
- var assessmentSection = mocks.Stub();
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = new ReferenceLine();
var failureMechanism = new PipingFailureMechanism();
- mocks.ReplayAll();
+ mockRepository.ReplayAll();
var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
context.Attach(observer);
@@ -438,9 +432,83 @@
Assert.IsTrue(importResult);
Assert.AreEqual(0, context.FailureMechanism.StochasticSoilModels.Count);
- mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver
+ mockRepository.VerifyAll(); // Ensure there are no calls to UpdateObserver
}
+ [Test]
+ public void Import_IncorrectProfiles_SkipModelAndLog()
+ {
+ // Setup
+ string validFilePath = Path.Combine(testDataPath, "invalidStochasticSoilProfiles.soil");
+
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ var failureMechanism = new PipingFailureMechanism();
+ mockRepository.ReplayAll();
+
+ var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
+ context.Attach(observer);
+
+ var importer = new PipingSoilProfilesImporter
+ {
+ ProgressChanged = IncrementProgress
+ };
+
+ var expectedLogMessage = String.Format("Fout bij het lezen van bestand '{0}': Het stochastisch ondergrondprofiel bevat geen geldige waarde." +
+ " Dit stochastisch ondergrondmodel wordt overgeslagen.", validFilePath);
+ var importResult = false;
+
+ // Call
+ Action call = () => importResult = importer.Import(context, validFilePath);
+
+ // Assert
+ TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1);
+ Assert.AreEqual(0, failureMechanism.StochasticSoilModels.Count);
+ Assert.IsTrue(importResult);
+
+ mockRepository.VerifyAll(); // Ensure there are no calls to UpdateObserver
+ }
+
+ [Test]
+ public void Import_IncorrectProbability_LogAndImportSoilModelToCollection()
+ {
+ // Setup
+ string validFilePath = Path.Combine(testDataPath, "incorrectProbability.soil");
+
+ var observer = mockRepository.StrictMock();
+ var assessmentSection = mockRepository.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ var failureMechanism = new PipingFailureMechanism();
+ mockRepository.ReplayAll();
+
+ var context = new StochasticSoilModelContext(failureMechanism, assessmentSection);
+ context.Attach(observer);
+
+ var importer = new PipingSoilProfilesImporter
+ {
+ ProgressChanged = IncrementProgress
+ };
+
+ var expectedLogMessages = new[]
+ {
+ "Het uitgelezen profiel 'Profile' niet wordt niet gebruikt in een van de stochastische ondergrondmodellen.",
+ "De som van de kans van voorkomen in het stochastich ondergrondmodel 'Name' is niet gelijk aan 100%."
+ };
+
+ var importResult = false;
+
+ // Call
+ Action call = () => importResult = importer.Import(context, validFilePath);
+
+ // Assert
+ TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, 2);
+ Assert.AreEqual(1, failureMechanism.StochasticSoilModels.Count);
+ Assert.IsTrue(importResult);
+
+ mockRepository.VerifyAll(); // Ensure there are no calls to UpdateObserver
+ }
+
private void IncrementProgress(string a, int b, int c)
{
progress++;