Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs
===================================================================
diff -u -rf4efcc2bb58d597f4a19884d98d0ab79bab04b1c -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f4efcc2bb58d597f4a19884d98d0ab79bab04b1c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -199,14 +199,5 @@
"nt_at_0_to_assign_as_characteristic_point_1_", resourceCulture);
}
}
-
- ///
- /// Looks up a localized string similar to Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel moet in het bereik [0,1] liggen..
- ///
- public static string StochasticSoilProfile_Probability_Should_be_in_range_0_1 {
- get {
- return ResourceManager.GetString("StochasticSoilProfile_Probability_Should_be_in_range_0_1", resourceCulture);
- }
- }
}
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx
===================================================================
diff -u -rf4efcc2bb58d597f4a19884d98d0ab79bab04b1c -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx (.../Resources.resx) (revision f4efcc2bb58d597f4a19884d98d0ab79bab04b1c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx (.../Resources.resx) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -156,7 +156,4 @@
De waarde moet binnen het bereik [0, 20] liggen.
-
- Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel moet in het bereik [0,1] liggen.
-
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs
===================================================================
diff -u -rc1e57c344103b0219edc5bb853da2a0ca5c41877 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs (.../StochasticSoilModel.cs) (revision c1e57c344103b0219edc5bb853da2a0ca5c41877)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs (.../StochasticSoilModel.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -92,6 +92,7 @@
throw new ArgumentNullException(nameof(fromModel));
}
+ Id = fromModel.Id;
Name = fromModel.Name;
SegmentName = fromModel.SegmentName;
Geometry.Clear();
@@ -110,13 +111,10 @@
StochasticSoilProfile sameProfile = StochasticSoilProfiles.SingleOrDefault(sp => sp.SoilProfile.Name.Equals(fromProfile.SoilProfile.Name));
if (sameProfile != null)
{
- var soilProfileChanged = !sameProfile.SoilProfile.Equals(fromProfile.SoilProfile);
- sameProfile.Update(fromProfile);
-
- if (soilProfileChanged)
+ if (sameProfile.Update(fromProfile))
{
updatedProfiles.Add(sameProfile);
- }
+ }
}
else
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs
===================================================================
diff -u -rf4efcc2bb58d597f4a19884d98d0ab79bab04b1c -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision f4efcc2bb58d597f4a19884d98d0ab79bab04b1c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -20,7 +20,6 @@
// All rights reserved.
using System;
-using Ringtoets.Piping.Data.Properties;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Data
@@ -30,8 +29,6 @@
///
public class StochasticSoilProfile
{
- private double probability;
-
///
/// Creates a new instance of .
///
@@ -48,12 +45,12 @@
///
/// Gets the type of the stochastic soil profile.
///
- public SoilProfileType SoilProfileType { get; private set; }
+ public SoilProfileType SoilProfileType { get; }
///
/// Gets the database identifier of the stochastic soil profile.
///
- public long SoilProfileId { get; private set; }
+ public long SoilProfileId { get; }
///
/// Gets the .
@@ -63,23 +60,7 @@
///
/// Gets the probability of the stochastic soil profile.
///
- /// Thrown when the is outside the range
- /// [0, 1].
- public double Probability
- {
- get
- {
- return probability;
- }
- private set
- {
- if (!double.IsNaN(value) && (value < 0 || value > 1))
- {
- throw new ArgumentOutOfRangeException(nameof(value), Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_1);
- }
- probability = value;
- }
- }
+ public double Probability { get; private set; }
///
/// Updates the probability of the
@@ -100,19 +81,53 @@
/// obtain the property values from.
/// Thrown when
/// is null.
- public void Update(StochasticSoilProfile fromProfile)
+ /// true if the profile has been updated; false otherwise.
+ public bool Update(StochasticSoilProfile fromProfile)
{
if (fromProfile == null)
{
throw new ArgumentNullException(nameof(fromProfile));
}
- SoilProfile = fromProfile.SoilProfile;
- Probability = fromProfile.Probability;
+ if (!Equals(fromProfile))
+ {
+ SoilProfile = fromProfile.SoilProfile;
+ Probability = fromProfile.Probability;
+ return true;
+ }
+ return false;
}
public override string ToString()
{
- return SoilProfile == null ? string.Empty : SoilProfile.ToString();
+ return SoilProfile?.ToString() ?? string.Empty;
}
+
+ protected bool Equals(StochasticSoilProfile other)
+ {
+ return Probability.Equals(other.Probability)
+ && SoilProfileType == other.SoilProfileType
+ && SoilProfileId == other.SoilProfileId
+ && Equals(SoilProfile, other.SoilProfile);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((StochasticSoilProfile) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = Probability.GetHashCode();
+ hashCode = (hashCode * 397) ^ (int) SoilProfileType;
+ hashCode = (hashCode * 397) ^ SoilProfileId.GetHashCode();
+ hashCode = (hashCode * 397) ^ (SoilProfile?.GetHashCode() ?? 0);
+ return hashCode;
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs
===================================================================
diff -u -r4e4ced94d27f939fc77f364201840814dc542af1 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision 4e4ced94d27f939fc77f364201840814dc542af1)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -98,7 +98,7 @@
{
if (exception is FormatException || exception is OverflowException || exception is InvalidCastException)
{
- var message = new FileReaderErrorMessageBuilder(Path)
+ string message = new FileReaderErrorMessageBuilder(Path)
.Build(Resources.StochasticSoilProfileDatabaseReader_StochasticSoilProfile_has_invalid_value);
throw new StochasticSoilProfileReadException(message, exception);
}
@@ -108,10 +108,7 @@
public override void Dispose()
{
- if (dataReader != null)
- {
- dataReader.Dispose();
- }
+ dataReader?.Dispose();
base.Dispose();
}
@@ -137,15 +134,15 @@
private void CreateDataReader()
{
- var stochasticSoilProfileQuery = SoilDatabaseQueryBuilder.GetAllStochasticSoilProfileQuery();
+ string stochasticSoilProfileQuery = SoilDatabaseQueryBuilder.GetAllStochasticSoilProfileQuery();
try
{
dataReader = CreateDataReader(stochasticSoilProfileQuery);
}
catch (SQLiteException exception)
{
CloseConnection();
- var message = new FileReaderErrorMessageBuilder(Path)
+ string message = new FileReaderErrorMessageBuilder(Path)
.Build(Resources.StochasticSoilModelDatabaseReader_Failed_to_read_database);
throw new CriticalFileReadException(message, exception);
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs
===================================================================
diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs (.../StochasticSoilModelUpdateDataStrategy.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateDataStrategy.cs (.../StochasticSoilModelUpdateDataStrategy.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -26,6 +26,7 @@
using Core.Common.Utils;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Plugin.Properties;
+using Ringtoets.Piping.Primitives;
using Ringtoets.Piping.Service;
namespace Ringtoets.Piping.Plugin.FileImporter
@@ -59,17 +60,7 @@
/// Removes stochastic soil models that are in , but are not part
/// of .
///
- /// The current collection of .
- /// The imported stochastic soil models.
- /// The file path from which the
- /// were imported.
- /// Thrown when
- /// contains multiple with the same ,
- /// and also contains a with
- /// the same name.
- ///
- /// Thrown when any parameter is null.
- /// List of updated instances.
+ ///
public IEnumerable UpdateModelWithImportedData(ObservableCollectionWithSourcePath targetCollection,
IEnumerable readStochasticSoilModels,
string sourceFilePath)
@@ -166,6 +157,10 @@
private IEnumerable UpdateStochasticSoilModel(StochasticSoilModel existingModel, StochasticSoilModel readModel)
{
+ Dictionary oldProfiles = existingModel
+ .StochasticSoilProfiles
+ .ToDictionary(ssp => ssp, ssp => ssp.SoilProfile, new ReferenceEqualityComparer());
+
StochasticSoilModelProfileDifference difference = existingModel.Update(readModel);
var affectedObjects = new List();
@@ -175,7 +170,10 @@
}
foreach (StochasticSoilProfile updatedProfile in difference.UpdatedProfiles)
{
- affectedObjects.AddRange(PipingDataSynchronizationService.ClearStochasticSoilProfileDependentData(failureMechanism, updatedProfile));
+ if (!oldProfiles[updatedProfile].Equals(updatedProfile.SoilProfile))
+ {
+ affectedObjects.AddRange(PipingDataSynchronizationService.ClearStochasticSoilProfileDependentData(failureMechanism, updatedProfile));
+ }
}
return affectedObjects;
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateException.cs
===================================================================
diff -u -rf4efcc2bb58d597f4a19884d98d0ab79bab04b1c -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateException.cs (.../StochasticSoilModelUpdateException.cs) (revision f4efcc2bb58d597f4a19884d98d0ab79bab04b1c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelUpdateException.cs (.../StochasticSoilModelUpdateException.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -25,7 +25,7 @@
namespace Ringtoets.Piping.Plugin.FileImporter
{
///
- /// The exception that is thrown when applying the stochastic soil model update stratagy failed.
+ /// The exception that is thrown when applying the stochastic soil model update strategy failed.
///
[Serializable]
public class StochasticSoilModelUpdateException : Exception
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs
===================================================================
diff -u -r1b6b6e221ac583d9d24ec033972acf73ffe30c56 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 1b6b6e221ac583d9d24ec033972acf73ffe30c56)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using System.Drawing;
namespace Ringtoets.Piping.Primitives
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs
===================================================================
diff -u -r1b6b6e221ac583d9d24ec033972acf73ffe30c56 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 1b6b6e221ac583d9d24ec033972acf73ffe30c56)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using System.Collections.Generic;
using System.Linq;
using Ringtoets.Piping.Primitives.Properties;
@@ -10,7 +31,7 @@
///
public class PipingSoilProfile
{
- private IEnumerable layers;
+ private PipingSoilLayer[] layers;
///
/// Creates a new instance ofL , with the given , and .
@@ -36,17 +57,17 @@
///
/// Gets the database identifier of the .
///
- public long PipingSoilProfileId { get; private set; }
+ public long PipingSoilProfileId { get; }
///
/// Gets the bottom level of the .
///
- public double Bottom { get; private set; }
+ public double Bottom { get; }
///
/// Gets the name of .
///
- public string Name { get; private set; }
+ public string Name { get; }
///
/// Gets an ordered (by , descending) of
@@ -70,7 +91,7 @@
///
/// Gets the type of soil profile used as data source to build this instance.
///
- public SoilProfileType SoilProfileType { get; private set; }
+ public SoilProfileType SoilProfileType { get; }
///
/// Gets the thickness of the given layer in the .
@@ -96,7 +117,7 @@
public override string ToString()
{
- return Name;
+ return Name ?? string.Empty;
}
public override bool Equals(object obj)
@@ -131,31 +152,29 @@
private bool Equals(PipingSoilProfile other)
{
- return AreLayersEqual(layers, other.layers)
+ return AreLayersEqual(other.layers)
&& PipingSoilProfileId == other.PipingSoilProfileId
&& Bottom.Equals(other.Bottom)
&& string.Equals(Name, other.Name)
&& SoilProfileType == other.SoilProfileType;
}
- private bool AreLayersEqual(IEnumerable layers, IEnumerable otherLayers)
+ private bool AreLayersEqual(PipingSoilLayer[] otherLayers)
{
- using (IEnumerator layersEnumerator = layers.GetEnumerator())
- using (IEnumerator otherLayersEnumerator = otherLayers.GetEnumerator())
+ int layerCount = layers.Length;
+ if (layerCount != otherLayers.Length)
{
- bool enumeratorAdvanced;
- bool otherEnumeratorAdvanced;
+ return false;
+ }
- while ((enumeratorAdvanced = layersEnumerator.MoveNext())
- & (otherEnumeratorAdvanced = otherLayersEnumerator.MoveNext()))
+ for (int i = 0; i < layerCount; i++)
+ {
+ if (!layers[i].Equals(otherLayers[i]))
{
- if (!layersEnumerator.Current.Equals(otherLayersEnumerator.Current))
- {
- return false;
- }
+ return false;
}
- return !enumeratorAdvanced && !otherEnumeratorAdvanced;
}
+ return true;
}
///
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs
===================================================================
diff -u -r1b6b6e221ac583d9d24ec033972acf73ffe30c56 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs (.../PipingSoilLayerTest.cs) (revision 1b6b6e221ac583d9d24ec033972acf73ffe30c56)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs (.../PipingSoilLayerTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -90,14 +90,29 @@
}
[Test]
+ public void Equals_Null_ReturnsFalse()
+ {
+ // Setup
+ var layer = CreateRandomLayer(21);
+
+ // Call
+ var areEqual = layer.Equals(null);
+
+ // Assert
+ Assert.IsFalse(areEqual);
+ }
+
+ [Test]
[TestCaseSource(nameof(LayerCombinations))]
public void Equals_DifferentScenarios_ReturnsExpectedResult(PipingSoilLayer layer, PipingSoilLayer otherLayer, bool expectedEqual)
{
// Call
- var areEqual = layer.Equals(otherLayer);
+ var areEqualOne = layer.Equals(otherLayer);
+ var areEqualTwo = otherLayer.Equals(layer);
// Assert
- Assert.AreEqual(expectedEqual, areEqual);
+ Assert.AreEqual(expectedEqual, areEqualOne);
+ Assert.AreEqual(expectedEqual, areEqualTwo);
}
private static TestCaseData[] LayerCombinations()
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs
===================================================================
diff -u -r1b6b6e221ac583d9d24ec033972acf73ffe30c56 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 1b6b6e221ac583d9d24ec033972acf73ffe30c56)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -171,7 +171,19 @@
}
[Test]
- [TestCase(null)]
+ public void ToString_WithNullName_ReturnsStringEmpty()
+ {
+ // Setup
+ var profile = new PipingSoilProfile(null, 0.0, new[]
+ {
+ new PipingSoilLayer(0.0)
+ }, SoilProfileType.SoilProfile1D, 0);
+
+ // Call & Assert
+ Assert.IsEmpty(profile.ToString());
+ }
+
+ [Test]
[TestCase("")]
[TestCase("some name")]
public void ToString_WithName_ReturnsName(string name)
@@ -187,14 +199,30 @@
}
[Test]
+ public void Equals_Null_ReturnsFalse()
+ {
+ // Setup
+ var profile = new PipingSoilProfile("name", 0, new[] {
+ CreateRandomLayer(new Random(21))}, SoilProfileType.SoilProfile1D, -1);
+
+ // Call
+ var areEqual = profile.Equals(null);
+
+ // Assert
+ Assert.IsFalse(areEqual);
+ }
+
+ [Test]
[TestCaseSource(nameof(ProfileCombinations))]
public void Equals_DifferentScenarios_ReturnsExpectedResult(PipingSoilProfile profile, PipingSoilProfile otherProfile, bool expectedEqual)
{
// Call
- var areEqual = profile.Equals(otherProfile);
+ var areEqualOne = profile.Equals(otherProfile);
+ var areEqualTwo = otherProfile.Equals(profile);
// Assert
- Assert.AreEqual(expectedEqual, areEqual);
+ Assert.AreEqual(expectedEqual, areEqualOne);
+ Assert.AreEqual(expectedEqual, areEqualTwo);
}
private static TestCaseData[] ProfileCombinations()
@@ -222,19 +250,14 @@
CreateRandomLayer(random)
}, random.NextEnumValue(), random.Next());
-
-
return new[]
{
- new TestCaseData(profileA, profileA, true) { TestName = "Equals_ProfileAProfileA_True"},
new TestCaseData(profileA, profileB, true) { TestName = "Equals_ProfileAProfileB_True"},
new TestCaseData(profileB, profileC, false) { TestName = "Equals_ProfileBProfileC_False"},
- new TestCaseData(profileC, profileC, true) { TestName = "Equals_ProfileCProfileC_True"},
new TestCaseData(profileD, profileE, false) { TestName = "Equals_ProfileDProfileE_False"},
new TestCaseData(profileD, profileF, false) { TestName = "Equals_ProfileDProfileF_False"},
new TestCaseData(profileD, profileG, false) { TestName = "Equals_ProfileDProfileG_False"},
new TestCaseData(profileH, profileI, false) { TestName = "Equals_ProfileHProfileI_False"},
- new TestCaseData(profileI, profileH, false) { TestName = "Equals_ProfileHProfileI_False"},
};
}
@@ -251,7 +274,7 @@
{
layers.Add(CreateRandomLayer(random));
}
- return new PipingSoilProfile(GetRandomName(random), -random.NextDouble(), layers, random.NextEnumValue(), random.Next());
+ return new PipingSoilProfile(GetRandomName(random), -1.0 - random.NextDouble(), layers, random.NextEnumValue(), random.Next());
}
private static PipingSoilLayer CreateRandomLayer(Random random)
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs
===================================================================
diff -u -rc1e57c344103b0219edc5bb853da2a0ca5c41877 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision c1e57c344103b0219edc5bb853da2a0ca5c41877)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -1,25 +1,5 @@
-// 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;
+using System.Collections.Generic;
using Core.Common.Base;
using Core.Common.Base.Geometry;
using NUnit.Framework;
@@ -38,15 +18,15 @@
public void Constructor_Always_ExpectedValues(long segmentSoilModelId, string segmentSoilModelName, string segmentName)
{
// Call
- StochasticSoilModel stochasticSoilModelSegment = new StochasticSoilModel(segmentSoilModelId, segmentSoilModelName, segmentName);
+ var stochasticSoilModel = new StochasticSoilModel(segmentSoilModelId, segmentSoilModelName, segmentName);
// Assert
- Assert.IsInstanceOf(stochasticSoilModelSegment);
- Assert.AreEqual(segmentSoilModelId, stochasticSoilModelSegment.Id);
- Assert.AreEqual(segmentSoilModelName, stochasticSoilModelSegment.Name);
- Assert.AreEqual(segmentName, stochasticSoilModelSegment.SegmentName);
- CollectionAssert.IsEmpty(stochasticSoilModelSegment.Geometry);
- CollectionAssert.IsEmpty(stochasticSoilModelSegment.StochasticSoilProfiles);
+ Assert.IsInstanceOf(stochasticSoilModel);
+ Assert.AreEqual(segmentSoilModelId, stochasticSoilModel.Id);
+ Assert.AreEqual(segmentSoilModelName, stochasticSoilModel.Name);
+ Assert.AreEqual(segmentName, stochasticSoilModel.SegmentName);
+ CollectionAssert.IsEmpty(stochasticSoilModel.Geometry);
+ CollectionAssert.IsEmpty(stochasticSoilModel.StochasticSoilProfiles);
}
[Test]
@@ -56,18 +36,18 @@
const long expectedSegmentSoilModelId = 1234L;
const string expectedSegmentSoilModelName = "someSegmentSoilModelName";
const string expectedSegmentName = "someSegmentName";
- StochasticSoilModel stochasticSoilModelSegment = new StochasticSoilModel(expectedSegmentSoilModelId, expectedSegmentSoilModelName, expectedSegmentName);
+ var stochasticSoilModel = new StochasticSoilModel(expectedSegmentSoilModelId, expectedSegmentSoilModelName, expectedSegmentName);
var point2D = new Point2D(1.0, 2.0);
// Call
- stochasticSoilModelSegment.Geometry.Add(point2D);
+ stochasticSoilModel.Geometry.Add(point2D);
// Assert
- Assert.AreEqual(expectedSegmentSoilModelId, stochasticSoilModelSegment.Id);
- Assert.AreEqual(expectedSegmentSoilModelName, stochasticSoilModelSegment.Name);
- Assert.AreEqual(expectedSegmentName, stochasticSoilModelSegment.SegmentName);
- Assert.AreEqual(1, stochasticSoilModelSegment.Geometry.Count);
- Assert.AreEqual(point2D, stochasticSoilModelSegment.Geometry[0]);
+ Assert.AreEqual(expectedSegmentSoilModelId, stochasticSoilModel.Id);
+ Assert.AreEqual(expectedSegmentSoilModelName, stochasticSoilModel.Name);
+ Assert.AreEqual(expectedSegmentName, stochasticSoilModel.SegmentName);
+ Assert.AreEqual(1, stochasticSoilModel.Geometry.Count);
+ Assert.AreEqual(point2D, stochasticSoilModel.Geometry[0]);
}
[Test]
@@ -77,21 +57,21 @@
const long expectedSegmentSoilModelId = 1234L;
const string expectedSegmentSoilModelName = "someSegmentSoilModelName";
const string expectedSegmentName = "someSegmentName";
- StochasticSoilModel stochasticSoilModelSegment = new StochasticSoilModel(expectedSegmentSoilModelId, expectedSegmentSoilModelName, expectedSegmentName);
+ var stochasticSoilModel = new StochasticSoilModel(expectedSegmentSoilModelId, expectedSegmentSoilModelName, expectedSegmentName);
- MockRepository mockRepository = new MockRepository();
+ var mockRepository = new MockRepository();
var stochasticSoilProfileProbabilityMock = mockRepository.StrictMock(1.0, null, null);
mockRepository.ReplayAll();
// Call
- stochasticSoilModelSegment.StochasticSoilProfiles.Add(stochasticSoilProfileProbabilityMock);
+ stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfileProbabilityMock);
// Assert
- Assert.AreEqual(expectedSegmentSoilModelId, stochasticSoilModelSegment.Id);
- Assert.AreEqual(expectedSegmentSoilModelName, stochasticSoilModelSegment.Name);
- Assert.AreEqual(expectedSegmentName, stochasticSoilModelSegment.SegmentName);
- Assert.AreEqual(1, stochasticSoilModelSegment.StochasticSoilProfiles.Count);
- Assert.AreEqual(stochasticSoilProfileProbabilityMock, stochasticSoilModelSegment.StochasticSoilProfiles[0]);
+ Assert.AreEqual(expectedSegmentSoilModelId, stochasticSoilModel.Id);
+ Assert.AreEqual(expectedSegmentSoilModelName, stochasticSoilModel.Name);
+ Assert.AreEqual(expectedSegmentName, stochasticSoilModel.SegmentName);
+ Assert.AreEqual(1, stochasticSoilModel.StochasticSoilProfiles.Count);
+ Assert.AreEqual(stochasticSoilProfileProbabilityMock, stochasticSoilModel.StochasticSoilProfiles[0]);
mockRepository.VerifyAll();
}
@@ -110,13 +90,144 @@
}
[Test]
+ public void Update_ModelWithUpdatedProperties_PropertiesUpdated()
+ {
+ // Assert
+ var model = new StochasticSoilModel(1234, "name", "segment");
+ model.Geometry.AddRange(new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(4, 5)
+ });
+
+ const int expectedId = 1236;
+ const string expectedName = "otherName";
+ const string expectedSegmentName = "otherSegmentName";
+ var expectedGeometry = new[]
+ {
+ new Point2D(4, 2)
+ };
+
+ var otherModel = new StochasticSoilModel(expectedId, expectedName, expectedSegmentName);
+ otherModel.Geometry.AddRange(expectedGeometry);
+
+ // Call
+ StochasticSoilModelProfileDifference difference = model.Update(otherModel);
+
+ // Assert
+ Assert.AreEqual(expectedId, model.Id);
+ Assert.AreEqual(expectedName, model.Name);
+ Assert.AreEqual(expectedSegmentName, model.SegmentName);
+ CollectionAssert.AreEqual(expectedGeometry, model.Geometry);
+
+ CollectionAssert.IsEmpty(difference.AddedProfiles);
+ CollectionAssert.IsEmpty(difference.UpdatedProfiles);
+ CollectionAssert.IsEmpty(difference.RemovedProfiles);
+ }
+
+ [Test]
+ public void Update_ModelWithAddedProfile_ProfileAdded()
+ {
+ // Setup
+ StochasticSoilModel model = CreateEmptyModel();
+ StochasticSoilModel otherModel = CreateEmptyModel();
+ var expectedAddedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3)
+ {
+ SoilProfile = new TestPipingSoilProfile()
+ };
+ otherModel.StochasticSoilProfiles.Add(expectedAddedProfile);
+
+ // Call
+ StochasticSoilModelProfileDifference difference = model.Update(otherModel);
+
+ // Assert
+ Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count);
+ Assert.AreEqual(expectedAddedProfile, otherModel.StochasticSoilProfiles[0]);
+
+ CollectionAssert.AreEqual(new[]
+ {
+ expectedAddedProfile
+ }, difference.AddedProfiles);
+ CollectionAssert.IsEmpty(difference.UpdatedProfiles);
+ CollectionAssert.IsEmpty(difference.RemovedProfiles);
+ }
+
+ [Test]
+ public void Update_ModelWithUpdatedProfile_ProfileUpdated()
+ {
+ // Setup
+ var profileName = "A";
+ var expectedUpdatedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3)
+ {
+ SoilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5)
+ };
+ StochasticSoilModel model = CreateEmptyModel();
+ model.StochasticSoilProfiles.Add(expectedUpdatedProfile);
+ StochasticSoilModel otherModel = CreateEmptyModel();
+ otherModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3)
+ {
+ SoilProfile = new PipingSoilProfile(profileName, -1, CreateLayers(), SoilProfileType.SoilProfile1D, -5)
+ });
+
+ // Call
+ StochasticSoilModelProfileDifference difference = model.Update(otherModel);
+
+ // Assert
+ Assert.AreEqual(1, otherModel.StochasticSoilProfiles.Count);
+ Assert.AreEqual(expectedUpdatedProfile, otherModel.StochasticSoilProfiles[0]);
+
+ CollectionAssert.IsEmpty(difference.AddedProfiles);
+ CollectionAssert.AreEqual(new[]
+ {
+ expectedUpdatedProfile
+ }, difference.UpdatedProfiles);
+ CollectionAssert.IsEmpty(difference.RemovedProfiles);
+ }
+
+ [Test]
+ public void Update_ModelWithUpdatedStochasticSoilProfile_ProfileUpdated()
+ {
+ // Setup
+ var profileName = "A";
+ var soilProfile = new PipingSoilProfile(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5);
+ var expectedUpdatedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3)
+ {
+ SoilProfile = soilProfile
+ };
+ StochasticSoilModel model = CreateEmptyModel();
+ model.StochasticSoilProfiles.Add(expectedUpdatedProfile);
+
+ StochasticSoilModel otherModel = CreateEmptyModel();
+ otherModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 3)
+ {
+ SoilProfile = soilProfile
+ });
+
+ // Call
+ StochasticSoilModelProfileDifference difference = model.Update(otherModel);
+
+ // Assert
+ CollectionAssert.IsEmpty(difference.AddedProfiles);
+ CollectionAssert.AreEqual(new[]
+ {
+ expectedUpdatedProfile
+ }, difference.UpdatedProfiles);
+ CollectionAssert.IsEmpty(difference.RemovedProfiles);
+ }
+
+ [Test]
+ public void Update_ModelWithRemovedProfile_ProfileRemoved()
+ {
+ var modelName = "name";
+ StochasticSoilModel model = CreateEmptyModel();
+ }
+
+ [Test]
public void Update_WithOtherModel_PropertiesUpdated()
{
// Setup
var equalProfileName = "nameA";
- var model = new StochasticSoilModel(1234, "name", "segment");
- model.Geometry.Add(new Point2D(6, 2));
- model.Geometry.Add(new Point2D(4, 3));
+ StochasticSoilModel model = CreateEmptyModel();
var stochasticProfileA = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -11)
{
@@ -133,14 +244,17 @@
var otherSegmentName = "other segment";
var otherModel = new StochasticSoilModel(41, otherName, otherSegmentName);
- var otherPointA = new Point2D(2,0);
- var otherPointB = new Point2D(3,0);
+ var otherPointA = new Point2D(2, 0);
+ var otherPointB = new Point2D(3, 0);
otherModel.Geometry.Add(otherPointA);
otherModel.Geometry.Add(otherPointB);
var otherStochasticProfileA = new StochasticSoilProfile(0.7, SoilProfileType.SoilProfile1D, -1)
{
- SoilProfile = new TestPipingSoilProfile(equalProfileName)
+ SoilProfile = new PipingSoilProfile(equalProfileName, -1, new[]
+ {
+ new PipingSoilLayer(0)
+ }, SoilProfileType.SoilProfile1D, -1)
};
var otherStochasticProfileB = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, -2)
{
@@ -150,7 +264,7 @@
otherModel.StochasticSoilProfiles.Add(otherStochasticProfileB);
// Call
- model.Update(otherModel);
+ StochasticSoilModelProfileDifference difference = model.Update(otherModel);
// Assert
Assert.AreEqual(otherName, model.Name);
@@ -162,6 +276,19 @@
Assert.AreSame(otherStochasticProfileA.SoilProfile, model.StochasticSoilProfiles[0].SoilProfile);
Assert.AreNotSame(stochasticProfileB, model.StochasticSoilProfiles[1]);
Assert.AreSame(otherStochasticProfileB.SoilProfile, model.StochasticSoilProfiles[1].SoilProfile);
+
+ CollectionAssert.AreEqual(new[]
+ {
+ stochasticProfileA
+ }, difference.UpdatedProfiles);
+ CollectionAssert.AreEqual(new[]
+ {
+ stochasticProfileB
+ }, difference.RemovedProfiles);
+ CollectionAssert.AreEqual(new[]
+ {
+ otherStochasticProfileB
+ }, difference.AddedProfiles);
}
[Test]
@@ -176,5 +303,19 @@
// Call & Assert
Assert.AreEqual(name, stochasticSoilModel.ToString());
}
+
+ private IEnumerable CreateLayers()
+ {
+ return new[]
+ {
+ new PipingSoilLayer(2),
+ };
+ }
+
+ private StochasticSoilModel CreateEmptyModel()
+ {
+ var model = new StochasticSoilModel(1234, "name", "segment");
+ return model;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs
===================================================================
diff -u -rf4efcc2bb58d597f4a19884d98d0ab79bab04b1c -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision f4efcc2bb58d597f4a19884d98d0ab79bab04b1c)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -20,6 +20,8 @@
// All rights reserved.
using System;
+using System.Drawing;
+using System.Linq;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Piping.KernelWrapper.TestUtil;
@@ -36,7 +38,7 @@
public void Constructor_Always_ExpectedValues(double probability, SoilProfileType soilProfileType, long soilProfileId)
{
// Call
- StochasticSoilProfile stochasticSoilProfileProbability = new StochasticSoilProfile(probability, soilProfileType, soilProfileId);
+ var stochasticSoilProfileProbability = new StochasticSoilProfile(probability, soilProfileType, soilProfileId);
// Assert
Assert.IsInstanceOf(stochasticSoilProfileProbability);
@@ -46,56 +48,25 @@
}
[Test]
- [TestCase(12.5)]
- [TestCase(1 + 1e-6)]
- [TestCase(0 - 1e-6)]
- [TestCase(-66.3)]
- public void Constructor_WithInvalidProbabilities_ThrowsArgumentOutOfRangeException(double probability)
- {
- // Call
- TestDelegate test = () => new StochasticSoilProfile(probability, SoilProfileType.SoilProfile1D, -1);
-
- // Assert
- var expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel moet in het bereik [0,1] liggen.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
- }
-
- [Test]
[TestCase(0)]
[TestCase(0.23)]
[TestCase(0.41)]
[TestCase(double.NaN)]
+ [TestCase(double.MaxValue)]
+ [TestCase(double.MinValue)]
public void AddProbability_DifferentValues_ProbabilityIncreasedAsExpected(double probabilityToAdd)
{
// Setup
- var startProbability = new Random(21).NextDouble() * 0.5;
+ double startProbability = new Random(21).NextDouble() * 0.5;
var profile = new StochasticSoilProfile(startProbability, SoilProfileType.SoilProfile1D, -1);
-
+
// Call
profile.AddProbability(probabilityToAdd);
// Assert
Assert.AreEqual(startProbability + probabilityToAdd, profile.Probability);
}
- [TestCase(double.MaxValue)]
- [TestCase(double.MinValue)]
-
- public void AddProbability_DifferentValuesMakingProbabilityInvalid_ThrowsArgumentOutOfRangeException(double probabilityToAdd)
- {
- // Setup
- var startProbability = new Random(21).NextDouble() * 0.5;
- var profile = new StochasticSoilProfile(startProbability, SoilProfileType.SoilProfile1D, -1);
-
- // Call
- TestDelegate test = () =>profile.AddProbability(probabilityToAdd);
-
- // Assert
- var expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel moet in het bereik [0,1] liggen.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
- Assert.AreEqual(startProbability, profile.Probability);
- }
-
[Test]
public void Update_WithNullProfile_ThrowsArgumentNullException()
{
@@ -124,15 +95,82 @@
var stochasticProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0);
// Call
- stochasticProfile.Update(otherStochasticProfile);
+ bool updated = stochasticProfile.Update(otherStochasticProfile);
// Assert
+ Assert.IsTrue(updated);
Assert.AreEqual(newProbability, stochasticProfile.Probability);
Assert.AreSame(newProfile, stochasticProfile.SoilProfile);
}
[Test]
- [TestCase(null)]
+ public void Update_WithEqualProfile_ReturnsFalse()
+ {
+ // Setup
+ var probability = 1.0;
+ var profile = new TestPipingSoilProfile();
+ var otherStochasticProfile = new StochasticSoilProfile(probability, SoilProfileType.SoilProfile1D, 0)
+ {
+ SoilProfile = profile
+ };
+
+ var stochasticProfile = new StochasticSoilProfile(probability, SoilProfileType.SoilProfile1D, 0)
+ {
+ SoilProfile = profile
+ };
+
+ // Call
+ bool updated = stochasticProfile.Update(otherStochasticProfile);
+
+ // Assert
+ Assert.IsFalse(updated);
+ Assert.AreEqual(probability, stochasticProfile.Probability);
+ Assert.AreSame(profile, stochasticProfile.SoilProfile);
+ }
+
+ [Test]
+ public void Equals_Null_ReturnsFalse()
+ {
+ // Setup
+ var stochasticProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0);
+
+ // Call
+ bool areEqual = stochasticProfile.Equals(null);
+
+ // Assert
+ Assert.IsFalse(areEqual);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(StochasticProfileCombinations))]
+ public void Equals_DifferentScenarios_ReturnsExpectedResult(StochasticSoilProfile profile, StochasticSoilProfile otherProfile, bool expectedEqual)
+ {
+ // Call
+ bool areEqualOne = profile.Equals(otherProfile);
+ bool areEqualTwo = profile.Equals(otherProfile);
+
+ // Assert
+ Assert.AreEqual(expectedEqual, areEqualOne);
+ Assert.AreEqual(expectedEqual, areEqualTwo);
+ }
+
+ [Test]
+ public void ToString_WithNullName_ReturnsStringEmpty()
+ {
+ // Setup
+ var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0)
+ {
+ SoilProfile = new PipingSoilProfile(null, 0.0, new[]
+ {
+ new PipingSoilLayer(0.0)
+ }, SoilProfileType.SoilProfile1D, 0)
+ };
+
+ // Call & Assert
+ Assert.IsEmpty(stochasticSoilProfile.ToString());
+ }
+
+ [Test]
[TestCase("")]
[TestCase("some name")]
public void ToString_WithName_ReturnsName(string name)
@@ -149,5 +187,58 @@
// Call & Assert
Assert.AreEqual(name, stochasticSoilProfile.ToString());
}
+
+ private static TestCaseData[] StochasticProfileCombinations()
+ {
+ StochasticSoilProfile profileA = CreateRandomStochasticProfile(21);
+ StochasticSoilProfile profileB = CreateRandomStochasticProfile(21);
+ StochasticSoilProfile profileC = CreateRandomStochasticProfile(73);
+
+ return new[]
+ {
+ new TestCaseData(profileA, profileB, true)
+ {
+ TestName = "Equals_ProfileAProfileB_True"
+ },
+ new TestCaseData(profileB, profileC, false)
+ {
+ TestName = "Equals_ProfileBProfileC_False"
+ }
+ };
+ }
+
+ private static StochasticSoilProfile CreateRandomStochasticProfile(int randomSeed)
+ {
+ var random = new Random(randomSeed);
+ return new StochasticSoilProfile(random.NextDouble(), SoilProfileType.SoilProfile1D, random.Next())
+ {
+ SoilProfile = CreateRandomProfile(random)
+ };
+ }
+
+ private static PipingSoilProfile CreateRandomProfile(Random random)
+ {
+ return new PipingSoilProfile(GetRandomName(random), -1.0 - random.NextDouble(), new[]
+ {
+ new PipingSoilLayer(random.NextDouble())
+ {
+ MaterialName = GetRandomName(random),
+ Color = Color.FromKnownColor(random.NextEnumValue()),
+ IsAquifer = random.NextBoolean(),
+ BelowPhreaticLevelDeviation = random.NextDouble(),
+ BelowPhreaticLevelMean = random.NextDouble(),
+ BelowPhreaticLevelShift = random.NextDouble(),
+ DiameterD70Deviation = random.NextDouble(),
+ DiameterD70Mean = random.NextDouble(),
+ PermeabilityDeviation = random.NextDouble(),
+ PermeabilityMean = random.NextDouble()
+ }
+ }, SoilProfileType.SoilProfile1D, random.Next());
+ }
+
+ private static string GetRandomName(Random random)
+ {
+ return string.Join("", Enumerable.Repeat('x', random.Next(0, 40)));
+ }
}
}
\ No newline at end of file
Fisheye: Tag 24145cb7feea063e2986e8f4b2270bb2a478b3fd refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/LineParseExceptionTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterTest.cs
===================================================================
diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -209,7 +230,7 @@
TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, expectedLogMessages.Length);
Assert.AreEqual(35 * 2, progress);
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(3, readModels.Length);
}
@@ -342,7 +363,7 @@
// Assert
TestHelper.AssertLogMessageIsGenerated(call, "Huidige actie was niet meer te annuleren en is daarom voortgezet.", 1);
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(3, readModels.Length);
}
@@ -373,7 +394,7 @@
importResult = importer.Import();
// Assert
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(3, readModels.Length);
}
@@ -407,7 +428,7 @@
TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, 2);
Assert.AreEqual(7, progress);
- var readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
CollectionAssert.IsEmpty(readModels);
}
@@ -428,7 +449,7 @@
bool importResult = importer.Import();
// Assert
- var readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
CollectionAssert.IsEmpty(readModels);
}
@@ -456,7 +477,7 @@
" Dit stochastische ondergrondmodel wordt overgeslagen.";
TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1);
- var readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
CollectionAssert.IsEmpty(readModels);
}
@@ -482,7 +503,7 @@
var expectedLogMessages = "De som van de kansen van voorkomen in het stochastich ondergrondmodel 'Name' is niet gelijk aan 100%.";
TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessages, 1);
- var readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(pathToCorruptFile, importResult, updateStrategy);
Assert.AreEqual(1, readModels.Length);
}
@@ -502,7 +523,7 @@
bool importResult = importer.Import();
// Assert
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(2, readModels.Length);
StochasticSoilModel model1 = readModels[0];
@@ -538,7 +559,7 @@
bool importResult = importer.Import();
// Assert
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(2, readModels.Length);
StochasticSoilModel model1 = readModels[0];
@@ -580,7 +601,7 @@
"ondergrondmodel 'Model'. Dit model wordt overgeslagen.";
TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1);
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
CollectionAssert.IsEmpty(readModels);
}
@@ -607,7 +628,7 @@
"'StochasticSoilModelName'. Kansen van voorkomen worden opgeteld.";
TestHelper.AssertLogMessageIsGenerated(importAction, expectedMessage, 1);
- var readModels = AssertSuccessfulImport(pathToFile, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(pathToFile, importResult, updateStrategy);
Assert.AreEqual(1, readModels.Length);
StochasticSoilModel firstModel = readModels.First();
Assert.AreEqual(1, firstModel.StochasticSoilProfiles.Count);
@@ -634,7 +655,7 @@
// Assert
TestHelper.AssertLogMessagesCount(importAction, 0);
- var readModels = AssertSuccessfulImport(pathToFile, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(pathToFile, importResult, updateStrategy);
Assert.AreEqual(1, readModels.Length);
StochasticSoilModel firstModel = readModels.First();
Assert.AreEqual(2, firstModel.StochasticSoilProfiles.Count);
@@ -662,7 +683,7 @@
bool importResult = importer.Import();
// Assert
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(1, readModels.Length);
StochasticSoilModel soilModel = readModels[0];
@@ -719,7 +740,7 @@
bool importResult = importer.Import();
// Assert
- var readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
+ StochasticSoilModel[] readModels = AssertSuccessfulImport(validFilePath, importResult, updateStrategy);
Assert.AreEqual(1, readModels.Length);
StochasticSoilModel soilModel = readModels[0];
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs
===================================================================
diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base;
@@ -316,8 +337,7 @@
StochasticSoilModel readModel = new TestStochasticSoilModel(modelsName);
StochasticSoilProfile changedProfile = CloneAndSlightlyModify(readModel.StochasticSoilProfiles.ElementAt(0));
- readModel.StochasticSoilProfiles.RemoveAt(0);
- readModel.StochasticSoilProfiles.Add(changedProfile);
+ readModel.StochasticSoilProfiles[0] = changedProfile;
var calculationWithUpdatedProfile = new PipingCalculationScenario(new GeneralPipingInput());
calculationWithUpdatedProfile.InputParameters.StochasticSoilModel = existingModel;
@@ -350,13 +370,16 @@
Assert.IsFalse(calculationWithUpdatedProfile.HasOutput);
Assert.AreSame(existingModel.StochasticSoilProfiles[0], calculationWithUpdatedProfile.InputParameters.StochasticSoilProfile);
- CollectionAssert.Contains(affectedObjects, calculationWithUpdatedProfile);
- CollectionAssert.Contains(affectedObjects, calculationWithUpdatedProfile.InputParameters);
Assert.IsTrue(calculationWithNotUpdatedProfile.HasOutput);
Assert.AreSame(existingModel.StochasticSoilProfiles[1], calculationWithNotUpdatedProfile.InputParameters.StochasticSoilProfile);
- CollectionAssert.DoesNotContain(affectedObjects, calculationWithNotUpdatedProfile);
- CollectionAssert.DoesNotContain(affectedObjects, calculationWithNotUpdatedProfile.InputParameters);
+
+ CollectionAssert.AreEquivalent(new IObservable[]
+ {
+ firstSoilModel,
+ calculationWithUpdatedProfile,
+ calculationWithUpdatedProfile.InputParameters
+ }, affectedObjects);
}
[Test]
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateExceptionTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateExceptionTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelUpdateExceptionTest.cs (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -0,0 +1,32 @@
+// 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 Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Piping.Plugin.FileImporter;
+
+namespace Ringtoets.Piping.Plugin.Test.FileImporter
+{
+ [TestFixture]
+ public class StochasticSoilModelUpdateExceptionTest :
+ CustomExceptionDesignGuidelinesTestFixture {}
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs
===================================================================
diff -u -r1b6b6e221ac583d9d24ec033972acf73ffe30c56 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 1b6b6e221ac583d9d24ec033972acf73ffe30c56)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -1,4 +1,25 @@
-using System.Linq;
+// 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.Linq;
using System.Threading;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj
===================================================================
diff -u -rc1e57c344103b0219edc5bb853da2a0ca5c41877 -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision c1e57c344103b0219edc5bb853da2a0ca5c41877)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -72,7 +72,7 @@
Properties\GlobalAssembly.cs
-
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs
===================================================================
diff -u -r5ad23eae9f87bb12cbf453126070e8967e32d7ad -r24145cb7feea063e2986e8f4b2270bb2a478b3fd
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision 5ad23eae9f87bb12cbf453126070e8967e32d7ad)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd)
@@ -115,7 +115,7 @@
assessmentSection);
// Call
- var text = info.Text(stochasticSoilModelCollectionContext);
+ string text = info.Text(stochasticSoilModelCollectionContext);
// Assert
Assert.AreEqual(Resources.StochasticSoilModelCollection_DisplayName, text);
@@ -136,7 +136,7 @@
assessmentSection);
// Call
- var image = info.Image(stochasticSoilModelCollectionContext);
+ Image image = info.Image(stochasticSoilModelCollectionContext);
// Assert
TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, image);
@@ -157,7 +157,7 @@
assessmentSection);
// Call
- var foreColor = info.ForeColor(stochasticSoilModelCollectionContext);
+ Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext);
// Assert
Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), foreColor);
@@ -182,7 +182,7 @@
assessmentSection);
// Call
- var foreColor = info.ForeColor(stochasticSoilModelCollectionContext);
+ Color foreColor = info.ForeColor(stochasticSoilModelCollectionContext);
// Assert
Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor);
@@ -226,9 +226,8 @@
stochasticSoilModel
}, "path");
-
// Call
- var objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext);
+ object[] objects = info.ChildNodeObjects(stochasticSoilModelCollectionContext);
// Assert
CollectionAssert.AreEqual(new[]
@@ -291,8 +290,8 @@
}
var nodeData = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection,
- pipingFailureMechanism,
- assessmentSectionMock);
+ pipingFailureMechanism,
+ assessmentSectionMock);
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
@@ -308,9 +307,9 @@
using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl))
{
// Assert
- var expectedToolTip = sourcePathSet
- ? RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip
- : RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip_No_SourcePath_set;
+ string expectedToolTip = sourcePathSet
+ ? RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip
+ : RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip_No_SourcePath_set;
TestHelper.AssertContextMenuStripContainsItem(menu, updateStochasticSoilModelsItemIndex,
RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_Text,
@@ -335,8 +334,8 @@
stochasticSoilModelCollection.AddRange(Enumerable.Empty(), somePath);
var nodeData = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection,
- pipingFailureMechanism,
- assessmentSectionMock);
+ pipingFailureMechanism,
+ assessmentSectionMock);
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
@@ -364,7 +363,7 @@
// Assert
TestHelper.AssertLogMessageIsGenerated(
- test,
+ test,
$"Bijwerken van ondergrondschematisaties in '{somePath}' is door de gebruiker geannuleerd.");
}
}
@@ -386,8 +385,8 @@
stochasticSoilModelCollection.AddRange(Enumerable.Empty(), existingFilePath);
var nodeData = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection,
- pipingFailureMechanism,
- assessmentSectionMock);
+ pipingFailureMechanism,
+ assessmentSectionMock);
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();