// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Deltares.Dam.Data; using Deltares.Dam.Data.DamEngineIo; using Deltares.DamEngine.Io.XmlInput; using Deltares.Geotechnics.SurfaceLines; using Deltares.Standard; using NUnit.Framework; namespace Deltares.Dam.Tests.DamEngineIo { [TestFixture] public class ConversionHelperTests { [Test] [TestCase(InputDamProjectType.Assessment, DamProjectType.Assessment)] [TestCase(InputDamProjectType.AssessmentRegional, DamProjectType.Assessment)] [TestCase(InputDamProjectType.Design, DamProjectType.Design)] [TestCase(InputDamProjectType.Operational, DamProjectType.Calamity)] //[TestCase(InputDamProjectType.NWO, DamProjectType.NWO)] // not implemented yet public void CanConvertToDamProjectType(InputDamProjectType inputDamProjectType, DamProjectType damProjectType) { Assert.AreEqual(damProjectType, ConversionHelper.ConvertToDamProjectType(inputDamProjectType)); } [Test] [TestCase(DamProjectType.Assessment, InputDamProjectType.Assessment)] [TestCase(DamProjectType.Design, InputDamProjectType.Design)] [TestCase(DamProjectType.Calamity, InputDamProjectType.Operational)] // [TestCase(DamProjectType.NWO, InputDamProjectType.NWO)] // not implemented yet public void CanConvertToInputDamProjectType(DamProjectType damProjectType, InputDamProjectType inputDamProjectType) { Assert.AreEqual(inputDamProjectType, ConversionHelper.ConvertToInputDamProjectType(damProjectType)); } [Test] [TestCase(PLLineCreationMethod.ExpertKnowledgeLinearInDike, LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeLinearInDike)] [TestCase(PLLineCreationMethod.ExpertKnowledgeRRD, LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeRRD)] [TestCase(PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD, LocationWaternetOptionsPhreaticLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD)] [TestCase(PLLineCreationMethod.None, LocationWaternetOptionsPhreaticLineCreationMethod.None)] [TestCase(PLLineCreationMethod.Sensors, LocationWaternetOptionsPhreaticLineCreationMethod.Sensors)] public void CanConvertToPlLineCreationMethod(PLLineCreationMethod plLineCreationMethod, LocationWaternetOptionsPhreaticLineCreationMethod inputPhreaticLineCreationMethod) { Assert.AreEqual(inputPhreaticLineCreationMethod, ConversionHelper.ConvertToInputPhreaticLineCreationMethod(plLineCreationMethod)); } [Test] [TestCase(LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeLinearInDike, PLLineCreationMethod.ExpertKnowledgeLinearInDike)] [TestCase(LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeRRD, PLLineCreationMethod.ExpertKnowledgeRRD)] [TestCase(LocationWaternetOptionsPhreaticLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD, PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD)] [TestCase(LocationWaternetOptionsPhreaticLineCreationMethod.None, PLLineCreationMethod.None)] [TestCase(LocationWaternetOptionsPhreaticLineCreationMethod.Sensors, PLLineCreationMethod.Sensors)] public void CanConvertToInputPlLineCreationMethod(LocationWaternetOptionsPhreaticLineCreationMethod inputPhreaticLineCreationMethod, PLLineCreationMethod plLineCreationMethod) { Assert.AreEqual(plLineCreationMethod, ConversionHelper.ConvertToPhreaticLineCreationMethod(inputPhreaticLineCreationMethod)); } [Test] [TestCase(LocationWaternetOptionsIntrusionVerticalWaterPressure.FullHydroStatic, IntrusionVerticalWaterPressureType.FullHydroStatic)] [TestCase(LocationWaternetOptionsIntrusionVerticalWaterPressure.HydroStatic, IntrusionVerticalWaterPressureType.HydroStatic)] [TestCase(LocationWaternetOptionsIntrusionVerticalWaterPressure.Linear, IntrusionVerticalWaterPressureType.Linear)] [TestCase(LocationWaternetOptionsIntrusionVerticalWaterPressure.SemiTimeDependent, IntrusionVerticalWaterPressureType.SemiTimeDependent)] [TestCase(LocationWaternetOptionsIntrusionVerticalWaterPressure.Standard, IntrusionVerticalWaterPressureType.Standard)] public void CanConvertToIntrusionVerticalWaterPressureType(LocationWaternetOptionsIntrusionVerticalWaterPressure inputIntrusionVerticalWaterPressureType, IntrusionVerticalWaterPressureType intrusionVerticalWaterPressureType) { Assert.AreEqual(intrusionVerticalWaterPressureType, ConversionHelper.ConvertToIntrusionVerticalWaterPressure(inputIntrusionVerticalWaterPressureType)); } [Test] [TestCase(IntrusionVerticalWaterPressureType.FullHydroStatic, LocationWaternetOptionsIntrusionVerticalWaterPressure.FullHydroStatic)] [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, LocationWaternetOptionsIntrusionVerticalWaterPressure.HydroStatic)] [TestCase(IntrusionVerticalWaterPressureType.Linear, LocationWaternetOptionsIntrusionVerticalWaterPressure.Linear)] [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, LocationWaternetOptionsIntrusionVerticalWaterPressure.SemiTimeDependent)] [TestCase(IntrusionVerticalWaterPressureType.Standard, LocationWaternetOptionsIntrusionVerticalWaterPressure.Standard)] public void CanConvertToInputIntrusionVerticalWaterPressureType(IntrusionVerticalWaterPressureType intrusionVerticalWaterPressureType, LocationWaternetOptionsIntrusionVerticalWaterPressure inputIntrusionVerticalWaterPressureType) { Assert.AreEqual(inputIntrusionVerticalWaterPressureType, ConversionHelper.ConvertToInputIntrusionVerticalWaterPressure(intrusionVerticalWaterPressureType)); } [Test] [TestCase(ConversionHelper.CpNone, CharacteristicPointType.None)] [TestCase(ConversionHelper.CpSurfaceLevelOutside, CharacteristicPointType.SurfaceLevelOutside)] [TestCase(ConversionHelper.CpDikeToeAtRiver, CharacteristicPointType.DikeToeAtRiver)] [TestCase(ConversionHelper.CpShoulderTopOutside, CharacteristicPointType.ShoulderTopOutside)] [TestCase(ConversionHelper.CpShoulderBaseOutside, CharacteristicPointType.ShoulderBaseOutside)] [TestCase(ConversionHelper.CpDikeTopAtRiver, CharacteristicPointType.DikeTopAtRiver)] [TestCase(ConversionHelper.CpDikeLine, CharacteristicPointType.DikeLine)] [TestCase(ConversionHelper.CpTrafficLoadOutside, CharacteristicPointType.TrafficLoadOutside)] [TestCase(ConversionHelper.CpTrafficLoadInside, CharacteristicPointType.TrafficLoadInside)] [TestCase(ConversionHelper.CpDikeTopAtPolder, CharacteristicPointType.DikeTopAtPolder)] [TestCase(ConversionHelper.CpShoulderBaseInside, CharacteristicPointType.ShoulderBaseInside)] [TestCase(ConversionHelper.CpShoulderTopInside, CharacteristicPointType.ShoulderTopInside)] [TestCase(ConversionHelper.CpDikeToeAtPolder, CharacteristicPointType.DikeToeAtPolder)] [TestCase(ConversionHelper.CpDitchDikeSide, CharacteristicPointType.DitchDikeSide)] [TestCase(ConversionHelper.CpBottomDitchDikeSide, CharacteristicPointType.BottomDitchDikeSide)] [TestCase(ConversionHelper.CpBottomDitchPolderSide, CharacteristicPointType.BottomDitchPolderSide)] [TestCase(ConversionHelper.CpDitchPolderSide, CharacteristicPointType.DitchPolderSide)] [TestCase(ConversionHelper.CpSurfaceLevelInside, CharacteristicPointType.SurfaceLevelInside)] public void CanConvertToCharacteristicPointType(int inputPointType, CharacteristicPointType characteristicPointType) { Assert.AreEqual(characteristicPointType, ConversionHelper.ConvertToDamPointType(inputPointType)); } [Test] [TestCase(CharacteristicPointType.None, ConversionHelper.CpNone)] [TestCase(CharacteristicPointType.SurfaceLevelOutside, ConversionHelper.CpSurfaceLevelOutside)] [TestCase(CharacteristicPointType.DikeToeAtRiver, ConversionHelper.CpDikeToeAtRiver)] [TestCase(CharacteristicPointType.ShoulderTopOutside, ConversionHelper.CpShoulderTopOutside)] [TestCase(CharacteristicPointType.ShoulderBaseOutside, ConversionHelper.CpShoulderBaseOutside)] [TestCase(CharacteristicPointType.DikeTopAtRiver, ConversionHelper.CpDikeTopAtRiver)] [TestCase(CharacteristicPointType.DikeLine, ConversionHelper.CpDikeLine)] [TestCase(CharacteristicPointType.TrafficLoadOutside, ConversionHelper.CpTrafficLoadOutside)] [TestCase(CharacteristicPointType.TrafficLoadInside, ConversionHelper.CpTrafficLoadInside)] [TestCase(CharacteristicPointType.DikeTopAtPolder, ConversionHelper.CpDikeTopAtPolder)] [TestCase(CharacteristicPointType.ShoulderBaseInside, ConversionHelper.CpShoulderBaseInside)] [TestCase(CharacteristicPointType.ShoulderTopInside, ConversionHelper.CpShoulderTopInside)] [TestCase(CharacteristicPointType.DikeToeAtPolder, ConversionHelper.CpDikeToeAtPolder)] [TestCase(CharacteristicPointType.DitchDikeSide, ConversionHelper.CpDitchDikeSide)] [TestCase(CharacteristicPointType.BottomDitchDikeSide, ConversionHelper.CpBottomDitchDikeSide)] [TestCase(CharacteristicPointType.BottomDitchPolderSide, ConversionHelper.CpBottomDitchPolderSide)] [TestCase(CharacteristicPointType.DitchPolderSide, ConversionHelper.CpDitchPolderSide)] [TestCase(CharacteristicPointType.SurfaceLevelInside, ConversionHelper.CpSurfaceLevelInside)] public void CanConvertToInputPointType(CharacteristicPointType characteristicPointType, int inputPointType) { Assert.AreEqual(inputPointType, ConversionHelper.ConvertToInputPointType(characteristicPointType)); } [Test] [TestCase(0, CalculationResult.NoRun)] [TestCase(1, CalculationResult.Succeeded)] [TestCase(2, CalculationResult.NoInput)] [TestCase(3, CalculationResult.NoLicense)] [TestCase(4, CalculationResult.UserAbort)] [TestCase(5, CalculationResult.InvalidInputStructure)] [TestCase(6, CalculationResult.InvalidInputData)] [TestCase(7, CalculationResult.RunFailed)] [TestCase(8, CalculationResult.UnexpectedError)] public void CanConvertToOutputCalculationResult(int result, CalculationResult calculationResult) { Assert.AreEqual(result, ConversionHelper.ConvertToOutputCalculationResult(calculationResult)); } [Test] [TestCase(CalculationResult.NoRun, 0)] [TestCase(CalculationResult.Succeeded, 1)] [TestCase(CalculationResult.NoInput, 2)] [TestCase(CalculationResult.NoLicense, 3)] [TestCase(CalculationResult.UserAbort, 4)] [TestCase(CalculationResult.InvalidInputStructure, 5)] [TestCase(CalculationResult.InvalidInputData, 6)] [TestCase(CalculationResult.RunFailed, 7)] [TestCase(CalculationResult.UnexpectedError, 8)] public void CanConvertToCalculationResult(CalculationResult result, int calculationResult) { Assert.AreEqual(result, ConversionHelper.ConvertToCalculationResult(calculationResult)); } } }