Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/XmlAdapter.cs
===================================================================
diff -u -r5397 -r5426
--- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/XmlAdapter.cs (.../XmlAdapter.cs) (revision 5397)
+++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/XmlAdapter.cs (.../XmlAdapter.cs) (revision 5426)
@@ -21,30 +21,36 @@
using System.Linq;
using System.Text.RegularExpressions;
+using Deltares.DamEngine.Io.XmlInput;
namespace Deltares.DamEngine.TestHelpers;
///
/// Helper class for adapting xml in tests
///
-public class XmlAdapter
+public static class XmlAdapter
{
///
/// Changes in an XML the value of all elements with the specified key to the specified value.
///
/// The input.
/// The key.
/// The value.
- ///
+ /// The modified input
public static string ChangeValueInXml(string input, string key, string value)
{
- string result = input;
string searchString = key + "=" + "\"([^\"]*)\""; // This means match any pattern which matches =""
string replacement = key + "=\"" + value + "\""; // Replace with =""
- result = Regex.Replace(input, searchString, replacement, RegexOptions.IgnorePatternWhitespace);
+ string result = Regex.Replace(input, searchString, replacement, RegexOptions.IgnorePatternWhitespace);
return result;
}
-
+
+ ///
+ /// Selects locations from an XML based on the location names by removing the other locations.
+ ///
+ /// The input.
+ /// The names of the locations that need to be selected.
+ /// The modified input
public static string SelectLocations(string input, string[] locationNames)
{
string result = input;
@@ -61,4 +67,58 @@
return result;
}
+ ///
+ /// Changes the stability input model.
+ ///
+ /// The input.
+ /// The stability input model
+ /// The modified input
+ public static string ChangeStabilityInputModel(string input, InputStabilityModelType stabilityModelType)
+ {
+ const string pattern = "StabilityModelType=\"[a-zA-Z]+\"";
+ string replacement = stabilityModelType switch
+ {
+ InputStabilityModelType.Bishop => "StabilityModelType=\"Bishop\"",
+ InputStabilityModelType.UpliftVan => "StabilityModelType=\"UpliftVan\"",
+ InputStabilityModelType.BishopUpliftVan => "StabilityModelType=\"BishopUpliftVan\"",
+ _ => pattern
+ };
+ string result = Regex.Replace(input, pattern, replacement);
+ return result;
+ }
+
+ ///
+ /// Changes the piping input model.
+ ///
+ /// The input.
+ /// The piping input model
+ /// The modified input
+ public static string ChangePipingInputModel(string input, InputPipingModelType pipingModelType)
+ {
+ const string pattern = "PipingModelType=\"[a-zA-Z]+\"";
+ string replacement = pipingModelType switch
+ {
+ InputPipingModelType.Bligh => "PipingModelType=\"Bligh\"",
+ InputPipingModelType.WtiSellmeijerRevised => "PipingModelType=\"WtiSellmeijerRevised\"",
+ InputPipingModelType.Sellmeijer4Forces => "PipingModelType=\"Sellmeijer4Forces\"",
+ InputPipingModelType.SellmeijerVnk => "PipingModelType=\"SellmeijerVnk\"",
+ _ => pattern
+ };
+ string result = Regex.Replace(input, pattern, replacement);
+ return result;
+ }
+
+ ///
+ /// Changes the stability model type to piping model type.
+ ///
+ /// The input.
+ /// The modified input
+ public static string ChangeStabilityToPiping(string input)
+ {
+ const string pattern = "StabilityModelType=";
+ const string replacement = "PipingModelType=";
+ string result = Regex.Replace(input, pattern, replacement);
+ return result;
+ }
+
}
\ No newline at end of file