// 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 System.Linq;
using NUnit.Framework;
using Ringtoets.HydraRing.Calculation.Data;
using Ringtoets.HydraRing.Calculation.Data.Input;
using Ringtoets.HydraRing.Calculation.Data.Input.Structures;
using Ringtoets.HydraRing.Calculation.Data.Input.WaveConditions;
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 eachother.
///
/// The expected calculation input.
/// The actual calculation input.
public static void AreEqual(WaveConditionsCosineCalculationInput expectedInput, HydraRingCalculationInput actualInput)
{
Assert.AreEqual(expectedInput.FailureMechanismType, actualInput.FailureMechanismType);
Assert.AreEqual(expectedInput.CalculationTypeId, actualInput.CalculationTypeId);
Assert.AreEqual(expectedInput.VariableId, actualInput.VariableId);
Assert.AreEqual(expectedInput.HydraulicBoundaryLocationId, actualInput.HydraulicBoundaryLocationId);
Assert.AreEqual(expectedInput.Section.SectionId, actualInput.Section.SectionId);
Assert.AreEqual(expectedInput.Beta, actualInput.Beta, accuracy);
Assert.AreEqual(expectedInput.Section.CrossSectionNormal, actualInput.Section.CrossSectionNormal, accuracy);
AreEqual(expectedInput.BreakWater, actualInput.BreakWater);
AreEqual(expectedInput.Section, actualInput.Section);
AreEqual(expectedInput.ForelandsPoints.ToArray(), actualInput.ForelandsPoints.ToArray());
AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray());
}
///
/// Asserts whether or not and are equal to eachother.
///
/// The expected calculation input.
/// The actual calculation input.
public static void AreEqual(StructuresOvertoppingCalculationInput expectedInput, StructuresOvertoppingCalculationInput actualInput)
{
Assert.AreEqual(expectedInput.FailureMechanismType, actualInput.FailureMechanismType);
Assert.AreEqual(expectedInput.CalculationTypeId, actualInput.CalculationTypeId);
Assert.AreEqual(expectedInput.VariableId, actualInput.VariableId);
Assert.AreEqual(expectedInput.HydraulicBoundaryLocationId, actualInput.HydraulicBoundaryLocationId);
Assert.AreEqual(expectedInput.Section.SectionId, actualInput.Section.SectionId);
Assert.AreEqual(expectedInput.Beta, actualInput.Beta, accuracy);
Assert.AreEqual(expectedInput.Section.CrossSectionNormal, actualInput.Section.CrossSectionNormal, accuracy);
AreEqual(expectedInput.BreakWater, actualInput.BreakWater);
AreEqual(expectedInput.Section, actualInput.Section);
AreEqual(expectedInput.ForelandsPoints.ToArray(), actualInput.ForelandsPoints.ToArray());
AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray());
}
///
/// Asserts whether or not and are equal to eachother.
///
/// The expected calculation input.
/// The actual calculation input.
public static void AreEqual(StructuresClosureCalculationInput expectedInput, StructuresClosureCalculationInput actualInput)
{
Assert.AreEqual(expectedInput.FailureMechanismType, actualInput.FailureMechanismType);
Assert.AreEqual(expectedInput.CalculationTypeId, actualInput.CalculationTypeId);
Assert.AreEqual(expectedInput.VariableId, actualInput.VariableId);
Assert.AreEqual(expectedInput.HydraulicBoundaryLocationId, actualInput.HydraulicBoundaryLocationId);
Assert.AreEqual(expectedInput.Section.SectionId, actualInput.Section.SectionId);
Assert.AreEqual(expectedInput.Beta, actualInput.Beta, accuracy);
Assert.AreEqual(expectedInput.Section.CrossSectionNormal, actualInput.Section.CrossSectionNormal, accuracy);
AreEqual(expectedInput.BreakWater, actualInput.BreakWater);
AreEqual(expectedInput.Section, actualInput.Section);
AreEqual(expectedInput.ForelandsPoints.ToArray(), actualInput.ForelandsPoints.ToArray());
AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray());
}
///
/// Asserts whether or not and are equal to eachother.
///
/// The expected calculation input.
/// The actual calculation input.
public static void AreEqual(StructuresStabilityPointCalculationInput expectedInput, StructuresStabilityPointCalculationInput actualInput)
{
Assert.AreEqual(expectedInput.FailureMechanismType, actualInput.FailureMechanismType);
Assert.AreEqual(expectedInput.CalculationTypeId, actualInput.CalculationTypeId);
Assert.AreEqual(expectedInput.VariableId, actualInput.VariableId);
Assert.AreEqual(expectedInput.HydraulicBoundaryLocationId, actualInput.HydraulicBoundaryLocationId);
Assert.AreEqual(expectedInput.Section.SectionId, actualInput.Section.SectionId);
Assert.AreEqual(expectedInput.Beta, actualInput.Beta, accuracy);
Assert.AreEqual(expectedInput.Section.CrossSectionNormal, actualInput.Section.CrossSectionNormal, accuracy);
AreEqual(expectedInput.BreakWater, actualInput.BreakWater);
AreEqual(expectedInput.Section, actualInput.Section);
AreEqual(expectedInput.ForelandsPoints.ToArray(), actualInput.ForelandsPoints.ToArray());
AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray());
}
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);
}
}
private static void AreEqual(HydraRingSection expectedSection, HydraRingSection actualSection)
{
Assert.AreEqual(expectedSection.SectionLength, actualSection.SectionLength, accuracy);
Assert.AreEqual(expectedSection.CrossSectionNormal, actualSection.CrossSectionNormal, accuracy);
Assert.AreEqual(expectedSection.SectionId, actualSection.SectionId);
}
private static void AreEqual(HydraRingForelandPoint[] expectedForelandPoints, HydraRingForelandPoint[] actualForelandPoints)
{
Assert.AreEqual(expectedForelandPoints.Length, actualForelandPoints.Length);
for (int i = 0; i < expectedForelandPoints.Length; i++)
{
Assert.AreEqual(expectedForelandPoints[i].X, actualForelandPoints[i].X, accuracy);
Assert.AreEqual(expectedForelandPoints[i].Z, actualForelandPoints[i].Z, accuracy);
}
}
///
/// Asserts whether or not and are equal to eachother.
///
/// The array of expected .
/// The array of actual .
public static void AreEqual(HydraRingVariable[] expected, HydraRingVariable[] actual)
{
Assert.AreEqual(expected.Length, actual.Length);
for (var i = 0; i < expected.Length; i++)
{
AreEqual(expected[i], actual[i]);
}
}
private static void AreEqual(HydraRingVariable expected, HydraRingVariable actual)
{
Assert.AreEqual(expected.DeviationType, actual.DeviationType);
Assert.AreEqual(expected.DistributionType, actual.DistributionType);
Assert.AreEqual(expected.Value, actual.Value, accuracy);
Assert.AreEqual(expected.Mean, actual.Mean, accuracy);
Assert.AreEqual(expected.Shift, actual.Shift, accuracy);
Assert.AreEqual(expected.Variability, actual.Variability, accuracy);
Assert.AreEqual(expected.VariableId, actual.VariableId, accuracy);
}
}
}