// Copyright (C) Stichting Deltares 2018. 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 NUnit.Framework;
using Ringtoets.HydraRing.Calculation.Data;
using Ringtoets.HydraRing.Calculation.Data.Input;
using Ringtoets.HydraRing.Calculation.Data.Variables;
namespace Ringtoets.HydraRing.Calculation.TestUtil
{
///
/// Assert methods for .
///
public static class HydraRingDataEqualityHelper
{
private const double accuracy = 1e-6;
///
/// Asserts whether or not and are equal to each other.
///
/// The type of to compare.
/// The expected calculation input.
/// The actual calculation input.
public static void AreEqual(T expectedInput, T actualInput) where T : HydraRingCalculationInput
{
Assert.AreEqual(expectedInput.FailureMechanismType, actualInput.FailureMechanismType);
Assert.AreEqual(expectedInput.CalculationTypeId, actualInput.CalculationTypeId);
Assert.AreEqual(expectedInput.VariableId, actualInput.VariableId);
Assert.AreEqual(expectedInput.HydraulicBoundaryLocationId, actualInput.HydraulicBoundaryLocationId);
AreEqual(expectedInput.Section, actualInput.Section);
AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray());
AreEqual(expectedInput.ProfilePoints.ToArray(), actualInput.ProfilePoints.ToArray());
AreEqual(expectedInput.ForelandsPoints.ToArray(), actualInput.ForelandsPoints.ToArray());
AreEqual(expectedInput.BreakWater, actualInput.BreakWater);
Assert.AreEqual(expectedInput.Beta, actualInput.Beta, accuracy);
}
///
/// Asserts whether or not and are equal to each other.
///
/// The array of expected .
/// The array of actual .
public static void AreEqual(HydraRingVariable[] expectedVariables, HydraRingVariable[] actualVariables)
{
Assert.AreEqual(expectedVariables.Length, actualVariables.Length);
for (var i = 0; i < expectedVariables.Length; i++)
{
AreEqual(expectedVariables[i], actualVariables[i]);
}
}
private static void AreEqual(HydraRingSection expectedSection, HydraRingSection actualSection)
{
Assert.AreEqual(expectedSection.SectionId, actualSection.SectionId);
Assert.AreEqual(expectedSection.SectionLength, actualSection.SectionLength, accuracy);
Assert.AreEqual(expectedSection.CrossSectionNormal, actualSection.CrossSectionNormal, accuracy);
}
private static void AreEqual(HydraRingVariable expectedVariable, HydraRingVariable actualVariable)
{
Assert.AreEqual(expectedVariable.DeviationType, actualVariable.DeviationType);
Assert.AreEqual(expectedVariable.DistributionType, actualVariable.DistributionType);
Assert.AreEqual(expectedVariable.Value, actualVariable.Value, accuracy);
Assert.AreEqual(expectedVariable.Parameter1, actualVariable.Parameter1, accuracy);
Assert.AreEqual(expectedVariable.Parameter2, actualVariable.Parameter2);
Assert.AreEqual(expectedVariable.Parameter3, actualVariable.Parameter3);
Assert.AreEqual(expectedVariable.Parameter4, actualVariable.Parameter4);
Assert.AreEqual(expectedVariable.VariableId, actualVariable.VariableId, accuracy);
Assert.AreEqual(expectedVariable.CoefficientOfVariation, actualVariable.CoefficientOfVariation, accuracy);
}
private static void AreEqual(HydraRingProfilePoint[] expectedProfilePoints, HydraRingProfilePoint[] actualProfilePoints)
{
Assert.AreEqual(expectedProfilePoints.Length, actualProfilePoints.Length);
for (var i = 0; i < expectedProfilePoints.Length; i++)
{
Assert.AreEqual(expectedProfilePoints[i].X, actualProfilePoints[i].X, accuracy);
Assert.AreEqual(expectedProfilePoints[i].Z, actualProfilePoints[i].Z, accuracy);
Assert.AreEqual(expectedProfilePoints[i].Roughness, actualProfilePoints[i].Roughness, accuracy);
}
}
private static void AreEqual(HydraRingForelandPoint[] expectedForelandPoints, HydraRingForelandPoint[] actualForelandPoints)
{
Assert.AreEqual(expectedForelandPoints.Length, actualForelandPoints.Length);
for (var i = 0; i < expectedForelandPoints.Length; i++)
{
Assert.AreEqual(expectedForelandPoints[i].X, actualForelandPoints[i].X, accuracy);
Assert.AreEqual(expectedForelandPoints[i].Z, actualForelandPoints[i].Z, accuracy);
}
}
private static void AreEqual(HydraRingBreakWater expectedBreakWater, HydraRingBreakWater actualBreakWater)
{
if (expectedBreakWater == null)
{
Assert.IsNull(actualBreakWater);
}
else
{
Assert.AreEqual(expectedBreakWater.Height, actualBreakWater.Height, accuracy);
Assert.AreEqual(expectedBreakWater.Type, actualBreakWater.Type);
}
}
}
}