using System; using System.Collections.Generic; using System.Net.NetworkInformation; using Xunit; using System.Linq; public abstract class BaseModifyXmlTests : PlDotNetTest { protected abstract string FunctionBody { get; } protected abstract LanguageType Language { get; } public BaseModifyXmlTests() { FunctionInfo = new SqlFunctionInfo { Name = "ModifyXml", Arguments = new List { new FunctionArgument("a", "XML") }, ReturnType = "XML", Body = FunctionBody, Language = Language, IsStrict = false, CastFunctionAs = "TEXT", }; } public static object[][] TestCases() { return new object[][] { new object[] { "c#-xml", "modifyXml1", "'Hello, World!'::XML", " = 'Goodbye, beautiful World!'::XML::text" }, new object[] { "c#-xml-null", "modifyXml2", "NULL::XML", " = 'Goodbye, beautiful World, it was null!'::XML::text" }, }; } [Theory] [MemberData(nameof(TestCases))] public void TestModifyXml(string featureName, string testName, string input, string expectedResult) { RunGenericTest(featureName, testName, input, expectedResult); } } [Trait("Language", "CSharp")] [Trait("Category", "String")] public class ModifyXmlTestsCSharp : BaseModifyXmlTests { protected override string FunctionBody => @" if (a == null) a = ""Hello, World, it was null!""; string new_xml = ((string)a).Replace(""Hello"", ""Goodbye""); new_xml = ((string)new_xml).Replace(""World"", ""beautiful World""); return new_xml; "; protected override LanguageType Language => LanguageType.PlcSharp; }