Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/LogNormalDistributionTest.cs =================================================================== diff -u -r1c01b600a1d6fb51fea1a5b888ceff0706c70b1d -r83b7345de9229da84eee587960c0961d49ec414d --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/LogNormalDistributionTest.cs (.../LogNormalDistributionTest.cs) (revision 1c01b600a1d6fb51fea1a5b888ceff0706c70b1d) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/LogNormalDistributionTest.cs (.../LogNormalDistributionTest.cs) (revision 83b7345de9229da84eee587960c0961d49ec414d) @@ -33,34 +33,6 @@ [TestFixture] public class LogNormalDistributionTest { - private static IEnumerable DistributionCombinations - { - get - { - LogNormalDistribution distribution = CreateFullyDefinedDistribution(); - - yield return new TestCaseData(distribution, distribution, true) - .SetName("SameDistribution"); - yield return new TestCaseData(distribution, CreateFullyDefinedDistribution(), true) - .SetName("EqualDistribution"); - - LogNormalDistribution otherMean = CreateFullyDefinedDistribution(); - otherMean.Mean = (RoundedDouble) 987; - yield return new TestCaseData(distribution, otherMean, false) - .SetName(nameof(otherMean)); - - LogNormalDistribution otherStandardDeviation = CreateFullyDefinedDistribution(); - otherStandardDeviation.StandardDeviation = (RoundedDouble) 0.987; - yield return new TestCaseData(distribution, otherStandardDeviation, false) - .SetName(nameof(otherStandardDeviation)); - - LogNormalDistribution otherShift = CreateFullyDefinedDistribution(); - otherShift.Shift = (RoundedDouble) 0.987; - yield return new TestCaseData(distribution, otherShift, false) - .SetName(nameof(otherShift)); - } - } - [Test] public void DefaultConstructor_ExpectedValues() { @@ -256,70 +228,39 @@ CoreCloneAssert.AreObjectClones(original, clone, DistributionAssert.AreEqual); } - [Test] - [TestCase(null)] - [TestCase("string")] - public void Equals_ToDifferentTypeOrNull_ReturnsFalse(object other) + [TestFixture] + private class LogNormalDistributionEqualsTest : EqualsGuidelinesTestFixture { - // Setup - LogNormalDistribution distribution = CreateFullyDefinedDistribution(); + protected override LogNormalDistribution CreateObject() + { + return CreateFullyDefinedDistribution(); + } - // Call - bool isEqual = distribution.Equals(other); + protected override DerivedLogNormalDistribution CreateDerivedObject() + { + LogNormalDistribution baseDistribution = CreateFullyDefinedDistribution(); + return new DerivedLogNormalDistribution(baseDistribution); + } - // Assert - Assert.IsFalse(isEqual); - } + private static IEnumerable GetUnequalTestCases() + { + LogNormalDistribution otherMean = CreateFullyDefinedDistribution(); + otherMean.Mean = (RoundedDouble) 987; + yield return new TestCaseData(otherMean) + .SetName(nameof(otherMean)); - [Test] - public void Equals_TransitivePropertyAllPropertiesEqual_ReturnsTrue() - { - // Setup - LogNormalDistribution distributionX = CreateFullyDefinedDistribution(); - LogNormalDistribution distributionY = CreateFullyDefinedDistribution(); - LogNormalDistribution distributionZ = CreateFullyDefinedDistribution(); + LogNormalDistribution otherStandardDeviation = CreateFullyDefinedDistribution(); + otherStandardDeviation.StandardDeviation = (RoundedDouble) 0.987; + yield return new TestCaseData(otherStandardDeviation) + .SetName(nameof(otherStandardDeviation)); - // Call - bool isXEqualToY = distributionX.Equals(distributionY); - bool isYEqualToZ = distributionY.Equals(distributionZ); - bool isXEqualToZ = distributionX.Equals(distributionZ); - - // Assert - Assert.IsTrue(isXEqualToY); - Assert.IsTrue(isYEqualToZ); - Assert.IsTrue(isXEqualToZ); + LogNormalDistribution otherShift = CreateFullyDefinedDistribution(); + otherShift.Shift = (RoundedDouble) 0.987; + yield return new TestCaseData(otherShift) + .SetName(nameof(otherShift)); + } } - [Test] - [TestCaseSource(nameof(DistributionCombinations))] - public void Equals_DifferentProperty_ReturnsIsEqual(LogNormalDistribution distribution, - LogNormalDistribution otherDistribution, - bool expectedToBeEqual) - { - // Call - bool isDistributionEqualToOther = distribution.Equals(otherDistribution); - bool isOtherEqualToDistribution = otherDistribution.Equals(distribution); - - // Assert - Assert.AreEqual(expectedToBeEqual, isDistributionEqualToOther); - Assert.AreEqual(expectedToBeEqual, isOtherEqualToDistribution); - } - - [Test] - public void GetHashCode_EqualDistributions_ReturnsSameHashCode() - { - // Setup - LogNormalDistribution distribution = CreateFullyDefinedDistribution(); - LogNormalDistribution otherDistribution = CreateFullyDefinedDistribution(); - - // Call - int hashCodeOne = distribution.GetHashCode(); - int hashCodeTwo = otherDistribution.GetHashCode(); - - // Assert - Assert.AreEqual(hashCodeOne, hashCodeTwo); - } - private static LogNormalDistribution CreateFullyDefinedDistribution() { return new LogNormalDistribution(5) @@ -329,5 +270,15 @@ Shift = (RoundedDouble) 0.2 }; } + + private class DerivedLogNormalDistribution : LogNormalDistribution + { + public DerivedLogNormalDistribution(LogNormalDistribution distribution) + { + Mean = distribution.Mean; + StandardDeviation = distribution.StandardDeviation; + Shift = distribution.Shift; + } + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/NormalDistributionTest.cs =================================================================== diff -u -rb286d241c3bfefe14166cc01382e806c98b54b5a -r83b7345de9229da84eee587960c0961d49ec414d --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/NormalDistributionTest.cs (.../NormalDistributionTest.cs) (revision b286d241c3bfefe14166cc01382e806c98b54b5a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/NormalDistributionTest.cs (.../NormalDistributionTest.cs) (revision 83b7345de9229da84eee587960c0961d49ec414d) @@ -33,29 +33,6 @@ [TestFixture] public class NormalDistributionTest { - private static IEnumerable DistributionCombinations - { - get - { - NormalDistribution distribution = CreateFullyDefinedDistribution(); - - yield return new TestCaseData(distribution, distribution, true) - .SetName("SameDistribution"); - yield return new TestCaseData(distribution, CreateFullyDefinedDistribution(), true) - .SetName("EqualDistribution"); - - NormalDistribution otherMean = CreateFullyDefinedDistribution(); - otherMean.Mean = (RoundedDouble) 987; - yield return new TestCaseData(distribution, otherMean, false) - .SetName(nameof(otherMean)); - - NormalDistribution otherStandardDeviation = CreateFullyDefinedDistribution(); - otherStandardDeviation.StandardDeviation = (RoundedDouble) 0.987; - yield return new TestCaseData(distribution, otherStandardDeviation, false) - .SetName(nameof(otherStandardDeviation)); - } - } - [Test] public void DefaultConstructor_ExpectedValues() { @@ -158,77 +135,50 @@ CoreCloneAssert.AreObjectClones(original, clone, DistributionAssert.AreEqual); } - [Test] - [TestCase(null)] - [TestCase("string")] - public void Equals_ToDifferentTypeOrNull_ReturnsFalse(object other) + private static NormalDistribution CreateFullyDefinedDistribution() { - // Setup - NormalDistribution distribution = CreateFullyDefinedDistribution(); - - // Call - bool isEqual = distribution.Equals(other); - - // Assert - Assert.IsFalse(isEqual); + return new NormalDistribution(5) + { + Mean = (RoundedDouble) 1, + StandardDeviation = (RoundedDouble) 0.1 + }; } - [Test] - public void Equals_TransitivePropertyAllPropertiesEqual_ReturnsTrue() + [TestFixture] + private class NormalDistributionEqualsTest : EqualsGuidelinesTestFixture { - // Setup - NormalDistribution distributionX = CreateFullyDefinedDistribution(); - NormalDistribution distributionY = CreateFullyDefinedDistribution(); - NormalDistribution distributionZ = CreateFullyDefinedDistribution(); + protected override NormalDistribution CreateObject() + { + return CreateFullyDefinedDistribution(); + } - // Call - bool isXEqualToY = distributionX.Equals(distributionY); - bool isYEqualToZ = distributionY.Equals(distributionZ); - bool isXEqualToZ = distributionX.Equals(distributionZ); + protected override DerivedNormalDistribution CreateDerivedObject() + { + NormalDistribution baseDistribution = CreateFullyDefinedDistribution(); + return new DerivedNormalDistribution(baseDistribution); + } - // Assert - Assert.IsTrue(isXEqualToY); - Assert.IsTrue(isYEqualToZ); - Assert.IsTrue(isXEqualToZ); - } + private static IEnumerable GetUnequalTestCases() + { + NormalDistribution otherMean = CreateFullyDefinedDistribution(); + otherMean.Mean = (RoundedDouble) 987; + yield return new TestCaseData(otherMean) + .SetName(nameof(otherMean)); - [Test] - [TestCaseSource(nameof(DistributionCombinations))] - public void Equals_DifferentProperty_ReturnsIsEqual(NormalDistribution distribution, - NormalDistribution otherDistribution, - bool expectedToBeEqual) - { - // Call - bool isDistributionEqualToOther = distribution.Equals(otherDistribution); - bool isOtherEqualToDistribution = otherDistribution.Equals(distribution); - - // Assert - Assert.AreEqual(expectedToBeEqual, isDistributionEqualToOther); - Assert.AreEqual(expectedToBeEqual, isOtherEqualToDistribution); + NormalDistribution otherStandardDeviation = CreateFullyDefinedDistribution(); + otherStandardDeviation.StandardDeviation = (RoundedDouble) 0.987; + yield return new TestCaseData(otherStandardDeviation) + .SetName(nameof(otherStandardDeviation)); + } } - [Test] - public void GetHashCode_EqualDistributions_ReturnsSameHashCode() + private class DerivedNormalDistribution : NormalDistribution { - // Setup - NormalDistribution distribution = CreateFullyDefinedDistribution(); - NormalDistribution otherDistribution = CreateFullyDefinedDistribution(); - - // Call - int hashCodeOne = distribution.GetHashCode(); - int hashCodeTwo = otherDistribution.GetHashCode(); - - // Assert - Assert.AreEqual(hashCodeOne, hashCodeTwo); - } - - private static NormalDistribution CreateFullyDefinedDistribution() - { - return new NormalDistribution(5) + public DerivedNormalDistribution(NormalDistribution distribution) { - Mean = (RoundedDouble) 1, - StandardDeviation = (RoundedDouble) 0.1 - }; + Mean = distribution.Mean; + StandardDeviation = distribution.StandardDeviation; + } } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/VariationCoefficientLogNormalDistributionTest.cs =================================================================== diff -u -r3faf4e513cd3a662427ce5aed527bb994f740c18 -r83b7345de9229da84eee587960c0961d49ec414d --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/VariationCoefficientLogNormalDistributionTest.cs (.../VariationCoefficientLogNormalDistributionTest.cs) (revision 3faf4e513cd3a662427ce5aed527bb994f740c18) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/VariationCoefficientLogNormalDistributionTest.cs (.../VariationCoefficientLogNormalDistributionTest.cs) (revision 83b7345de9229da84eee587960c0961d49ec414d) @@ -33,34 +33,6 @@ [TestFixture] public class VariationCoefficientLogNormalDistributionTest { - private static IEnumerable DistributionCombinations - { - get - { - VariationCoefficientLogNormalDistribution distribution = CreateFullyDefinedDistribution(); - - yield return new TestCaseData(distribution, distribution, true) - .SetName("SameDistribution"); - yield return new TestCaseData(distribution, CreateFullyDefinedDistribution(), true) - .SetName("EqualDistribution"); - - VariationCoefficientLogNormalDistribution otherMean = CreateFullyDefinedDistribution(); - otherMean.Mean = (RoundedDouble) 987; - yield return new TestCaseData(distribution, otherMean, false) - .SetName(nameof(otherMean)); - - VariationCoefficientLogNormalDistribution otherCoefficientOfVariation = CreateFullyDefinedDistribution(); - otherCoefficientOfVariation.CoefficientOfVariation = (RoundedDouble) 0.987; - yield return new TestCaseData(distribution, otherCoefficientOfVariation, false) - .SetName(nameof(otherCoefficientOfVariation)); - - VariationCoefficientLogNormalDistribution otherShift = CreateFullyDefinedDistribution(); - otherShift.Shift = (RoundedDouble) 0.987; - yield return new TestCaseData(distribution, otherShift, false) - .SetName(nameof(otherShift)); - } - } - [Test] public void DefaultConstructor_ExpectedValues() { @@ -252,78 +224,59 @@ CoreCloneAssert.AreObjectClones(original, clone, DistributionAssert.AreEqual); } - [Test] - [TestCase(null)] - [TestCase("string")] - public void Equals_ToDifferentTypeOrNull_ReturnsFalse(object other) - { - // Setup - VariationCoefficientLogNormalDistribution distribution = CreateFullyDefinedDistribution(); - // Call - bool isEqual = distribution.Equals(other); - - // Assert - Assert.IsFalse(isEqual); - } - - [Test] - public void Equals_TransitivePropertyAllPropertiesEqual_ReturnsTrue() + private static VariationCoefficientLogNormalDistribution CreateFullyDefinedDistribution() { - // Setup - VariationCoefficientLogNormalDistribution distributionX = CreateFullyDefinedDistribution(); - VariationCoefficientLogNormalDistribution distributionY = CreateFullyDefinedDistribution(); - VariationCoefficientLogNormalDistribution distributionZ = CreateFullyDefinedDistribution(); - - // Call - bool isXEqualToY = distributionX.Equals(distributionY); - bool isYEqualToZ = distributionY.Equals(distributionZ); - bool isXEqualToZ = distributionX.Equals(distributionZ); - - // Assert - Assert.IsTrue(isXEqualToY); - Assert.IsTrue(isYEqualToZ); - Assert.IsTrue(isXEqualToZ); + return new VariationCoefficientLogNormalDistribution(5) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 0.1, + Shift = (RoundedDouble) 0.2 + }; } - [Test] - [TestCaseSource(nameof(DistributionCombinations))] - public void Equals_DifferentProperty_ReturnsIsEqual(VariationCoefficientLogNormalDistribution distribution, - VariationCoefficientLogNormalDistribution otherDistribution, - bool expectedToBeEqual) + [TestFixture] + private class NormalDistributionEqualsTest : EqualsGuidelinesTestFixture { - // Call - bool isDistributionEqualToOther = distribution.Equals(otherDistribution); - bool isOtherEqualToDistribution = otherDistribution.Equals(distribution); + protected override VariationCoefficientLogNormalDistribution CreateObject() + { + return CreateFullyDefinedDistribution(); + } - // Assert - Assert.AreEqual(expectedToBeEqual, isDistributionEqualToOther); - Assert.AreEqual(expectedToBeEqual, isOtherEqualToDistribution); - } + protected override DerivedVariationCoefficientLogNormalDistribution CreateDerivedObject() + { + VariationCoefficientLogNormalDistribution baseDistribution = CreateFullyDefinedDistribution(); + return new DerivedVariationCoefficientLogNormalDistribution(baseDistribution); + } - [Test] - public void GetHashCode_EqualDistributions_ReturnsSameHashCode() - { - // Setup - VariationCoefficientLogNormalDistribution distribution = CreateFullyDefinedDistribution(); - VariationCoefficientLogNormalDistribution otherDistribution = CreateFullyDefinedDistribution(); + private static IEnumerable GetUnequalTestCases() + { + VariationCoefficientLogNormalDistribution otherMean = CreateFullyDefinedDistribution(); + otherMean.Mean = (RoundedDouble) 987; + yield return new TestCaseData(otherMean) + .SetName(nameof(otherMean)); - // Call - int hashCodeOne = distribution.GetHashCode(); - int hashCodeTwo = otherDistribution.GetHashCode(); + VariationCoefficientLogNormalDistribution otherStandardDeviation = CreateFullyDefinedDistribution(); + otherStandardDeviation.CoefficientOfVariation = (RoundedDouble) 0.987; + yield return new TestCaseData(otherStandardDeviation) + .SetName(nameof(otherStandardDeviation)); - // Assert - Assert.AreEqual(hashCodeOne, hashCodeTwo); + VariationCoefficientLogNormalDistribution otherShift = CreateFullyDefinedDistribution(); + otherShift.Shift = (RoundedDouble) 0.987; + yield return new TestCaseData(otherShift) + .SetName(nameof(otherShift)); + } } - private static VariationCoefficientLogNormalDistribution CreateFullyDefinedDistribution() + private class DerivedVariationCoefficientLogNormalDistribution : VariationCoefficientLogNormalDistribution { - return new VariationCoefficientLogNormalDistribution(5) + public DerivedVariationCoefficientLogNormalDistribution(VariationCoefficientLogNormalDistribution distribution) { - Mean = (RoundedDouble) 1, - CoefficientOfVariation = (RoundedDouble) 0.1, - Shift = (RoundedDouble) 0.2 - }; + Mean = distribution.Mean; + CoefficientOfVariation = distribution.CoefficientOfVariation; + Shift = distribution.Shift; + } } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/VariationCoefficientNormalDistributionTest.cs =================================================================== diff -u -rb286d241c3bfefe14166cc01382e806c98b54b5a -r83b7345de9229da84eee587960c0961d49ec414d --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/VariationCoefficientNormalDistributionTest.cs (.../VariationCoefficientNormalDistributionTest.cs) (revision b286d241c3bfefe14166cc01382e806c98b54b5a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/VariationCoefficientNormalDistributionTest.cs (.../VariationCoefficientNormalDistributionTest.cs) (revision 83b7345de9229da84eee587960c0961d49ec414d) @@ -33,29 +33,6 @@ [TestFixture] public class VariationCoefficientNormalDistributionTest { - private static IEnumerable DistributionCombinations - { - get - { - VariationCoefficientNormalDistribution distribution = CreateFullyDefinedDistribution(); - - yield return new TestCaseData(distribution, distribution, true) - .SetName("SameDistribution"); - yield return new TestCaseData(distribution, CreateFullyDefinedDistribution(), true) - .SetName("EqualDistribution"); - - VariationCoefficientNormalDistribution otherMean = CreateFullyDefinedDistribution(); - otherMean.Mean = (RoundedDouble) 987; - yield return new TestCaseData(distribution, otherMean, false) - .SetName(nameof(otherMean)); - - VariationCoefficientNormalDistribution otherCoefficientOfVariation = CreateFullyDefinedDistribution(); - otherCoefficientOfVariation.CoefficientOfVariation = (RoundedDouble) 0.987; - yield return new TestCaseData(distribution, otherCoefficientOfVariation, false) - .SetName(nameof(otherCoefficientOfVariation)); - } - } - [Test] public void Constructor_ExpectedValues() { @@ -167,70 +144,44 @@ CoreCloneAssert.AreObjectClones(original, clone, DistributionAssert.AreEqual); } - [Test] - [TestCase(null)] - [TestCase("string")] - public void Equals_ToDifferentTypeOrNull_ReturnsFalse(object other) + [TestFixture] + private class NormalDistributionEqualsTest : EqualsGuidelinesTestFixture { - // Setup - VariationCoefficientNormalDistribution distribution = CreateFullyDefinedDistribution(); + protected override VariationCoefficientNormalDistribution CreateObject() + { + return CreateFullyDefinedDistribution(); + } - // Call - bool isEqual = distribution.Equals(other); + protected override DerivedVariationCoefficientNormalDistribution CreateDerivedObject() + { + VariationCoefficientNormalDistribution baseDistribution = CreateFullyDefinedDistribution(); + return new DerivedVariationCoefficientNormalDistribution(baseDistribution); + } - // Assert - Assert.IsFalse(isEqual); - } + private static IEnumerable GetUnequalTestCases() + { + VariationCoefficientNormalDistribution otherMean = CreateFullyDefinedDistribution(); + otherMean.Mean = (RoundedDouble) 987; + yield return new TestCaseData(otherMean) + .SetName(nameof(otherMean)); - [Test] - public void Equals_TransitivePropertyAllPropertiesEqual_ReturnsTrue() - { - // Setup - VariationCoefficientNormalDistribution distributionX = CreateFullyDefinedDistribution(); - VariationCoefficientNormalDistribution distributionY = CreateFullyDefinedDistribution(); - VariationCoefficientNormalDistribution distributionZ = CreateFullyDefinedDistribution(); - - // Call - bool isXEqualToY = distributionX.Equals(distributionY); - bool isYEqualToZ = distributionY.Equals(distributionZ); - bool isXEqualToZ = distributionX.Equals(distributionZ); - - // Assert - Assert.IsTrue(isXEqualToY); - Assert.IsTrue(isYEqualToZ); - Assert.IsTrue(isXEqualToZ); + VariationCoefficientNormalDistribution otherStandardDeviation = CreateFullyDefinedDistribution(); + otherStandardDeviation.CoefficientOfVariation = (RoundedDouble) 0.987; + yield return new TestCaseData(otherStandardDeviation) + .SetName(nameof(otherStandardDeviation)); + } } - [Test] - [TestCaseSource(nameof(DistributionCombinations))] - public void Equals_DifferentProperty_ReturnsIsEqual(VariationCoefficientNormalDistribution distribution, - VariationCoefficientNormalDistribution otherDistribution, - bool expectedToBeEqual) + private class DerivedVariationCoefficientNormalDistribution : VariationCoefficientNormalDistribution { - // Call - bool isDistributionEqualToOther = distribution.Equals(otherDistribution); - bool isOtherEqualToDistribution = otherDistribution.Equals(distribution); - - // Assert - Assert.AreEqual(expectedToBeEqual, isDistributionEqualToOther); - Assert.AreEqual(expectedToBeEqual, isOtherEqualToDistribution); + public DerivedVariationCoefficientNormalDistribution(VariationCoefficientNormalDistribution distribution) + { + Mean = distribution.Mean; + CoefficientOfVariation = distribution.CoefficientOfVariation; + } } - [Test] - public void GetHashCode_EqualDistributions_ReturnsSameHashCode() - { - // Setup - VariationCoefficientNormalDistribution distribution = CreateFullyDefinedDistribution(); - VariationCoefficientNormalDistribution otherDistribution = CreateFullyDefinedDistribution(); - - // Call - int hashCodeOne = distribution.GetHashCode(); - int hashCodeTwo = otherDistribution.GetHashCode(); - - // Assert - Assert.AreEqual(hashCodeOne, hashCodeTwo); - } - private static VariationCoefficientNormalDistribution CreateFullyDefinedDistribution() { return new VariationCoefficientNormalDistribution(5)