// 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 Core.Common.Base.Data;
using NUnit.Framework;
using Ringtoets.Common.Data.Probabilistics;
namespace Ringtoets.Common.Data.TestUtil
{
///
/// Class to assert the properties of the probabilistic distributions.
///
public static class DistributionAssert
{
///
/// Determines if the properties of the actual are the same
/// as the expected .
///
/// The expected .
/// The actual .
/// Thrown when the following differences are found between
/// the and :
///
/// - The probabilistic distribution types.
/// - The values for the mean and/or the standard deviation.
/// - The precision for the mean and/or the standard deviation.
///
public static void AreEqual(IDistribution expectedDistribution, IDistribution actualDistribution)
{
Assert.AreEqual(expectedDistribution.GetType(), actualDistribution.GetType());
AreEqualValue(expectedDistribution.Mean, actualDistribution.Mean);
AreEqualValue(expectedDistribution.StandardDeviation, actualDistribution.StandardDeviation);
}
///
/// Determines if the properties of the actual are the same
/// as the expected .
///
/// The expected .
/// The actual .
/// Thrown when the following differences are found between
/// the and :
///
/// - The probabilistic distribution types.
/// - The values for the mean, the standard deviation, the lower boundary and/or the upper boundary.
/// - The precision for the mean, the standard deviation, the lower boundary and/or the upper boundary.
///
public static void AreEqual(TruncatedNormalDistribution expectedDistribution, TruncatedNormalDistribution actualDistribution)
{
AreEqual((IDistribution) expectedDistribution, actualDistribution);
AreEqualValue(expectedDistribution.LowerBoundary, actualDistribution.LowerBoundary);
AreEqualValue(expectedDistribution.UpperBoundary, actualDistribution.UpperBoundary);
}
///
/// Determines if the properties of the actual are the same as
/// the expected .
///
/// The expected .
/// The actual .
/// Thrown when the following differences are found between
/// the and :
///
/// - The probabilistic distribution types.
/// - The values for the mean and/or the variation.
/// - The precision for the mean and/or the variation.
///
public static void AreEqual(IVariationCoefficientDistribution expectedDistribution, IVariationCoefficientDistribution actualDistribution)
{
Assert.AreEqual(expectedDistribution.GetType(), actualDistribution.GetType());
AreEqualValue(expectedDistribution.Mean, actualDistribution.Mean);
AreEqualValue(expectedDistribution.CoefficientOfVariation, actualDistribution.CoefficientOfVariation);
}
private static void AreEqualValue(RoundedDouble expectedValue, RoundedDouble actualValue)
{
Assert.AreEqual(expectedValue.NumberOfDecimalPlaces, actualValue.NumberOfDecimalPlaces);
Assert.AreEqual(expectedValue, actualValue);
}
}
}