Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs =================================================================== diff -u -r286830ea09ca418fba6b5c26f2e52c71f6dd56bd -r29acdef1f06e3be94d7fd8a94731e391b5d97ae8 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision 286830ea09ca418fba6b5c26f2e52c71f6dd56bd) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision 29acdef1f06e3be94d7fd8a94731e391b5d97ae8) @@ -35,7 +35,7 @@ { private double probability; - private static readonly Range probabilityValidityRange = new Range(0,1); + private static readonly Range probabilityValidityRange = new Range(0, 1); /// /// Creates a new instance of . @@ -80,9 +80,11 @@ { if (!probabilityValidityRange.InRange(value)) { - throw new ArgumentOutOfRangeException(nameof(value), string.Format( - Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_, - probabilityValidityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture))); + throw new ArgumentOutOfRangeException( + nameof(value), + string.Format( + Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_, + probabilityValidityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture))); } probability = value; } @@ -130,10 +132,9 @@ protected bool Equals(StochasticSoilProfile other) { - return Probability.Equals(other.Probability) - && SoilProfileType == other.SoilProfileType - && SoilProfileId == other.SoilProfileId - && Equals(SoilProfile, other.SoilProfile); + return Probability.Equals(other.Probability) + && SoilProfileType == other.SoilProfileType + && Equals(SoilProfile, other.SoilProfile); } public override bool Equals(object obj) @@ -150,7 +151,6 @@ { int hashCode = Probability.GetHashCode(); hashCode = (hashCode * 397) ^ (int) SoilProfileType; - hashCode = (hashCode * 397) ^ SoilProfileId.GetHashCode(); hashCode = (hashCode * 397) ^ (SoilProfile?.GetHashCode() ?? 0); return hashCode; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs =================================================================== diff -u -r24145cb7feea063e2986e8f4b2270bb2a478b3fd -r29acdef1f06e3be94d7fd8a94731e391b5d97ae8 --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 24145cb7feea063e2986e8f4b2270bb2a478b3fd) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 29acdef1f06e3be94d7fd8a94731e391b5d97ae8) @@ -142,7 +142,6 @@ unchecked { int hashCode = layers?.GetHashCode() ?? 0; - hashCode = (hashCode * 397) ^ PipingSoilProfileId.GetHashCode(); hashCode = (hashCode * 397) ^ Bottom.GetHashCode(); hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (int) SoilProfileType; @@ -153,7 +152,6 @@ private bool Equals(PipingSoilProfile other) { return AreLayersEqual(other.layers) - && PipingSoilProfileId == other.PipingSoilProfileId && Bottom.Equals(other.Bottom) && string.Equals(Name, other.Name) && SoilProfileType == other.SoilProfileType; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs =================================================================== diff -u -r76a7de2e77e45645d0e7e485e03333baf9cc3b0d -r29acdef1f06e3be94d7fd8a94731e391b5d97ae8 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 76a7de2e77e45645d0e7e485e03333baf9cc3b0d) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 29acdef1f06e3be94d7fd8a94731e391b5d97ae8) @@ -34,6 +34,8 @@ [TestFixture] public class PipingSoilProfileTest { + private static readonly Random profileIdRandom = new Random(32); + [Test] [TestCase(SoilProfileType.SoilProfile1D)] [TestCase(SoilProfileType.SoilProfile2D)] @@ -255,7 +257,10 @@ CreateRandomLayer(random), CreateRandomLayer(random) }, random.NextEnumValue(), random.Next()); - + + var profileJ = new PipingSoilProfile("A", -3, new [] { new PipingSoilLayer(-2) }, SoilProfileType.SoilProfile1D, 35); + var profileK = new PipingSoilProfile("A", -3, new [] { new PipingSoilLayer(-2) }, SoilProfileType.SoilProfile1D, 56); + return new[] { new TestCaseData(profileA, profileB, true) { TestName = "Equals_ProfileAProfileB_True"}, @@ -264,12 +269,13 @@ 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(profileJ, profileK, true) { TestName = "Equals_DifferentIds_True"}, }; } private static PipingSoilProfile CreateSingleLayerProfile(string name, double bottom, SoilProfileType type) { - return new PipingSoilProfile(name, bottom, new [] { new PipingSoilLayer(bottom + 1.0) }, type, -200); + return new PipingSoilProfile(name, bottom, new [] { new PipingSoilLayer(bottom + 1.0) }, type, profileIdRandom.Next()); } private static PipingSoilProfile CreateRandomProfile(int randomSeed) @@ -280,7 +286,7 @@ { layers.Add(CreateRandomLayer(random)); } - return new PipingSoilProfile(GetRandomName(random), -1.0 - random.NextDouble(), layers, random.NextEnumValue(), random.Next()); + return new PipingSoilProfile(GetRandomName(random), -1.0 - random.NextDouble(), layers, random.NextEnumValue(), profileIdRandom.Next()); } private static PipingSoilLayer CreateRandomLayer(Random random) Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs =================================================================== diff -u -r2711ea7d788b8f6193cf6c090317a6d24d891d4b -r29acdef1f06e3be94d7fd8a94731e391b5d97ae8 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 2711ea7d788b8f6193cf6c090317a6d24d891d4b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 29acdef1f06e3be94d7fd8a94731e391b5d97ae8) @@ -31,6 +31,8 @@ [TestFixture] public class StochasticSoilProfileTest { + private static readonly Random profileIdRandom = new Random(32); + [Test] [TestCase(0.1, SoilProfileType.SoilProfile1D, 123L)] [TestCase(0.26, SoilProfileType.SoilProfile2D, 123L)] @@ -237,6 +239,8 @@ StochasticSoilProfile profileA = CreateRandomStochasticProfile(21); StochasticSoilProfile profileB = CreateRandomStochasticProfile(21); StochasticSoilProfile profileC = CreateRandomStochasticProfile(73); + StochasticSoilProfile profileE = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 25); + StochasticSoilProfile profileF = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 45); return new[] { @@ -247,14 +251,18 @@ new TestCaseData(profileB, profileC, false) { TestName = "Equals_ProfileBProfileC_False" + }, + new TestCaseData(profileE, profileF, true) + { + TestName = "Equals_DifferentIds_True" } }; } private static StochasticSoilProfile CreateRandomStochasticProfile(int randomSeed) { var random = new Random(randomSeed); - return new StochasticSoilProfile(random.NextDouble(), SoilProfileType.SoilProfile1D, random.Next()) + return new StochasticSoilProfile(random.NextDouble(), SoilProfileType.SoilProfile1D, profileIdRandom.Next()) { SoilProfile = CreateRandomProfile(random) };