Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/DistributionAssertTest.cs =================================================================== diff -u -r12d68f588f3d39996a3a34577f9ec94a87bec865 -rfba90aff5df30d1a8575d0730aba71ceac649865 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/DistributionAssertTest.cs (.../DistributionAssertTest.cs) (revision 12d68f588f3d39996a3a34577f9ec94a87bec865) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/DistributionAssertTest.cs (.../DistributionAssertTest.cs) (revision fba90aff5df30d1a8575d0730aba71ceac649865) @@ -19,8 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using Core.Common.Base.Data; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Probabilistics; @@ -125,6 +127,45 @@ Assert.Throws(call); } + [Test] + public void AreDistributionPropertiesEqual_IdenticalVariationCoefficientLogNormalDistributionProperties_DoesNotThrowException() + { + // Setup + var random = new Random(21); + const int nrOfDecimals = 4; + var mean = random.NextRoundedDouble(); + var coefficientOfVariation = random.NextRoundedDouble(); + var shift = random.NextRoundedDouble(); + + // Call + TestDelegate call = () => DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(nrOfDecimals) + { + Mean = mean, + CoefficientOfVariation = coefficientOfVariation, + Shift = shift + }, new VariationCoefficientLogNormalDistribution(nrOfDecimals) + { + Mean = mean, + CoefficientOfVariation = coefficientOfVariation, + Shift = shift + }); + + // Assert + Assert.DoesNotThrow(call); + } + + [Test] + [TestCaseSource(nameof(DifferentVariationCoefficientLogNormalDistributions))] + public void AreDistributionPropertiesEqual_DifferentVariationCoefficientLogNormalDistributionProperties_ThrowsAssertionException(VariationCoefficientLogNormalDistribution distributionOne, + VariationCoefficientLogNormalDistribution distributionTwo) + { + // Call + TestDelegate call = () => DistributionAssert.AreEqual(distributionOne, distributionTwo); + + // Assert + Assert.Throws(call); + } + #region Test data private static IEnumerable IdenticalDistributionProperties @@ -473,49 +514,50 @@ CoefficientOfVariation = (RoundedDouble) 2 }).SetName("DifferentRoundingVariationCoefficientNormalDistribution"); yield return new TestCaseData( - new VariationCoefficientLogNormalDistribution(2) + new VariationCoefficientNormalDistribution(2) { Mean = (RoundedDouble) 1, CoefficientOfVariation = (RoundedDouble) 2 }, - new VariationCoefficientLogNormalDistribution(3) + new VariationCoefficientNormalDistribution(2) { - Mean = (RoundedDouble) 1, + Mean = (RoundedDouble) 2, CoefficientOfVariation = (RoundedDouble) 2 - }).SetName("DifferentRoundingVariationCoefficientLogNormalDistribution"); + }).SetName("DifferentMeanVariationCoefficientNormalDistribution"); yield return new TestCaseData( new VariationCoefficientNormalDistribution(2) { Mean = (RoundedDouble) 1, - CoefficientOfVariation = (RoundedDouble) 2 + CoefficientOfVariation = (RoundedDouble) 1 }, new VariationCoefficientNormalDistribution(2) { - Mean = (RoundedDouble) 2, + Mean = (RoundedDouble) 1, CoefficientOfVariation = (RoundedDouble) 2 - }).SetName("DifferentMeanVariationCoefficientNormalDistribution"); + }).SetName("DifferentVariationVariationCoefficientNormalDistribution"); yield return new TestCaseData( new VariationCoefficientLogNormalDistribution(2) { Mean = (RoundedDouble) 1, CoefficientOfVariation = (RoundedDouble) 2 }, - new VariationCoefficientLogNormalDistribution(2) + new VariationCoefficientLogNormalDistribution(3) { - Mean = (RoundedDouble) 2, + Mean = (RoundedDouble) 1, CoefficientOfVariation = (RoundedDouble) 2 - }).SetName("DifferentMeanVariationCoefficientLogNormalDistribution"); + }).SetName("DifferentRoundingVariationCoefficientLogNormalDistribution"); yield return new TestCaseData( - new VariationCoefficientNormalDistribution(2) + new VariationCoefficientLogNormalDistribution(2) { Mean = (RoundedDouble) 1, - CoefficientOfVariation = (RoundedDouble) 1 + CoefficientOfVariation = (RoundedDouble) 2 }, - new VariationCoefficientNormalDistribution(2) + new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble) 1, + Mean = (RoundedDouble) 2, CoefficientOfVariation = (RoundedDouble) 2 - }).SetName("DifferentStandardDeviationVariationCoefficientNormalDistribution"); + }).SetName("DifferentMeanVariationCoefficientLogNormalDistribution"); + yield return new TestCaseData( new VariationCoefficientLogNormalDistribution(2) { @@ -526,10 +568,61 @@ { Mean = (RoundedDouble) 1, CoefficientOfVariation = (RoundedDouble) 2 - }).SetName("DifferentStandardDeviationVariationCoefficientLogNormalDistribution"); + }).SetName("DifferentVariationVariationCoefficientLogNormalDistribution"); } } + private static IEnumerable DifferentVariationCoefficientLogNormalDistributions() + { + yield return new TestCaseData( + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 2 + }, + new VariationCoefficientLogNormalDistribution(3) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 2 + }).SetName("DifferentRoundingVariationCoefficientLogNormalDistribution"); + yield return new TestCaseData( + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 2 + }, + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 2 + }).SetName("DifferentMeanVariationCoefficientLogNormalDistribution"); + + yield return new TestCaseData( + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 1 + }, + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 2 + }).SetName("DifferentVariationVariationCoefficientLogNormalDistribution"); + yield return new TestCaseData( + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 1, + Shift = (RoundedDouble) 0.5 + }, + new VariationCoefficientLogNormalDistribution(2) + { + Mean = (RoundedDouble) 1, + CoefficientOfVariation = (RoundedDouble) 1, + Shift = (RoundedDouble) 0.4 + }).SetName("DifferentShiftVariationCoefficientLogNormalDistribution"); + } + #endregion } } \ No newline at end of file