// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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 Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Io.XmlInput; using NUnit.Framework; namespace Deltares.DamEngine.Interface.Tests { [TestFixture] public class ConversionHelperTests { [Test] [TestCase(InputDamProjectType.Assessment, DamProjectType.Assessment)] [TestCase(InputDamProjectType.AssessmentRegional, DamProjectType.AssessmentRegional)] [TestCase(InputDamProjectType.Design, DamProjectType.Design)] [TestCase(InputDamProjectType.Operational, DamProjectType.Operational)] [TestCase(InputDamProjectType.NWO, DamProjectType.NWO)] public void CanConvertInputDamProjectType(InputDamProjectType inputDamProjectType, DamProjectType damProjectType) { Assert.AreEqual(damProjectType, ConversionHelper.ConvertToDamProjectType(inputDamProjectType)); } [Test] [TestCase(DamProjectType.Assessment, InputDamProjectType.Assessment)] [TestCase(DamProjectType.AssessmentRegional, InputDamProjectType.AssessmentRegional)] [TestCase(DamProjectType.Design, InputDamProjectType.Design)] [TestCase(DamProjectType.Operational, InputDamProjectType.Operational)] [TestCase(DamProjectType.NWO, InputDamProjectType.NWO)] public void CanConvertDamProjectType(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 CanConvertInputPlLineCreationMethod(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 CanConvertPlLineCreationMethod(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 CanConvertInputIntrusionVerticalWaterPressureType(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 CanConvertIntrusionVerticalWaterPressureType(IntrusionVerticalWaterPressureType intrusionVerticalWaterPressureType, LocationWaternetOptionsIntrusionVerticalWaterPressure inputIntrusionVerticalWaterPressureType) { Assert.AreEqual(inputIntrusionVerticalWaterPressureType, ConversionHelper.ConvertToInputIntrusionVerticalWaterPressure(intrusionVerticalWaterPressureType)); } [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)); } } }