using System; using System.Collections.Generic; using System.Net.NetworkInformation; using Xunit; using System.Linq; public abstract class BaseModifyXmlFsharpTests : PlDotNetTest { protected abstract string FunctionBody { get; } protected abstract LanguageType Language { get; } public BaseModifyXmlFsharpTests() { FunctionInfo = new SqlFunctionInfo { Name = "ModifyXmlFsharp", 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[] { "f#-xml", "modifyXmlFSharp1", "'Hello, World!'::XML", " = 'Goodbye, beautiful World!'::XML::text" }, new object[] { "f#-xml", "modifyXmlFSharp2", "''::XML", " = 'Goodbye, beautiful World, it was null!'::XML::text" }, new object[] { "f#-xml-null", "modifyXmlFSharp3", "NULL::XML", " = 'Goodbye, beautiful World, it was null!'::XML::text" }, }; } [Theory] [MemberData(nameof(TestCases))] public void TestModifyXmlFsharp(string featureName, string testName, string input, string expectedResult) { RunGenericTest(featureName, testName, input, expectedResult); } } [Trait("Language", "FSharp")] [Trait("Category", "String")] public class ModifyXmlFsharpTestsFSharp : BaseModifyXmlFsharpTests { protected override string FunctionBody => @" let mutable new_xml: string = """" if System.Object.ReferenceEquals(a, null) ||a.Equals("""") then new_xml <- ""Hello, World, it was null!"" else new_xml <- a new_xml <- (new_xml.Replace(""Hello"", ""Goodbye"")).Replace(""World"", ""beautiful World"") new_xml "; protected override LanguageType Language => LanguageType.PlfSharp; }