Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wicher <kwicher@microsoft.com>2016-07-28 23:16:52 +0300
committerKrzysztof Wicher <kwicher@microsoft.com>2016-07-28 23:16:52 +0300
commit65cca50e20ad60f96527648db31ec03b9cc361aa (patch)
tree598c1bf73b66019d4d502657606897e28851eeb9 /src/System.Private.Xml/tests/Xslt/XslTransformApi
parent2583be64b949ce1633ba88c8fe56f96a9e3cb2d2 (diff)
rename System.Xml to System.Private.Xml (no csproj changes)
Diffstat (limited to 'src/System.Private.Xml/tests/Xslt/XslTransformApi')
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CThreads.cs127
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CXmlCache.cs1426
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTArgumentList.cs3457
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs2652
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransformMultith.cs182
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltArgumentListMultith.cs301
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltChecksum.cs116
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/DataHelper.cs297
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs410
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/MyNavigator.cs181
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/Program.cs17
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj49
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/ThreadFunc.cs8
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs1026
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/XunitAssemblyAttributes.cs10
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/cthread.cs190
-rw-r--r--src/System.Private.Xml/tests/Xslt/XslTransformApi/project.json37
17 files changed, 10486 insertions, 0 deletions
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CThreads.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CThreads.cs
new file mode 100644
index 0000000000..ac8c2bcec9
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CThreads.cs
@@ -0,0 +1,127 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace System.Xml.Tests
+{
+ public sealed class CThreads
+ {
+ //Data
+ private IList<CThread> _rgThreads = new List<CThread>();
+
+ //Static
+ public static int MaxThreads = 20;
+
+ private ITestOutputHelper _output;
+ public CThreads(ITestOutputHelper output)
+ {
+ _output = output;
+ }
+
+ //Accessors
+ private IList<CThread> Internal
+ {
+ get { return _rgThreads; }
+ }
+
+ public CThread this[int index]
+ {
+ get { return _rgThreads[index]; }
+ }
+
+ public CThread Add(CThread rThread)
+ {
+ _rgThreads.Add(rThread);
+ return rThread;
+ }
+
+ public void Add(ThreadFunc func, object oParam)
+ {
+ Add(1, func, oParam);
+ }
+
+ public void Add(int cThreads, ThreadFunc func, object oParam)
+ {
+ //Default to one iteration
+ Add(cThreads, 1, func, oParam);
+ }
+
+ public void Add(int cThreads, int iterations, ThreadFunc func, object oParam)
+ {
+ for (int i = 0; i < cThreads; i++)
+ Add(new CThread(iterations, func, oParam, _output));
+ }
+
+ public void Start()
+ {
+ for (int i = 0; i < _rgThreads.Count; i++)
+ this[i].Start();
+ }
+
+ public void Abort()
+ {
+ for (int i = 0; i < _rgThreads.Count; i++)
+ this[i].Abort();
+ }
+
+ public void Wait()
+ {
+ Exception eReturn = null;
+
+ //Wait for all the threads to complete...
+ for (int i = 0; i < _rgThreads.Count; i++)
+ {
+ //Even if a thread ends up throwing, we still having to wait for all the
+ //other threads to complete first. Then throw the first exception received.
+ try
+ {
+ this[i].Wait();
+ }
+ catch (Exception e)
+ {
+ //Only need to save off the first exception
+ if (eReturn == null)
+ eReturn = e;
+ }
+ }
+
+ //If any of the threads failed, throw an exception...
+ if (eReturn != null)
+ throw eReturn;
+ }
+
+ public void StartSingleThreaded()
+ {
+ //This is mainly a debugging tool to ensure your threading scenario works
+ //if it was run actually sequentially. (ie: non-multlthreaded).
+ for (int i = 0; i < _rgThreads.Count; i++)
+ {
+ this[i].Start();
+ this[i].Wait();
+ }
+ }
+
+ public int ReturnCodes(int iReturnCode)
+ {
+ int cMatches = 0;
+ for (int i = 0; i < _rgThreads.Count; i++)
+ {
+ if (this[i].ReturnCode == iReturnCode)
+ cMatches++;
+ }
+
+ return cMatches;
+ }
+
+ public void Verify(int cThreads, int iReturnCode)
+ {
+ //Make sure the number of threads expected had the correct return code...
+ Assert.Equal(ReturnCodes(iReturnCode), cThreads);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXmlCache.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXmlCache.cs
new file mode 100644
index 0000000000..32086f4416
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXmlCache.cs
@@ -0,0 +1,1426 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+
+public enum NodeFlags
+{
+ None = 0,
+ EmptyElement = 1,
+ HasValue = 2,
+ SingleQuote = 4,
+ DefaultAttribute = 8,
+ UnparsedEntities = 16,
+ IsWhitespace = 32,
+ DocumentRoot = 64,
+ AttributeTextNode = 128,
+ MixedContent = 256,
+ Indent = 512
+}
+
+abstract public class CXmlBase
+{
+ protected XmlNodeType _nType;
+ protected string _strName;
+ protected string _strLocalName;
+ protected string _strPrefix;
+ protected string _strNamespace;
+ internal int _nDepth;
+ internal NodeFlags _eFlags = NodeFlags.None;
+ internal CXmlBase _rNextNode = null;
+ internal CXmlBase _rParentNode = null;
+ internal CXmlBase _rFirstChildNode = null;
+ internal CXmlBase _rLastChildNode = null;
+ internal int _nChildNodes = 0;
+
+ //
+ // Constructors
+ //
+ public CXmlBase(string strPrefix, string strName, string strLocalName, XmlNodeType NodeType, string strNamespace)
+ {
+ _strPrefix = strPrefix;
+ _strName = strName;
+ _strLocalName = strLocalName;
+ _nType = NodeType;
+ _strNamespace = strNamespace;
+ }
+
+ public CXmlBase(string strPrefix, string strName, XmlNodeType NodeType, string strNamespace)
+ : this(strPrefix, strName, strName, NodeType, strNamespace)
+ { }
+
+ public CXmlBase(string strPrefix, string strName, XmlNodeType NodeType)
+ : this(strPrefix, strName, strName, NodeType, "")
+ { }
+
+ public CXmlBase(string strName, XmlNodeType NodeType)
+ : this("", strName, strName, NodeType, "")
+ { }
+
+ //
+ // Virtual Methods and Properties
+ //
+ abstract public void Write(XmlWriter rXmlWriter);
+
+ abstract public string Xml
+ { get; }
+
+ abstract public void WriteXml(TextWriter rTW);
+
+ abstract public string Value
+ { get; }
+
+ //
+ // Public Methods and Properties
+ //
+ public string Name
+ {
+ get { return _strName; }
+ }
+
+ public string LocalName
+ {
+ get { return _strLocalName; }
+ }
+
+ public string Prefix
+ {
+ get { return _strPrefix; }
+ }
+
+ public string Namespace
+ {
+ get { return _strNamespace; }
+ }
+
+ public int Depth
+ {
+ get { return _nDepth; }
+ }
+
+ public XmlNodeType NodeType
+ {
+ get { return _nType; }
+ }
+
+ public NodeFlags Flags
+ {
+ get { return _eFlags; }
+ }
+
+ public int ChildNodeCount
+ {
+ get { return _nChildNodes; }
+ }
+
+ public void InsertNode(CXmlBase rNode)
+ {
+ if (_rFirstChildNode == null)
+ {
+ _rFirstChildNode = _rLastChildNode = rNode;
+ }
+ else
+ {
+ _rLastChildNode._rNextNode = rNode;
+ _rLastChildNode = rNode;
+ }
+
+ if ((this._eFlags & NodeFlags.IsWhitespace) == 0)
+ _nChildNodes++;
+
+ rNode._rParentNode = this;
+ }
+
+ //
+ // Internal Methods and Properties
+ //
+ internal CXmlBase _Child(int n)
+ {
+ int i;
+ int j;
+ CXmlBase rChild = _rFirstChildNode;
+
+ for (i = 0, j = 0; rChild != null; i++, rChild = rChild._rNextNode)
+ {
+ if ((rChild._eFlags & NodeFlags.IsWhitespace) == 0)
+ {
+ if (j++ == n) break;
+ }
+ }
+
+ return rChild;
+ }
+
+ internal CXmlBase _Child(string str)
+ {
+ CXmlBase rChild;
+
+ for (rChild = _rFirstChildNode; rChild != null; rChild = rChild._rNextNode)
+ if (rChild.Name == str) break;
+
+ return rChild;
+ }
+
+ //
+ // Private Methods and Properties
+ //
+}
+
+public class CXmlAttribute : CXmlBase
+{
+ //
+ // Constructor
+ //
+ public CXmlAttribute(XmlReader rXmlReader)
+ : base(rXmlReader.Prefix, rXmlReader.Name, rXmlReader.LocalName, rXmlReader.NodeType, rXmlReader.NamespaceURI)
+ {
+ if (rXmlReader.IsDefault)
+ _eFlags |= NodeFlags.DefaultAttribute;
+
+ if (rXmlReader.QuoteChar == '\'')
+ _eFlags |= NodeFlags.SingleQuote;
+ }
+
+ //
+ // Public Methods and Properties (Override)
+ //
+ override public void Write(XmlWriter rXmlWriter)
+ {
+ CXmlBase rNode;
+
+ if ((this._eFlags & NodeFlags.DefaultAttribute) == 0)
+ {
+ if (rXmlWriter is XmlTextWriter)
+ ((XmlTextWriter)rXmlWriter).QuoteChar = this.Quote;
+
+ rXmlWriter.WriteStartAttribute(this.Prefix, this.LocalName, this.Namespace);
+
+ for (rNode = this._rFirstChildNode; rNode != null; rNode = rNode._rNextNode)
+ {
+ rNode.Write(rXmlWriter);
+ }
+
+ rXmlWriter.WriteEndAttribute();
+ }
+ }
+
+ override public string Xml
+ {
+ get
+ {
+ CXmlCache._rBufferWriter.Dispose();
+ WriteXml(CXmlCache._rBufferWriter);
+ return CXmlCache._rBufferWriter.ToString();
+ }
+ }
+
+ override public void WriteXml(TextWriter rTW)
+ {
+ if ((this._eFlags & NodeFlags.DefaultAttribute) == 0)
+ {
+ CXmlBase rNode;
+
+ rTW.Write(' ' + this.Name + '=' + this.Quote);
+ for (rNode = this._rFirstChildNode; rNode != null; rNode = rNode._rNextNode)
+ {
+ rNode.WriteXml(rTW);
+ }
+ rTW.Write(this.Quote);
+ }
+ }
+
+ //
+ // Public Methods and Properties
+ //
+ override public string Value
+ {
+ get
+ {
+ CXmlNode rNode;
+ string strValue = string.Empty;
+
+ for (rNode = (CXmlNode)this._rFirstChildNode; rNode != null; rNode = rNode.NextNode)
+ strValue += rNode.Value;
+
+ return strValue;
+ }
+ }
+
+ public CXmlAttribute NextAttribute
+ {
+ get { return (CXmlAttribute)this._rNextNode; }
+ }
+
+ public char Quote
+ {
+ get { return ((base._eFlags & NodeFlags.SingleQuote) != 0 ? '\'' : '"'); }
+ set { if (value == '\'') base._eFlags |= NodeFlags.SingleQuote; else base._eFlags &= ~NodeFlags.SingleQuote; }
+ }
+
+ public CXmlNode FirstChild
+ {
+ get { return (CXmlNode)base._rFirstChildNode; }
+ }
+
+ public CXmlNode Child(int n)
+ {
+ return (CXmlNode)base._Child(n);
+ }
+
+ public CXmlNode Child(string str)
+ {
+ return (CXmlNode)base._Child(str);
+ }
+}
+
+public class CXmlNode : CXmlBase
+{
+ internal string _strValue = null;
+ private CXmlAttribute _rFirstAttribute = null;
+ private CXmlAttribute _rLastAttribute = null;
+ private int _nAttributeCount = 0;
+
+ //
+ // Constructors
+ //
+ public CXmlNode(string strPrefix, string strName, XmlNodeType NodeType)
+ : base(strPrefix, strName, NodeType)
+ { }
+
+ public CXmlNode(XmlReader rXmlReader)
+ : base(rXmlReader.Prefix, rXmlReader.Name, rXmlReader.LocalName, rXmlReader.NodeType, rXmlReader.NamespaceURI)
+ {
+ _eFlags |= CXmlCache._eDefaultFlags;
+
+ if (NodeType == XmlNodeType.Whitespace ||
+ NodeType == XmlNodeType.SignificantWhitespace)
+ {
+ _eFlags |= NodeFlags.IsWhitespace;
+ }
+
+ if (rXmlReader.IsEmptyElement)
+ {
+ _eFlags |= NodeFlags.EmptyElement;
+ }
+
+ if (rXmlReader.HasValue)
+ {
+ _eFlags |= NodeFlags.HasValue;
+ _strValue = rXmlReader.Value;
+ }
+ }
+
+ //
+ // Public Methods and Properties (Override)
+ //
+ override public void Write(XmlWriter rXmlWriter)
+ {
+ CXmlBase rNode;
+ CXmlAttribute rAttribute;
+ string DocTypePublic = null;
+ string DocTypeSystem = null;
+
+ /*
+ // Display of Indent information
+ if (this.LocalName == string.Empty)
+ _output.WriteLine("Node={0}, Indent={1}, Mixed={2}",this.NodeType, this.Flags & NodeFlags.Indent, this.Flags & NodeFlags.MixedContent);
+ else
+ _output.WriteLine("Node={0}, Indent={1}, Mixed={2}",this.LocalName, this.Flags & NodeFlags.Indent, this.Flags & NodeFlags.MixedContent);
+ */
+ switch (this.NodeType)
+ {
+ case XmlNodeType.CDATA:
+ rXmlWriter.WriteCData(this._strValue);
+ break;
+
+ case XmlNodeType.Comment:
+ rXmlWriter.WriteComment(this._strValue);
+ break;
+
+ case XmlNodeType.DocumentType:
+ for (rAttribute = _rFirstAttribute; rAttribute != null; rAttribute = rAttribute.NextAttribute)
+ {
+ if (rAttribute.Name == "PUBLIC")
+ { DocTypePublic = rAttribute.Value; }
+ if (rAttribute.Name == "SYSTEM")
+ { DocTypeSystem = rAttribute.Value; }
+ }
+ rXmlWriter.WriteDocType(this.Name, DocTypePublic, DocTypeSystem, this._strValue);
+ break;
+
+ case XmlNodeType.EntityReference:
+ rXmlWriter.WriteEntityRef(this.Name);
+ break;
+
+ case XmlNodeType.ProcessingInstruction:
+ rXmlWriter.WriteProcessingInstruction(this.Name, this._strValue);
+ break;
+
+ case XmlNodeType.Text:
+ if (this.Name == string.Empty)
+ {
+ if ((this.Flags & NodeFlags.UnparsedEntities) == 0)
+ {
+ rXmlWriter.WriteString(this._strValue);
+ }
+ else
+ {
+ rXmlWriter.WriteRaw(this._strValue.ToCharArray(), 0, this._strValue.Length);
+ }
+ }
+ else
+ {
+ if (this._strName[0] == '#')
+ rXmlWriter.WriteCharEntity(this._strValue[0]);
+ else
+ rXmlWriter.WriteEntityRef(this.Name);
+ }
+ break;
+
+ case XmlNodeType.Whitespace:
+ case XmlNodeType.SignificantWhitespace:
+ if ((this._rParentNode._eFlags & NodeFlags.DocumentRoot) != 0)
+ rXmlWriter.WriteRaw(this._strValue.ToCharArray(), 0, this._strValue.Length);
+ else
+ rXmlWriter.WriteString(this._strValue);
+ break;
+
+ case XmlNodeType.Element:
+ rXmlWriter.WriteStartElement(this.Prefix, this.LocalName, null);
+
+ for (rAttribute = _rFirstAttribute; rAttribute != null; rAttribute = rAttribute.NextAttribute)
+ {
+ rAttribute.Write(rXmlWriter);
+ }
+
+ if ((this.Flags & NodeFlags.EmptyElement) == 0)
+ rXmlWriter.WriteString(string.Empty);
+
+ for (rNode = base._rFirstChildNode; rNode != null; rNode = rNode._rNextNode)
+ {
+ rNode.Write(rXmlWriter);
+ }
+
+ // Should only produce empty tag if the original document used empty tag
+ if ((this.Flags & NodeFlags.EmptyElement) == 0)
+ rXmlWriter.WriteFullEndElement();
+ else
+ rXmlWriter.WriteEndElement();
+
+ break;
+
+ case XmlNodeType.XmlDeclaration:
+ rXmlWriter.WriteRaw("<?xml " + this._strValue + "?>");
+ break;
+
+ default:
+ throw (new Exception("Node.Write: Unhandled node type " + this.NodeType.ToString()));
+ }
+ }
+
+ override public string Xml
+ {
+ get
+ {
+ CXmlCache._rBufferWriter.Dispose();
+ WriteXml(CXmlCache._rBufferWriter);
+ return CXmlCache._rBufferWriter.ToString();
+ }
+ }
+
+ override public void WriteXml(TextWriter rTW)
+ {
+ String strXml;
+ CXmlAttribute rAttribute;
+ CXmlBase rNode;
+
+ switch (this._nType)
+ {
+ case XmlNodeType.Text:
+ if (this._strName == "")
+ {
+ rTW.Write(this._strValue);
+ }
+ else
+ {
+ if (this._strName.StartsWith("#"))
+ {
+ rTW.Write("&" + Convert.ToString(Convert.ToInt32(this._strValue[0])) + ";");
+ }
+ else
+ {
+ rTW.Write("&" + this.Name + ";");
+ }
+ }
+ break;
+
+ case XmlNodeType.Whitespace:
+ case XmlNodeType.SignificantWhitespace:
+ case XmlNodeType.DocumentType:
+ rTW.Write(this._strValue);
+ break;
+
+ case XmlNodeType.Element:
+ strXml = this.Name;
+ rTW.Write('<' + strXml);
+
+ //Put in all the Attributes
+ for (rAttribute = _rFirstAttribute; rAttribute != null; rAttribute = rAttribute.NextAttribute)
+ {
+ rAttribute.WriteXml(rTW);
+ }
+
+ //If there is children, put those in, otherwise close the tag.
+ if ((base._eFlags & NodeFlags.EmptyElement) == 0)
+ {
+ rTW.Write('>');
+
+ for (rNode = base._rFirstChildNode; rNode != null; rNode = rNode._rNextNode)
+ {
+ rNode.WriteXml(rTW);
+ }
+
+ rTW.Write("</" + strXml + ">");
+ }
+ else
+ {
+ rTW.Write(" />");
+ }
+
+ break;
+
+ case XmlNodeType.EntityReference:
+ rTW.Write("&" + this._strName + ";");
+ break;
+
+ case XmlNodeType.Notation:
+ rTW.Write("<!NOTATION " + this._strValue + ">");
+ break;
+
+ case XmlNodeType.CDATA:
+ rTW.Write("<![CDATA[" + this._strValue + "]]>");
+ break;
+
+ case XmlNodeType.XmlDeclaration:
+ case XmlNodeType.ProcessingInstruction:
+ rTW.Write("<?" + this._strName + " " + this._strValue + "?>");
+ break;
+
+ case XmlNodeType.Comment:
+ rTW.Write("<!--" + this._strValue + "-->");
+ break;
+
+ default:
+ throw (new Exception("Unhandled NodeType " + this._nType.ToString()));
+ }
+ }
+
+ //
+ // Public Methods and Properties
+ //
+ public string NodeValue
+ {
+ get { return _strValue; }
+ }
+
+ override public string Value
+ {
+ get
+ {
+ string strValue = "";
+ CXmlNode rChild;
+
+ if ((this._eFlags & NodeFlags.HasValue) != 0)
+ {
+ char chEnt;
+ int nIndexAmp = 0;
+ int nIndexSem = 0;
+
+ if ((this._eFlags & NodeFlags.UnparsedEntities) == 0)
+ return this._strValue;
+
+ strValue = this._strValue;
+
+ while ((nIndexAmp = strValue.IndexOf('&', nIndexAmp)) != -1)
+ {
+ nIndexSem = strValue.IndexOf(';', nIndexAmp);
+ chEnt = ResolveCharEntity(strValue.Substring(nIndexAmp + 1, nIndexSem - nIndexAmp - 1));
+ if (chEnt != char.MinValue)
+ {
+ strValue = strValue.Substring(0, nIndexAmp) + chEnt + strValue.Substring(nIndexSem + 1);
+ nIndexAmp++;
+ }
+ else
+ nIndexAmp = nIndexSem;
+ }
+ return strValue;
+ }
+
+ for (rChild = (CXmlNode)this._rFirstChildNode; rChild != null; rChild = (CXmlNode)rChild._rNextNode)
+ {
+ strValue = strValue + rChild.Value;
+ }
+
+ return strValue;
+ }
+ }
+
+ public CXmlNode NextNode
+ {
+ get
+ {
+ CXmlBase rNode = this._rNextNode;
+
+ while (rNode != null &&
+ (rNode.Flags & NodeFlags.IsWhitespace) != 0)
+ rNode = rNode._rNextNode;
+ return (CXmlNode)rNode;
+ }
+ }
+
+ public CXmlNode FirstChild
+ {
+ get
+ {
+ CXmlBase rNode = this._rFirstChildNode;
+
+ while (rNode != null &&
+ (rNode.Flags & NodeFlags.IsWhitespace) != 0)
+ rNode = rNode._rNextNode;
+ return (CXmlNode)rNode;
+ }
+ }
+
+ public CXmlNode Child(int n)
+ {
+ int i;
+ CXmlNode rChild;
+
+ i = 0;
+ for (rChild = FirstChild; rChild != null; rChild = rChild.NextNode)
+ if (i++ == n) break;
+
+ return rChild;
+ }
+
+ public CXmlNode Child(string str)
+ {
+ return (CXmlNode)base._Child(str);
+ }
+
+ public int Type
+ {
+ get { return Convert.ToInt32(base._nType); }
+ }
+
+ public CXmlAttribute FirstAttribute
+ {
+ get { return _rFirstAttribute; }
+ }
+
+ public int AttributeCount
+ {
+ get { return _nAttributeCount; }
+ }
+
+ public CXmlAttribute Attribute(int n)
+ {
+ int i;
+ CXmlAttribute rAttribute;
+
+ i = 0;
+ for (rAttribute = _rFirstAttribute; rAttribute != null; rAttribute = rAttribute.NextAttribute)
+ if (i++ == n) break;
+ return rAttribute;
+ }
+
+ public CXmlAttribute Attribute(string str)
+ {
+ CXmlAttribute rAttribute;
+
+ for (rAttribute = _rFirstAttribute; rAttribute != null; rAttribute = rAttribute.NextAttribute)
+ {
+ if (rAttribute.Name == str) break;
+ }
+
+ return rAttribute;
+ }
+
+ public void AddAttribute(CXmlAttribute rAttribute)
+ {
+ if (_rFirstAttribute == null)
+ {
+ _rFirstAttribute = rAttribute;
+ }
+ else
+ {
+ _rLastAttribute._rNextNode = rAttribute;
+ }
+ _rLastAttribute = rAttribute;
+ _nAttributeCount++;
+ }
+
+ private char ResolveCharEntity(string strName)
+ {
+ if (strName[0] == '#')
+ if (strName[1] == 'x')
+ return Convert.ToChar(Convert.ToInt32(strName.Substring(2), 16));
+ else
+ return Convert.ToChar(Convert.ToInt32(strName.Substring(1)));
+ if (strName == "lt")
+ return '<';
+ if (strName == "gt")
+ return '>';
+ if (strName == "amp")
+ return '&';
+ if (strName == "apos")
+ return '\'';
+ if (strName == "quot")
+ return '"';
+
+ return char.MinValue;
+ }
+}
+
+public class CXmlCache
+{
+ //CXmlCache Properties
+ private bool _fTrace = false;
+
+ private bool _fThrow = true;
+ private bool _fReadNode = true;
+ private int _hr = 0;
+ private Encoding _eEncoding = System.Text.Encoding.UTF8;
+ private string _strParseError = "";
+
+ //XmlReader Properties
+#pragma warning disable 0618
+ private ValidationType _eValidationMode = ValidationType.Auto;
+#pragma warning restore 0618
+
+ private WhitespaceHandling _eWhitespaceMode = WhitespaceHandling.None;
+ private EntityHandling _eEntityMode = EntityHandling.ExpandEntities;
+ private bool _fNamespaces = true;
+
+ private bool _fValidationCallback = false;
+ private bool _fExpandAttributeValues = false;
+
+ //Internal stuff
+ protected XmlReader _rXmlReader = null;
+
+ protected CXmlNode _rDocumentRootNode;
+ protected CXmlNode _rRootNode = null;
+ internal static NodeFlags _eDefaultFlags = NodeFlags.None;
+ static internal BufferWriter _rBufferWriter = new BufferWriter();
+
+ private ITestOutputHelper _output;
+ public CXmlCache(ITestOutputHelper output)
+ {
+ _output = output;
+ }
+
+ //
+ // Constructor
+ //
+ public CXmlCache()
+ {
+ }
+
+ //
+ // Public Methods and Properties
+ //
+ public virtual bool Load(XmlReader rXmlReader)
+ {
+ //Hook up your reader as my reader
+ _rXmlReader = rXmlReader;
+
+ if (rXmlReader is XmlTextReader)
+ {
+ _eWhitespaceMode = ((XmlTextReader)rXmlReader).WhitespaceHandling;
+ _fNamespaces = ((XmlTextReader)rXmlReader).Namespaces;
+ _eValidationMode = ValidationType.None;
+ // _eEntityMode = ((XmlValidatingReader)rXmlReader).EntityHandling;
+ }
+#pragma warning disable 0618
+ if (rXmlReader is XmlValidatingReader)
+ {
+ if (((XmlValidatingReader)rXmlReader).Reader is XmlTextReader)
+ {
+ _eWhitespaceMode = ((XmlTextReader)((XmlValidatingReader)rXmlReader).Reader).WhitespaceHandling;
+ }
+ else
+ {
+ _eWhitespaceMode = WhitespaceHandling.None;
+ }
+ _fNamespaces = ((XmlValidatingReader)rXmlReader).Namespaces;
+ _eValidationMode = ((XmlValidatingReader)rXmlReader).ValidationType;
+ _eEntityMode = ((XmlValidatingReader)rXmlReader).EntityHandling;
+ }
+#pragma warning restore 0618
+
+ DebugTrace("Setting ValidationMode=" + _eValidationMode.ToString());
+ DebugTrace("Setting EntityMode=" + _eEntityMode.ToString());
+ DebugTrace("Setting WhitespaceMode=" + _eWhitespaceMode.ToString());
+
+ //Process the Document
+ try
+ {
+ _rDocumentRootNode = new CXmlNode("", "", XmlNodeType.Element);
+ _rDocumentRootNode._eFlags = NodeFlags.DocumentRoot | NodeFlags.Indent;
+ Process(_rDocumentRootNode);
+ for (_rRootNode = _rDocumentRootNode.FirstChild; _rRootNode != null && _rRootNode.NodeType != XmlNodeType.Element; _rRootNode = _rRootNode.NextNode) ;
+ }
+ catch (Exception e)
+ {
+ //Unhook your reader
+ _rXmlReader = null;
+
+ _strParseError = e.ToString();
+
+ if (_fThrow)
+ {
+ throw (e);
+ }
+
+ if (_hr == 0)
+ _hr = -1;
+
+ return false;
+ }
+
+ //Unhook your reader
+ _rXmlReader = null;
+
+ return true;
+ }
+
+ public bool Load(string strFileName)
+ {
+#pragma warning disable 0618
+ XmlTextReader rXmlTextReader;
+ XmlValidatingReader rXmlValidatingReader;
+ bool fRet;
+
+ rXmlTextReader = new XmlTextReader(strFileName);
+ rXmlTextReader.WhitespaceHandling = _eWhitespaceMode;
+ rXmlTextReader.Namespaces = _fNamespaces;
+
+ _eEncoding = rXmlTextReader.Encoding;
+
+ rXmlValidatingReader = new XmlValidatingReader(rXmlTextReader);
+ rXmlValidatingReader.ValidationType = _eValidationMode;
+ rXmlValidatingReader.EntityHandling = _eEntityMode;
+#pragma warning restore 0618
+
+ if (_fValidationCallback)
+ rXmlValidatingReader.ValidationEventHandler += new ValidationEventHandler(this.ValidationCallback);
+
+ try
+ {
+ fRet = Load((XmlReader)rXmlValidatingReader);
+ }
+ catch (Exception e)
+ {
+ fRet = false;
+ rXmlValidatingReader.Dispose();
+ rXmlTextReader.Dispose();
+
+ if (_strParseError == string.Empty)
+ _strParseError = e.ToString();
+
+ if (_fThrow)
+ throw (e);
+ }
+
+ rXmlValidatingReader.Dispose();
+ rXmlTextReader.Dispose();
+ return fRet;
+ }
+
+ public void Save(string strName)
+ {
+ Save(strName, false, _eEncoding);
+ }
+
+ public void Save(string strName, bool fOverWrite)
+ {
+ Save(strName, fOverWrite, _eEncoding);
+ }
+
+ public void Save(string strName, bool fOverWrite, System.Text.Encoding Encoding)
+ {
+ CXmlBase rNode;
+ XmlTextWriter rXmlTextWriter = null;
+
+ try
+ {
+ if (fOverWrite)
+ {
+ File.Delete(strName);
+ }
+
+ rXmlTextWriter = new XmlTextWriter(strName, Encoding);
+ rXmlTextWriter.Namespaces = _fNamespaces;
+
+ for (rNode = _rDocumentRootNode._rFirstChildNode; rNode != null; rNode = rNode._rNextNode)
+ {
+ rNode.Write(rXmlTextWriter);
+ }
+ rXmlTextWriter.Dispose();
+ }
+ catch (Exception e)
+ {
+ DebugTrace(e.ToString());
+ if (rXmlTextWriter != null)
+ rXmlTextWriter.Dispose();
+ throw (e);
+ }
+ }
+
+ virtual public string Xml
+ {
+ get
+ {
+ _rBufferWriter.Dispose();
+ WriteXml(_rBufferWriter);
+ return _rBufferWriter.ToString();
+ }
+ }
+
+ public void WriteXml(TextWriter rTW)
+ {
+ CXmlBase rNode;
+
+ //Spit out the document
+ for (rNode = _rDocumentRootNode._rFirstChildNode; rNode != null; rNode = rNode._rNextNode)
+ rNode.WriteXml(rTW);
+ }
+
+ public CXmlNode RootNode
+ {
+ get { return _rRootNode; }
+ }
+
+ public string ParseError
+ {
+ get { return _strParseError; }
+ }
+
+ public int ParseErrorCode
+ {
+ get { return _hr; }
+ }
+
+ //
+ // XmlReader Properties
+ //
+ public string EntityMode
+ {
+ set
+ {
+ if (value == "ExpandEntities")
+ _eEntityMode = EntityHandling.ExpandEntities;
+ else if (value == "ExpandCharEntities")
+ _eEntityMode = EntityHandling.ExpandCharEntities;
+ else
+ throw (new Exception("Invalid Entity mode."));
+ }
+ get { return _eEntityMode.ToString(); }
+ }
+
+ public string ValidationMode
+ {
+ set
+ {
+#pragma warning disable 0618
+ if (value == "None")
+ _eValidationMode = ValidationType.None;
+ else if (value == "DTD")
+ _eValidationMode = ValidationType.DTD;
+ else if (value == "XDR")
+ _eValidationMode = ValidationType.XDR;
+ else if (value == "Schema")
+ _eValidationMode = ValidationType.Schema;
+ else if (value == "Auto")
+ _eValidationMode = ValidationType.Auto;
+ else
+ throw (new Exception("Invalid Validation mode."));
+#pragma warning restore 0618
+ }
+ get { return _eValidationMode.ToString(); }
+ }
+
+ public string WhitespaceMode
+ {
+ set
+ {
+ if (value == "All")
+ _eWhitespaceMode = WhitespaceHandling.All;
+ else if (value == "Significant")
+ _eWhitespaceMode = WhitespaceHandling.Significant;
+ else if (value == "None")
+ _eWhitespaceMode = WhitespaceHandling.None;
+ else
+ throw (new Exception("Invalid Whitespace mode."));
+ }
+ get { return _eWhitespaceMode.ToString(); }
+ }
+
+ public bool Namespaces
+ {
+ set { _fNamespaces = value; }
+ get { return _fNamespaces; }
+ }
+
+ public bool UseValidationCallback
+ {
+ set { _fValidationCallback = value; }
+ get { return _fValidationCallback; }
+ }
+
+ public bool ExpandAttributeValues
+ {
+ set { _fExpandAttributeValues = value; }
+ get { return _fExpandAttributeValues; }
+ }
+
+ //
+ // Internal Properties
+ //
+ public bool Throw
+ {
+ get { return _fThrow; }
+ set { _fThrow = value; }
+ }
+
+ public bool Trace
+ {
+ set { _fTrace = value; }
+ get { return _fTrace; }
+ }
+
+ //
+ //Private Methods
+ //
+ private void DebugTrace(string str)
+ {
+ DebugTrace(str, 0);
+ }
+
+ private void DebugTrace(string str, int nDepth)
+ {
+ if (_fTrace)
+ {
+ int i;
+
+ for (i = 0; i < nDepth; i++)
+ _output.WriteLine(" ");
+ _output.WriteLine(str);
+ }
+ }
+
+ private void DebugTrace(XmlReader rXmlReader)
+ {
+ if (_fTrace)
+ {
+ string str;
+
+ str = rXmlReader.NodeType.ToString() + ", Depth=" + rXmlReader.Depth + " Name=";
+ if (rXmlReader.Prefix != "")
+ {
+ str += rXmlReader.Prefix + ":";
+ }
+ str += rXmlReader.LocalName;
+
+ if (rXmlReader.HasValue)
+ str += " Value=" + rXmlReader.Value;
+
+ if (rXmlReader.NodeType == XmlNodeType.Attribute)
+ str += " QuoteChar=" + rXmlReader.QuoteChar;
+
+ DebugTrace(str, rXmlReader.Depth);
+ }
+ }
+
+ protected void Process(CXmlBase rParentNode)
+ {
+ CXmlNode rNewNode;
+
+ while (true)
+ {
+ //We want to pop if Read() returns false, aka EOF
+ if (_fReadNode)
+ {
+ if (!_rXmlReader.Read())
+ {
+ DebugTrace("Read() == false");
+ return;
+ }
+ }
+ else
+ {
+ if (!_rXmlReader.ReadAttributeValue())
+ {
+ DebugTrace("ReadAttributeValue() == false");
+ return;
+ }
+ }
+
+ DebugTrace(_rXmlReader);
+
+ //We also want to pop if we get an EndElement or EndEntity
+ if (_rXmlReader.NodeType == XmlNodeType.EndElement ||
+ _rXmlReader.NodeType == XmlNodeType.EndEntity)
+ {
+ DebugTrace("NodeType == EndElement or EndEntity");
+ return;
+ }
+
+ rNewNode = GetNewNode(_rXmlReader);
+ rNewNode._nDepth = _rXmlReader.Depth;
+
+ // Test for MixedContent and set Indent if necessary
+ if ((rParentNode.Flags & NodeFlags.MixedContent) != 0)
+ {
+ rNewNode._eFlags |= NodeFlags.MixedContent;
+ // Indent is off for all new nodes
+ }
+ else
+ {
+ rNewNode._eFlags |= NodeFlags.Indent; // Turn on Indent for current Node
+ }
+
+ // Set all Depth 0 nodes to No Mixed Content and Indent True
+ if (_rXmlReader.Depth == 0)
+ {
+ rNewNode._eFlags |= NodeFlags.Indent; // Turn on Indent
+ rNewNode._eFlags &= ~NodeFlags.MixedContent; // Turn off MixedContent
+ }
+
+ rParentNode.InsertNode(rNewNode);
+
+ //Do some special stuff based on NodeType
+ switch (_rXmlReader.NodeType)
+ {
+ case XmlNodeType.EntityReference:
+ if (_eValidationMode == ValidationType.DTD)
+ {
+ // _rXmlReader.EntityHandling = EntityHandling.ExpandEntities;
+ _rXmlReader.ResolveEntity();
+ Process(rNewNode);
+ // _rXmlReader.EntityHandling = _eEntityMode;
+ }
+ break;
+
+ case XmlNodeType.Element:
+ if (_rXmlReader.MoveToFirstAttribute())
+ {
+ do
+ {
+ CXmlAttribute rNewAttribute = new CXmlAttribute(_rXmlReader);
+ rNewNode.AddAttribute(rNewAttribute);
+
+ if (_fExpandAttributeValues)
+ {
+ DebugTrace("Attribute: " + _rXmlReader.Name);
+ _fReadNode = false;
+ Process(rNewAttribute);
+ _fReadNode = true;
+ }
+ else
+ {
+ CXmlNode rValueNode = new CXmlNode("", "", XmlNodeType.Text);
+ rValueNode._eFlags = _eDefaultFlags | NodeFlags.HasValue;
+
+ rValueNode._strValue = _rXmlReader.Value;
+
+ DebugTrace(" Value=" + rValueNode.Value, _rXmlReader.Depth + 1);
+
+ rNewAttribute.InsertNode(rValueNode);
+ }
+ } while (_rXmlReader.MoveToNextAttribute());
+ }
+
+ if ((rNewNode.Flags & NodeFlags.EmptyElement) == 0)
+ Process(rNewNode);
+
+ break;
+
+ case XmlNodeType.XmlDeclaration:
+ if (_rXmlReader is XmlTextReader)
+ {
+ _eEncoding = ((XmlTextReader)_rXmlReader).Encoding;
+ }
+#pragma warning disable 0618
+ else if (_rXmlReader is XmlValidatingReader)
+ {
+ _eEncoding = ((XmlValidatingReader)_rXmlReader).Encoding;
+ }
+#pragma warning restore 0618
+ else
+ {
+ string strValue = rNewNode.NodeValue;
+ int nPos = strValue.IndexOf("encoding");
+ if (nPos != -1)
+ {
+ int nEnd;
+
+ nPos = strValue.IndexOf("=", nPos); //Find the = sign
+ nEnd = strValue.IndexOf("\"", nPos) + 1; //Find the next " character
+ nPos = strValue.IndexOf("'", nPos) + 1; //Find the next ' character
+ if (nEnd == 0 || (nPos < nEnd && nPos > 0)) //Pick the one that's closer to the = sign
+ {
+ nEnd = strValue.IndexOf("'", nPos);
+ }
+ else
+ {
+ nPos = nEnd;
+ nEnd = strValue.IndexOf("\"", nPos);
+ }
+ string sEncodeName = strValue.Substring(nPos, nEnd - nPos);
+ DebugTrace("XMLDecl contains encoding " + sEncodeName);
+ if (sEncodeName.ToUpper() == "UCS-2")
+ {
+ sEncodeName = "unicode";
+ }
+ _eEncoding = System.Text.Encoding.GetEncoding(sEncodeName);
+ }
+ }
+ break;
+
+ case XmlNodeType.ProcessingInstruction:
+ break;
+
+ case XmlNodeType.Text:
+ if (!_fReadNode)
+ {
+ rNewNode._eFlags = _eDefaultFlags | NodeFlags.AttributeTextNode;
+ }
+ rNewNode._eFlags |= NodeFlags.MixedContent; // turn on Mixed Content for current node
+ rNewNode._eFlags &= ~NodeFlags.Indent; // turn off Indent for current node
+ rParentNode._eFlags |= NodeFlags.MixedContent; // turn on Mixed Content for Parent Node
+ break;
+
+ case XmlNodeType.Whitespace:
+ case XmlNodeType.SignificantWhitespace:
+ case XmlNodeType.CDATA:
+ rNewNode._eFlags |= NodeFlags.MixedContent; // turn on Mixed Content for current node
+ rNewNode._eFlags &= ~NodeFlags.Indent; // turn off Indent for current node
+ rParentNode._eFlags |= NodeFlags.MixedContent; // turn on Mixed Content for Parent Node
+ break;
+
+ case XmlNodeType.Comment:
+ case XmlNodeType.Notation:
+ break;
+
+ case XmlNodeType.DocumentType:
+ if (_rXmlReader.MoveToFirstAttribute())
+ {
+ do
+ {
+ CXmlAttribute rNewAttribute = new CXmlAttribute(_rXmlReader);
+ rNewNode.AddAttribute(rNewAttribute);
+
+ CXmlNode rValueNode = new CXmlNode(_rXmlReader);
+ rValueNode._strValue = _rXmlReader.Value;
+ rNewAttribute.InsertNode(rValueNode);
+ } while (_rXmlReader.MoveToNextAttribute());
+ }
+
+ break;
+
+ default:
+ _output.WriteLine("UNHANDLED TYPE, " + _rXmlReader.NodeType.ToString() + " IN Process()!");
+ break;
+ }
+ }
+ }
+
+ protected virtual CXmlNode GetNewNode(XmlReader rXmlReader)
+ {
+ return new CXmlNode(rXmlReader);
+ }
+
+ private void ValidationCallback(object sender, ValidationEventArgs args)
+ {
+ // commented by ROCHOA -- don't know where ValidationEventArgs comes from
+ // _hr = Convert.ToInt16(args.ErrorCode);
+ throw (new Exception("[" + Convert.ToString(_hr) + "] " + args.Message));
+ }
+}
+
+public class ChecksumWriter : TextWriter
+{
+ private int _nPosition = 0;
+ private Decimal _dResult = 0;
+ private Encoding _encoding;
+
+ // --------------------------------------------------------------------------------------------------
+ // Constructor
+ // --------------------------------------------------------------------------------------------------
+ public ChecksumWriter()
+ {
+ _encoding = Encoding.UTF8;
+ }
+
+ // --------------------------------------------------------------------------------------------------
+ // Properties
+ // --------------------------------------------------------------------------------------------------
+ public Decimal CheckSum
+ {
+ get { return _dResult; }
+ }
+
+ public override Encoding Encoding
+ {
+ get { return _encoding; }
+ }
+
+ // --------------------------------------------------------------------------------------------------
+ // Public methods
+ // --------------------------------------------------------------------------------------------------
+ override public void Write(String str)
+ {
+ int i;
+ int m;
+
+ m = str.Length;
+ for (i = 0; i < m; i++)
+ {
+ Write(str[i]);
+ }
+ }
+
+ override public void Write(Char[] rgch)
+ {
+ int i;
+ int m;
+
+ m = rgch.Length;
+ for (i = 0; i < m; i++)
+ {
+ Write(rgch[i]);
+ }
+ }
+
+ override public void Write(Char[] rgch, Int32 iOffset, Int32 iCount)
+ {
+ int i;
+ int m;
+
+ m = iOffset + iCount;
+ for (i = iOffset; i < m; i++)
+ {
+ Write(rgch[i]);
+ }
+ }
+
+ override public void Write(Char ch)
+ {
+ _dResult += Math.Round((Decimal)(ch / (_nPosition + 1.0)), 10);
+ _nPosition++;
+ }
+
+ public void Close()
+ {
+ _nPosition = 0;
+ _dResult = 0;
+ }
+}
+
+public class BufferWriter : TextWriter
+{
+ private int _nBufferSize = 0;
+ private int _nBufferUsed = 0;
+ private int _nBufferGrow = 1024;
+ private Char[] _rgchBuffer = null;
+ private Encoding _encoding;
+
+ // --------------------------------------------------------------------------------------------------
+ // Constructor
+ // --------------------------------------------------------------------------------------------------
+ public BufferWriter()
+ {
+ _encoding = Encoding.UTF8;
+ }
+
+ // --------------------------------------------------------------------------------------------------
+ // Properties
+ // --------------------------------------------------------------------------------------------------
+ override public string ToString()
+ {
+ return new String(_rgchBuffer, 0, _nBufferUsed);
+ }
+
+ public override Encoding Encoding
+ {
+ get { return _encoding; }
+ }
+
+ // --------------------------------------------------------------------------------------------------
+ // Public methods
+ // --------------------------------------------------------------------------------------------------
+ override public void Write(String str)
+ {
+ int i;
+ int m;
+
+ m = str.Length;
+ for (i = 0; i < m; i++)
+ {
+ Write(str[i]);
+ }
+ }
+
+ override public void Write(Char[] rgch)
+ {
+ int i;
+ int m;
+
+ m = rgch.Length;
+ for (i = 0; i < m; i++)
+ {
+ Write(rgch[i]);
+ }
+ }
+
+ override public void Write(Char[] rgch, Int32 iOffset, Int32 iCount)
+ {
+ int i;
+ int m;
+
+ m = iOffset + iCount;
+ for (i = iOffset; i < m; i++)
+ {
+ Write(rgch[i]);
+ }
+ }
+
+ override public void Write(Char ch)
+ {
+ if (_nBufferUsed == _nBufferSize)
+ {
+ Char[] rgchTemp = new Char[_nBufferSize + _nBufferGrow];
+ for (_nBufferUsed = 0; _nBufferUsed < _nBufferSize; _nBufferUsed++)
+ rgchTemp[_nBufferUsed] = _rgchBuffer[_nBufferUsed];
+ _rgchBuffer = rgchTemp;
+ _nBufferSize += _nBufferGrow;
+ if (_nBufferGrow < (1024 * 1024))
+ _nBufferGrow *= 2;
+ }
+ _rgchBuffer[_nBufferUsed++] = ch;
+ }
+
+ public void Close()
+ {
+ //Set nBufferUsed to 0, so we start writing from the beginning of the buffer.
+ _nBufferUsed = 0;
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTArgumentList.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTArgumentList.cs
new file mode 100644
index 0000000000..4b58aaa9bd
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTArgumentList.cs
@@ -0,0 +1,3457 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.Collections.Generic;
+//using System.Dynamic;
+using System.IO;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.Xml.Tests
+{
+ /***********************************************************/
+ /* XsltArgumentList.GetParam */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltArgumentList - GetParam", Desc = "Get Param Test Cases")]
+ public class CArgIntegrity : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgIntegrity(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation(Desc = "Basic Verification Test", Pri = 0)]
+ [InlineData()]
+ [Theory]
+ public void GetParam1()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+ return;
+ }
+
+ private static string s_typeXml = "<order></order>";
+
+ private static string s_typeXsl = @"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+ <xsl:param name='param'/>
+ <xsl:template match='/'>
+ <order>
+ <param><xsl:value-of select='$param'/></param>
+ </order>
+ </xsl:template>
+</xsl:stylesheet>";
+
+ private static void WriteFiles(string input, string output)
+ {
+ using (XmlWriter w = XmlWriter.Create(output))
+ {
+ using (XmlReader r = XmlReader.Create(new StringReader(input)))
+ {
+ w.WriteNode(r, false);
+ }
+ }
+ }
+
+ private static void WriteXmlAndXslFiles()
+ {
+ WriteFiles(s_typeXml, "type.xml");
+ WriteFiles(s_typeXsl, "type.xsl");
+ }
+
+ //[Variation(Desc = "Tuple.XsltArgumentList.AddParam/AddExtensionObject", Param = 1)]
+ [InlineData(1)]
+ //[Variation(Desc = "DynamicObject.XsltArgumentList.AddParam/AddExtensionObject", Param = 2)]
+ //[InlineData(2)]
+ //[Variation(Desc = "Guid.XsltArgumentList.AddParam/AddExtensionObject", Param = 3)]
+ [InlineData(3)]
+ //[Variation(Desc = "Dictionary.XsltArgumentList.AddParam/AddExtensionObject", Param = 4)]
+ [InlineData(4)]
+ [Theory]
+ public void var_types(int param)
+ {
+ WriteXmlAndXslFiles();
+
+ object t = null;
+ switch (param)
+ {
+ case 1: t = Tuple.Create(1, "Melitta", 7.5); break;
+ //case 2: t = new TestDynamicObject(); break;
+ case 3: t = new Guid(); break;
+ case 4: t = new Dictionary<string, object>(); break;
+ }
+ _output.WriteLine(t.ToString());
+
+#pragma warning disable 0618
+ XslTransform xslt = new XslTransform();
+#pragma warning restore 0618
+ xslt.Load("type.xsl");
+
+ XsltArgumentList xslArg = new XsltArgumentList();
+ xslArg.AddParam("param", "", t);
+ xslArg.AddExtensionObject("", t);
+
+ XPathDocument xpathDom = new XPathDocument("type.xml");
+ using (StringWriter sw = new StringWriter())
+ {
+ xslt.Transform(xpathDom, xslArg, sw);
+ _output.WriteLine(sw.ToString());
+ }
+ return;
+ }
+
+ //public class TestDynamicObject : DynamicObject
+ //{
+ // public dynamic GetDynamicObject()
+ // {
+ // return new Dictionary<string, object>();
+ // }
+ //}
+
+ //[Variation("Param name is null")]
+ [InlineData()]
+ [Theory]
+ public void GetParam2()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.GetParam(null, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for null param name {0}", retObj);
+ Assert.True(false);
+ }
+ else
+ return;
+ }
+
+ //[Variation("Param name is empty string")]
+ [InlineData()]
+ [Theory]
+ public void GetParam3()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.GetParam(szEmpty, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for empty string param name: {0}", retObj);
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Param name is non existent")]
+ [InlineData()]
+ [Theory]
+ public void GetParam4()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.GetParam("RandomName", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for non-existent parameter name: {0}", retObj);
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Invalid Param name")]
+ [InlineData()]
+ [Theory]
+ public void GetParam5()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.GetParam(szInvalid, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for an invalid param name");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Very Long Param")]
+ [InlineData()]
+ [Theory]
+ public void GetParam6()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam(szLongString, szEmpty, "Test6");
+ retObj = m_xsltArg.GetParam(szLongString, szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test6", retObj);
+ if (retObj.ToString() != "Test6")
+ Assert.True(false);
+ return;
+ }
+
+ //[Variation("Namespace URI = null")]
+ [InlineData()]
+ [Theory]
+ public void GetParam7()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.GetParam("myArg1", null);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for null namespace System.Xml.Tests");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Namespace URI is empty string - Bug 200998")]
+ [InlineData()]
+ [Theory]
+ public void GetParam8()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test8");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test8", retObj);
+ if (retObj.ToString() != "Test8")
+ Assert.True(false);
+ return;
+ }
+
+ //[Variation("Namespace URI non-existent")]
+ [InlineData()]
+ [Theory]
+ public void GetParam9()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test9");
+ retObj = m_xsltArg.GetParam("myArg1", "http://www.microsoft.com");
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not retrieve a null value for non-existent uri");
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", "http://www.msn.com", "Test1");
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not retrieve a null value for non-existent uri");
+ Assert.True(false);
+ }
+
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not retrieve a null value for non-existent uri");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Very long namespace System.Xml.Tests")]
+ [InlineData()]
+ [Theory]
+ public void GetParam10()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szLongNS, "Test10");
+ retObj = m_xsltArg.GetParam("myArg1", szLongNS);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test10", retObj);
+ if (retObj.ToString() != "Test10")
+ Assert.True(false);
+ return;
+ }
+
+ /*
+ * This test is no more valid.
+ * MDAC Bug # 88407 fix now allows ANY characters in URI
+ //[Variation("Invalid Namespace URI")]
+ [InlineData()]
+ [Theory]
+ public void GetParam11()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam("myArg1", szInvalid, "Test11");
+ }
+ catch (System.UriFormatException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw System.UriFormatException for invalid namespace System.Xml.Tests");
+ Assert.True(false);
+ }
+ */
+
+ //[Variation("Different Data Types")]
+ [InlineData()]
+ [Theory]
+ public void GetParam12()
+ {
+ m_xsltArg = new XsltArgumentList();
+ String obj = "0.00";
+
+ // string
+ m_xsltArg.AddParam("myArg1", szEmpty, obj);
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "0.00", retObj);
+ if (retObj.ToString() != "0.00")
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", "0.00", "string");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ //int -- check conversions and value for original object and returned object
+ int j = 8;
+ int i = 8;
+ m_xsltArg.AddParam("myArg2", szEmpty, i);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value:{1}", i, retObj);
+ if (!i.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", i, "int");
+ Assert.True(false);
+ }
+
+ if (i.GetType() != j.GetType())
+ Assert.True(false);
+
+ Boolean bF = (1 == 0);
+ m_xsltArg.AddParam("myArg3", szEmpty, bF);
+ retObj = m_xsltArg.GetParam("myArg3", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bF.ToString(), retObj);
+ if (!bF.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", bF.ToString(), "boolean");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ Boolean bT = (1 == 1);
+ m_xsltArg.AddParam("myArg4", szEmpty, bT);
+ retObj = m_xsltArg.GetParam("myArg4", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bT.ToString(), retObj);
+ if (!bT.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", bT.ToString(), "boolean");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ XPathDocument xd = new XPathDocument(FullFilePath("fish.xml"));
+
+ m_xsltArg.AddParam("myArg5", szEmpty, ((IXPathNavigable)xd).CreateNavigator());
+ retObj = m_xsltArg.GetParam("myArg5", szEmpty);
+ if (retObj == null)
+ {
+ _output.WriteLine("Failed to add/get a value of type {1}", "XPathNavigator");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Case Sensitivity")]
+ [InlineData()]
+ [Theory]
+ public void GetParam13()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myarg1", szEmpty);
+ if (retObj != null)
+ Assert.True(false);
+ retObj = m_xsltArg.GetParam("myArg1 ", szEmpty);
+ if (retObj != null)
+ Assert.True(false);
+ retObj = m_xsltArg.GetParam("myArg", szEmpty);
+ if (retObj != null)
+ Assert.True(false);
+
+ return;
+ }
+
+ //[Variation("Whitespace")]
+ [InlineData()]
+ [Theory]
+ public void GetParam14()
+ {
+ int i = 1;
+ m_xsltArg = new XsltArgumentList();
+
+ foreach (String str in szWhiteSpace)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, "Test" + str);
+ retObj = m_xsltArg.GetParam("myArg" + i, szEmpty);
+ if (retObj.ToString() != "Test" + str)
+ {
+ _output.WriteLine("Error processing {0} test for whitespace arg in first set", i);
+ Assert.True(false);
+ }
+ i++;
+ }
+
+ foreach (String str in szWhiteSpace)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, "Test"); // dont add whitespace to name here since addparam would throw
+ retObj = m_xsltArg.GetParam("myArg" + str, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Error processing {0} test for whitespace arg in second set. Returned object is not null.", i);
+ Assert.True(false);
+ }
+ i++;
+ }
+ return;
+ }
+
+ //[Variation("Call After Param has been removed")]
+ [InlineData()]
+ [Theory]
+ public void GetParam15()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+
+ if (retObj != null)
+ Assert.True(false);
+ return;
+ }
+
+ //[Variation("Call multiple Times")]
+ [InlineData()]
+ [Theory]
+ public void GetParam16()
+ {
+ m_xsltArg = new XsltArgumentList();
+ int i = 0;
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test16");
+ for (i = 0; i < 200; i++)
+ {
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj.ToString() != "Test16")
+ {
+ _output.WriteLine("Failed after retrieving {0} times", i);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test16", retObj);
+ Assert.True(false);
+ }
+ }
+ _output.WriteLine("Retrievied {0} times", i);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ return;
+ }
+
+ //[Variation("Using XSL namespace")]
+ [InlineData()]
+ [Theory]
+ public void GetParam17()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test17");
+
+ retObj = m_xsltArg.GetParam("myArg3", szDefaultNS);
+ if (retObj != null)
+ {
+ _output.WriteLine("Return a non-null value when retrieving Param with namespace {0}", szXslNS);
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Resolving conflicts with variables with different namespaces")]
+ [InlineData()]
+ [Theory]
+ public void GetParam18()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+
+ m_xsltArg.AddParam("myArg1", "http://www.msn.com", "Test2");
+ retObj = m_xsltArg.GetParam("myArg1", "http://www.msn.com");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test2", retObj);
+
+ if (retObj.ToString() != "Test2")
+ Assert.True(false);
+
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Retrieve Original Value:{0}\nActual Retrieved Value: {1}", "Test1", retObj);
+
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+ return;
+ }
+
+ //[Variation("Namespace AND param = null")]
+ [InlineData()]
+ [Theory]
+ public void GetParam19()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.GetParam(null, null);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for null parameter name");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Data Types - Of type Double ")]
+ [InlineData()]
+ [Theory]
+ public void GetParamDoubles()
+ {
+ double d1 = double.PositiveInfinity;
+ double d2 = double.NegativeInfinity;
+ double d3 = double.NaN;
+ double d4 = 2.000001;
+ double d5 = 0.00;
+ double d6 = double.MaxValue;
+ double d7 = double.MinValue;
+
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, d1);
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d1, retObj);
+ if (!double.IsPositiveInfinity((double)retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d1);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, d2);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d2, retObj);
+ if (!double.IsNegativeInfinity((double)retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d2);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg3", szEmpty, d3);
+ retObj = m_xsltArg.GetParam("myArg3", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d3, retObj);
+ if (!double.IsNaN((double)retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d3);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg4", szEmpty, d4);
+ retObj = m_xsltArg.GetParam("myArg4", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d4, retObj);
+ if (!d4.Equals((double)retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d4);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg5", szEmpty, d5);
+ retObj = m_xsltArg.GetParam("myArg5", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d5, retObj);
+ if (!d5.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d5);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg6", szEmpty, d6);
+ retObj = m_xsltArg.GetParam("myArg6", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d6, retObj);
+ if (!d6.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d6);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg7", szEmpty, d7);
+ retObj = m_xsltArg.GetParam("myArg7", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d7, retObj);
+ if (!d7.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0}", d7);
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+ return;
+ }
+ }
+
+ /***********************************************************/
+ /* XsltArgumentList.GetExtensionObject */
+ /***********************************************************/
+
+ // TODO: Fix security issue
+ ////[TestCase(Name="XsltArgumentList - GetExtensionObject", Desc="XsltArgumentList.GetExtensionObject")]
+
+ //public class CArgGetExtObj : XsltApiTestCaseBase
+ //{
+ // //[Variation(Desc="Basic Verification Test",Pri=0)]
+ // [InlineData()]
+ // public int GetExtObject1()
+ // {
+ // MyObject obj = new MyObject(1);
+ // m_xsltArg = new XsltArgumentList();
+
+ // m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ // retObj = m_xsltArg.GetExtensionObject(szDefaultNS);
+
+ // _output.WriteLine("Retrieved value: {0}", ((MyObject)retObj).MyValue());
+ // if(((MyObject)retObj).MyValue() != obj.MyValue())
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different");
+ // Assert.True(false);
+ // }
+
+ // if((LoadXSL("MyObjectDef.xsl") == TEST_PASS) && (Transform_ArgList("fruits.xml") == TEST_PASS) &&
+ // (CheckResult(430.402026847)== TEST_PASS))
+ // return;
+ // else
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Namespace URI = null")]
+ // [InlineData()]
+ // public int GetExtObject2()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+
+ // try
+ // {
+ // m_xsltArg.GetExtensionObject(null);
+ // }
+ // catch(System.ArgumentNullException)
+ // {
+ // return;
+ // }
+ // _output.WriteLine("ArgumentNullException not thrown for null namespace System.Xml.Tests");
+ // return;
+ // }
+
+ // //[Variation("Namespace URI is empty string")]
+ // [InlineData()]
+ // public int GetExtObject3()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+
+ // try
+ // {
+ // retObj = m_xsltArg.GetExtensionObject(szEmpty);
+ // }
+ // catch(Exception e)
+ // {
+ // _output.WriteLine(e.ToString());
+ // Assert.True(false);
+ // }
+
+ // if((LoadXSL("showParam.xsl") == TEST_PASS) && (Transform_ArgList("fruits.xml") == TEST_PASS) &&
+ // (CheckResult(466.5112789241)== TEST_PASS))
+ // return;
+ // else
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Namespace URI non-existent")]
+ // [InlineData()]
+ // public int GetExtObject4()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+
+ // retObj = m_xsltArg.GetExtensionObject(szDefaultNS);
+
+ // if(retObj != null)
+ // {
+ // _output.WriteLine("Did not return a NULL value for a non-existent URI");
+ // Assert.True(false);
+ // }
+ // try
+ // {
+ // if((LoadXSL("MyObjectDef.xsl") == TEST_PASS))
+ // Transform_ArgList("fruits.xml");
+ // }
+ // catch(System.Xml.Xsl.XsltException)
+ // {
+ // return;
+ // }
+ // _output.WriteLine("Did not throw exception for an invalid transform");
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Very long namespace System.Xml.Tests")]
+ // [InlineData()]
+ // public int GetExtObject5()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+ // MyObject obj = new MyObject(5);
+
+ // m_xsltArg.AddExtensionObject(szLongNS, obj);
+ // retObj = m_xsltArg.GetExtensionObject(szLongNS);
+
+ // if(((MyObject)retObj).MyValue() != obj.MyValue())
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different");
+ // Assert.True(false);
+ // }
+
+ // if((LoadXSL("MyObjectLongNS.xsl") == TEST_PASS) && (Transform_ArgList("fruits.xml") == TEST_PASS) &&
+ // (CheckResult(522.0563223871)== TEST_PASS))
+ // return;
+ // else
+ // Assert.True(false);
+ // }
+
+ // /*
+ // * This test is no more valid.
+ // * MDAC Bug # 88407 fix now allows ANY characters in URI
+ // //[Variation("Invalid namespace System.Xml.Tests")]
+ // [InlineData()]
+ // public int GetExtObject6()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+ // MyObject obj = new MyObject(6);
+
+ // try
+ // {
+ // m_xsltArg.AddExtensionObject(szInvalid, obj);
+ // }
+ // catch (System.UriFormatException)
+ // {
+ // return;
+ // }
+ // _output.WriteLine("Did not throw System.UriFormatException for invalid namespace System.Xml.Tests");
+ // Assert.True(false);
+ // }
+ // */
+
+ // //[Variation("Different Data Types")]
+ // [InlineData()]
+ // public int GetExtObject7()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+ // String obj = "0.00";
+
+ // // string
+ // m_xsltArg.AddExtensionObject("myArg1", obj);
+ // retObj = m_xsltArg.GetExtensionObject("myArg1");
+ // _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "0.00", retObj);
+ // if( retObj.ToString() != "0.00")
+ // {
+ // _output.WriteLine("Failed to add/get a value for {0} of type {1}", "0.00", "string");
+ // _output.WriteLine("Retrieved: {0} ", retObj);
+ // Assert.True(false);
+ // }
+
+ // int i = 8;
+
+ // m_xsltArg.AddExtensionObject("myArg2", i);
+ // retObj = m_xsltArg.GetExtensionObject("myArg2");
+ // _output.WriteLine("Added Value:{0}\nRetrieved Value:{1}", i, retObj);
+ // if(!i.Equals(retObj))
+ // {
+ // _output.WriteLine("Failed to add/get a value for {0} with conversion from int to double", i);
+ // _output.WriteLine("Retrieved: {0}", retObj.ToString());
+ // Assert.True(false);
+ // }
+
+ // //must also be same instance!!!
+ // if(i != (int)retObj)
+ // Assert.True(false);
+
+ // Boolean bF = (1==0);
+
+ // m_xsltArg.AddExtensionObject("myArg3", bF);
+ // retObj = m_xsltArg.GetExtensionObject("myArg3");
+ // _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bF.ToString(), retObj);
+ // if( !bF.Equals(retObj))
+ // {
+ // _output.WriteLine("Failed to add/get a value for {0} of type {1}", bF.ToString(), "boolean");
+ // _output.WriteLine("Retrieved: {0} ", retObj);
+ // Assert.True(false);
+ // }
+
+ // Boolean bT = (1==1);
+
+ // m_xsltArg.AddExtensionObject("myArg4", bT);
+ // retObj = m_xsltArg.GetExtensionObject("myArg4");
+ // _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bT.ToString(), retObj);
+ // if( !bT.Equals(retObj))
+ // {
+ // _output.WriteLine("Failed to add/get a value for {0} of type {1}", bT.ToString(), "boolean");
+ // _output.WriteLine("Retrieved: {0} ", retObj);
+ // Assert.True(false);
+ // }
+ // return;
+ // }
+
+ // //[Variation("Case sensitivity")]
+ // [InlineData()]
+ // public int GetExtObject8()
+ // {
+ // MyObject obj = new MyObject(8);
+ // m_xsltArg = new XsltArgumentList();
+
+ // m_xsltArg.AddExtensionObject("urn:my-object", obj);
+
+ // retObj = m_xsltArg.GetExtensionObject("urn:my-object");
+ // if(((MyObject)retObj).MyValue() != obj.MyValue())
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different");
+ // Assert.True(false);
+ // }
+
+ // retObj = m_xsltArg.GetExtensionObject("URN:MY-OBJECT");
+ // if(retObj != null)
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different for URN:MY-OBJECT");
+ // Assert.True(false);
+ // }
+
+ // retObj = m_xsltArg.GetExtensionObject("urn:My-Object");
+ // if(retObj != null)
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different for urn:My-Object");
+ // Assert.True(false);
+ // }
+
+ // retObj = m_xsltArg.GetExtensionObject("urn-my:object");
+ // if(retObj != null)
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different for urn-my:object");
+ // Assert.True(false);
+ // }
+
+ // if((LoadXSL("MyObjectDef.xsl") == TEST_PASS) && (Transform_ArgList("fruits.xml") == TEST_PASS) &&
+ // (CheckResult(430.402026847)== TEST_PASS))
+ // return;
+ // else
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Whitespace")]
+ // [InlineData()]
+ // public int GetExtObject9()
+ // {
+ // int i=1;
+ // m_xsltArg = new XsltArgumentList();
+
+ // foreach(String str in szWhiteSpace)
+ // {
+ // MyObject obj = new MyObject(i);
+
+ // m_xsltArg.AddExtensionObject(szDefaultNS + str, obj);
+ // retObj = m_xsltArg.GetExtensionObject(szDefaultNS + str);
+ // if(((MyObject)retObj).MyValue() != i)
+ // {
+ // _output.WriteLine("Error processing {0} test for whitespace arg", i);
+ // Assert.True(false);
+ // }
+ // i++;
+ // }
+
+ // try
+ // {
+ // if((LoadXSL("MyObjectDef.xsl") == TEST_PASS))
+ // Transform_ArgList("fruits.xml");
+ // }
+ // catch(System.Xml.Xsl.XsltException)
+ // {
+ // return;
+ // }
+ // _output.WriteLine("Did not throw expected exception: System.Xml.Xsl.XsltException");
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Call after object has been removed")]
+ // [InlineData()]
+ // public int GetExtObject10()
+ // {
+ // MyObject obj = new MyObject(10);
+ // m_xsltArg = new XsltArgumentList();
+
+ // m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ // m_xsltArg.RemoveExtensionObject(szDefaultNS);
+ // retObj = m_xsltArg.GetExtensionObject(szDefaultNS);
+
+ // if(retObj != null)
+ // {
+ // _output.WriteLine("Did not retrieve a NULL value for a non-existent object returned");
+ // Assert.True(false);
+ // }
+
+ // try
+ // {
+ // if((LoadXSL("MyObjectDef.xsl") == TEST_PASS))
+ // Transform_ArgList("fruits.xml");
+ // }
+ // catch(System.Xml.Xsl.XsltException)
+ // {
+ // return;
+ // }
+ // _output.WriteLine("Did not throw expected exception: System.Xml.Xsl.XsltException");
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Call multiple times")]
+ // [InlineData()]
+ // public int GetExtObject11()
+ // {
+ // MyObject obj = new MyObject(11);
+ // m_xsltArg = new XsltArgumentList();
+
+ // m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+
+ // for(int i=0; i < 500; i++)
+ // {
+ // retObj = m_xsltArg.GetExtensionObject(szDefaultNS);
+ // if(((MyObject)retObj).MyValue() != obj.MyValue())
+ // {
+ // _output.WriteLine("Set and retrieved value appear to be different after {i} tries", i);
+ // Assert.True(false);
+ // }
+ // }
+ // if((LoadXSL("MyObjectDef.xsl") == TEST_PASS) && (Transform_ArgList("fruits.xml") == TEST_PASS) &&
+ // (CheckResult(430.402026847)== TEST_PASS))
+ // return;
+ // else
+ // Assert.True(false);
+ // }
+
+ // //[Variation("Using XSL Namespace")]
+ // [InlineData()]
+ // public int GetExtObject12()
+ // {
+ // m_xsltArg = new XsltArgumentList();
+
+ // retObj = m_xsltArg.GetExtensionObject(szDefaultNS);
+ // if(retObj != null)
+ // {
+ // _output.WriteLine("Did not retrieve null value when using namespace {0}", szXslNS);
+ // Assert.True(false);
+ // }
+ // return;
+ // }
+ //}
+
+ /***********************************************************/
+ /* XsltArgumentList.AddParam */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltArgumentList - AddParam : Reader, Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CArgAddParam : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgAddParam(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation(Desc = "Basic Verification Test", Pri = 0)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam1()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.6003003605) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Param = null")]
+ [InlineData()]
+ [Theory]
+ public void AddParam2()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam(null, szEmpty, "Test1");
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("System.ArgumentNullException not thrown for adding null param");
+ Assert.True(false);
+ }
+
+ //[Variation("Param name is empty string")]
+ [InlineData()]
+ [Theory]
+ public void AddParam3()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam(szEmpty, szEmpty, "Test1");
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("System.ArgumentNullException not thrown for param name empty string");
+ Assert.True(false);
+ }
+
+ //[Variation("Very Long Param Name")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam4()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam(szLongString, szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam(szLongString, szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ if ((LoadXSL("showParamLongName.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(383.8692240713) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Invalid Param name")]
+ [InlineData()]
+ [Theory]
+ public void AddParam5()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam(szInvalid, szEmpty, "Test1");
+ }
+ catch (System.Xml.XmlException)
+ {
+ return;
+ }
+ _output.WriteLine("System.Xml.XmlException not thrown for invalid param name");
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI = null")]
+ [InlineData()]
+ [Theory]
+ public void AddParam6()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam("myArg1", null, "Test1");
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("System.ArgumentNullException not thrown for null namespace System.Xml.Tests");
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI is empty string")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam7()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test7");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test7")
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.7055635184) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Very long namespace System.Xml.Tests")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam8()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szLongNS, "Test8");
+ retObj = m_xsltArg.GetParam("myArg1", szLongNS);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test8")
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ /*
+ * This test is no more valid.
+ * MDAC Bug # 88407 fix now allows ANY characters in URI
+ //[Variation("Invalid Namespace URI")]
+ [InlineData()]
+ [Theory]
+ public void AddParam9()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam("myArg1", szInvalid, "Test1");
+ }
+ catch (System.UriFormatException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw System.UriFormatException for invalid namespace System.Xml.Tests");
+ Assert.True(false);
+ }
+ */
+
+ //[Variation("Objects as different Data Types")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam10()
+ {
+ m_xsltArg = new XsltArgumentList();
+ MyObject m = new MyObject(10, _output);
+
+ m_xsltArg.AddParam("myArg1", szEmpty, m);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(473.4007803959) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Setting a param that already exists")]
+ [InlineData()]
+ [Theory]
+ public void AddParam11()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test2");
+ try
+ {
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw System.ArgumentException for adding a param that already exists");
+ Assert.True(false);
+ }
+
+ //[Variation("Object with same name, different namespace System.Xml.Tests")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam12()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myArg1", "http://www.msn.com", "Test2");
+ retObj = m_xsltArg.GetParam("myArg1", "http://www.msn.com");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test2", retObj);
+
+ if (retObj.ToString() != "Test2")
+ Assert.True(false);
+
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Retrieve Original Value:{0}\nActual Retrieved Value: {1}", "Test1", retObj);
+
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.6003003605) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Object with same namespace System.Xml.Tests, different name")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam13()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myArg2", szEmpty, "Test2");
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test2", retObj);
+
+ if (retObj.ToString() != "Test2")
+ Assert.True(false);
+
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Retrieve Original Value:{0}\nActual Retrieved Value: {1}", "Test1", retObj);
+
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(449.000354515) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Case Sensitivity")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam14()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myarg1", szEmpty, "Test2");
+ retObj = m_xsltArg.GetParam("myarg1", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test2", retObj);
+ if (retObj.ToString() != "Test2")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myArg2", szEmpty, "Test2");
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test2", retObj);
+ if (retObj.ToString() != "Test2")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myarg3", szEmpty, "Test3");
+ retObj = m_xsltArg.GetParam("myarg3", szEmpty);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test3", retObj);
+ if (retObj.ToString() != "Test3")
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(449.000354515) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Object is null")]
+ [InlineData()]
+ [Theory]
+ public void AddParam15()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddParam("myArg1", szEmpty, null);
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("System.ArgumentNullException not thrown for null object");
+ Assert.True(false);
+ }
+
+ //[Variation("Add/remove object many times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam16()
+ {
+ m_xsltArg = new XsltArgumentList();
+ String obj = "Test";
+
+ for (int i = 0; i < 200; i++)
+ {
+ m_xsltArg.AddParam("myArg2", szEmpty, obj + i);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj.ToString() != ("Test" + i))
+ {
+ _output.WriteLine("Failed to add/remove iteration {0}", i);
+ Assert.True(false);
+ }
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ }
+
+ for (int i = 0; i < 200; i++)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, obj + i);
+ retObj = m_xsltArg.GetParam("myArg" + i, szEmpty);
+ if (retObj.ToString() != (obj + i))
+ {
+ _output.WriteLine("Failed in 2nd part to add/remove iteration {0}", i);
+ Assert.True(false);
+ }
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ }
+
+ for (int i = 0; i < 200; i++)
+ {
+ m_xsltArg.RemoveParam("myArg" + i, szEmpty);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, obj + "1");
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj.ToString() != ("Test1"))
+ Assert.True(false);
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(458.7752486264) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Whitespace in URI and param")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam17()
+ {
+ int i = 1;
+ int errCount = 0;
+ m_xsltArg = new XsltArgumentList();
+
+ foreach (String str in szWhiteSpace)
+ {
+ try
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, "Test" + str);
+ }
+ catch (System.Xml.XmlException)
+ {
+ _output.WriteLine("Improperly reported an exception for a whitespace value");
+ Assert.True(false);
+ }
+ i++;
+ }
+
+ foreach (String str in szWhiteSpace)
+ {
+ try
+ {
+ m_xsltArg.AddParam("myArg" + str, szEmpty, "Test");
+ }
+ catch (System.Xml.XmlException)
+ {
+ errCount++;
+ }
+ finally
+ {
+ errCount--;
+ }
+ }
+
+ if (errCount != 0)
+ {
+ _output.WriteLine("At least one whitespace test failed.");
+ Assert.True(false);
+ }
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(420.7138852814) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Adding many objects")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam18()
+ {
+ m_xsltArg = new XsltArgumentList();
+ String obj = "Test";
+
+ for (int i = 1; i < 7; i++)
+ {
+ m_xsltArg.AddParam("myArg" + +i, szEmpty, obj + i);
+ retObj = m_xsltArg.GetParam("myArg" + i, szEmpty);
+ if (retObj.ToString() != ("Test" + i))
+ Assert.True(false);
+ }
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(413.6341271694) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Add same object many times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam19()
+ {
+ m_xsltArg = new XsltArgumentList();
+ String obj = "Test";
+
+ for (int i = 0; i < 300; i++)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, obj + "1");
+ retObj = m_xsltArg.GetParam("myArg" + i, szEmpty);
+ if (retObj.ToString() != ("Test" + "1"))
+ {
+ _output.WriteLine("Failed to add {0}", "myArg" + i);
+ Assert.True(false);
+ }
+ m_xsltArg.RemoveParam("myArg" + i, szEmpty);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj.ToString() != ("Test1"))
+ Assert.True(false);
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(458.7752486264) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Using Different XSLT namespace")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddParam20()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", "urn:" + szXslNS, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", "urn:" + szXslNS);
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myArg2", "urn:tmp", "Test2");
+ retObj = m_xsltArg.GetParam("myArg2", "urn:tmp");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test2", retObj);
+ if (retObj.ToString() != "Test2")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myArg3", "urn:my-object", "Test3");
+ retObj = m_xsltArg.GetParam("myArg3", "urn:my-object");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test3", retObj);
+ if (retObj.ToString() != "Test3")
+ Assert.True(false);
+
+ m_xsltArg.AddParam("myArg4", "urn:MY-OBJECT", "Test4");
+ retObj = m_xsltArg.GetParam("myArg4", "urn:MY-OBJECT");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test4", retObj);
+ if (retObj.ToString() != "Test4")
+ Assert.True(false);
+
+ if ((LoadXSL("showParamNS.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(509.315418596) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Using Default XSLT namespace - Bug305503")]
+ [InlineData()]
+ [Theory]
+ public void AddParam21()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("myArg1", szXslNS, "Test1");
+ return;
+ }
+
+ //[Variation("Parameters should not be cached")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject32()
+ {
+ if (LoadXSL("test_Param.xsl") == 1)
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("myParam1", szEmpty, "first");
+
+ // Transform once
+ if ((Transform_ArgList("foo.xml") == 1) && (CheckResult(383.6292620645) == 1))
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("myParam1", szEmpty, "second");
+
+ // Transform again to make sure that parameter from first transform are not cached
+ if ((Transform_ArgList("foo.xml") == 1) && (CheckResult(384.9801823644) == 1))
+ return;
+ }
+ }
+ Assert.True(false);
+ }
+ }
+
+ /***************************************************************/
+ /* XsltArgumentList.AddParam Misc Tests */
+ /*Bug 268515 - Global param value is overridden by local value */
+ /***************************************************************/
+
+ //Testcases with Reader outputs are skipped because they don't write to an output file
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddParam Misc : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CArgAddParamMisc : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgAddParamMisc(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //All the below variations, there is no parameter sent and default global value is set
+
+ //global param is xsl:param local param is xsl:param
+ //[Variation(id = 1, Pri = 2, Desc = "No param sent, global param used, local param exists with a default value", Params = new object[] { "AddParameterA1.xsl", "default local" })]
+ [InlineData("AddParameterA1.xsl", "default local")]
+ //[Variation(id = 2, Pri = 2, Desc = "No param sent, global param used, local param exists with no default value", Params = new object[] { "AddParameterA2.xsl", "" })]
+ [InlineData("AddParameterA2.xsl", "")]
+ //[Variation(id = 3, Pri = 2, Desc = "No param sent, global param used, local param doesn't exist but reference to param exists", Params = new object[] { "AddParameterA3.xsl", "default global" })]
+ [InlineData("AddParameterA3.xsl", "default global")]
+ //[Variation(id = 4, Pri = 2, Desc = "No param sent, global param used, local param exists with a default value and with-param sends a value", Params = new object[] { "AddParameterA4.xsl", "with-param" })]
+ [InlineData("AddParameterA4.xsl", "with-param")]
+ //[Variation(id = 5, Pri = 2, Desc = "No param sent, global param used, local param exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterA5.xsl", "" })]
+ [InlineData("AddParameterA5.xsl", "")]
+ //[Variation(id = 6, Pri = 2, Desc = "No param sent, global param used, local param doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterA6.xsl", "default global" })]
+ [InlineData("AddParameterA6.xsl", "default global")]
+ //[Variation(id = 7, Pri = 2, Desc = "No param sent, global param used, local param doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterA7.xsl", "default global" })]
+ [InlineData("AddParameterA7.xsl", "default global")]
+
+ //global param is xsl:variable local param is xsl:param
+ //[Variation(id = 8, Pri = 2, Desc = "No param sent, global variable used, local param exists with a default value", Params = new object[] { "AddParameterDA1.xsl", "default local" })]
+ [InlineData("AddParameterDA1.xsl", "default local")]
+ //[Variation(id = 9, Pri = 2, Desc = "No param sent, global variable used, local param exists with no default value", Params = new object[] { "AddParameterDA2.xsl", "" })]
+ [InlineData("AddParameterDA2.xsl", "")]
+ //[Variation(id = 10, Pri = 2, Desc = "No param sent, global variable used, local param doesn't exist but reference to param exists", Params = new object[] { "AddParameterDA3.xsl", "default global" })]
+ [InlineData("AddParameterDA3.xsl", "default global")]
+ //[Variation(id = 11, Pri = 2, Desc = "No param sent, global variable used, local param exists with a default value and with-param sends a value", Params = new object[] { "AddParameterDA4.xsl", "with-param" })]
+ [InlineData("AddParameterDA4.xsl", "with-param")]
+ //[Variation(id = 12, Pri = 2, Desc = "No param sent, global variable used, local param exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterDA5.xsl", "" })]
+ [InlineData("AddParameterDA5.xsl", "")]
+ //[Variation(id = 13, Pri = 2, Desc = "No param sent, global variable used, local param doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterDA6.xsl", "default global" })]
+ [InlineData("AddParameterDA6.xsl", "default global")]
+ //[Variation(id = 14, Pri = 2, Desc = "No param sent, global variable used, local param doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterDA7.xsl", "default global" })]
+ [InlineData("AddParameterDA7.xsl", "default global")]
+
+ //global param is xsl:param local param is xsl:variable
+ //[Variation(id = 15, Pri = 2, Desc = "No param sent, global param used, local variable exists with a default value", Params = new object[] { "AddParameterEA1.xsl", "default local" })]
+ [InlineData("AddParameterEA1.xsl", "default local")]
+ //[Variation(id = 16, Pri = 2, Desc = "No param sent, global param used, local variable exists with no default value", Params = new object[] { "AddParameterEA2.xsl", "" })]
+ [InlineData("AddParameterEA2.xsl", "")]
+ //[Variation(id = 17, Pri = 2, Desc = "No param sent, global param used, local variable doesn't exist but reference to param exists", Params = new object[] { "AddParameterEA3.xsl", "default global" })]
+ [InlineData("AddParameterEA3.xsl", "default global")]
+ //[Variation(id = 18, Pri = 2, Desc = "No param sent, global param used, local variable exists with a default value and with-param sends a value", Params = new object[] { "AddParameterEA4.xsl", "default local" })]
+ [InlineData("AddParameterEA4.xsl", "default local")]
+ //[Variation(id = 19, Pri = 2, Desc = "No param sent, global param used, local variable exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterEA5.xsl", "" })]
+ [InlineData("AddParameterEA5.xsl", "")]
+ //[Variation(id = 20, Pri = 2, Desc = "No param sent, global param used, local variable doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterEA6.xsl", "default global" })]
+ [InlineData("AddParameterEA6.xsl", "default global")]
+ //[Variation(id = 21, Pri = 2, Desc = "No param sent, global param used, local variable doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterEA7.xsl", "default global" })]
+ [InlineData("AddParameterEA7.xsl", "default global")]
+
+ //global param is xsl:variable local param is xsl:variable
+ //[Variation(id = 22, Pri = 2, Desc = "No param sent, global variable used, local variable exists with a default value", Params = new object[] { "AddParameterFA1.xsl", "default local" })]
+ [InlineData("AddParameterFA1.xsl", "default local")]
+ //[Variation(id = 23, Pri = 2, Desc = "No param sent, global variable used, local variable exists with no default value", Params = new object[] { "AddParameterFA2.xsl", "" })]
+ [InlineData("AddParameterFA2.xsl", "")]
+ //[Variation(id = 24, Pri = 2, Desc = "No param sent, global variable used, local variable doesn't exist but reference to param exists", Params = new object[] { "AddParameterFA3.xsl", "default global" })]
+ [InlineData("AddParameterFA3.xsl", "default global")]
+ //[Variation(id = 25, Pri = 2, Desc = "No param sent, global variable used, local variable exists with a default value and with-param sends a value", Params = new object[] { "AddParameterFA4.xsl", "default local" })]
+ [InlineData("AddParameterFA4.xsl", "default local")]
+ //[Variation(id = 26, Pri = 2, Desc = "No param sent, global variable used, local variable exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterFA5.xsl", "" })]
+ [InlineData("AddParameterFA5.xsl", "")]
+ //[Variation(id = 27, Pri = 2, Desc = "No param sent, global variable used, local variable doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterFA6.xsl", "default global" })]
+ [InlineData("AddParameterFA6.xsl", "default global")]
+ //[Variation(id = 28, Pri = 2, Desc = "No param sent, global variable used, local variable doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterFA7.xsl", "default global" })]
+ [InlineData("AddParameterFA7.xsl", "default global")]
+ [Theory]
+ public void AddParam1(object param0, object param1)
+ {
+ m_xsltArg = new XsltArgumentList();
+ string xslFile = param0.ToString();
+ string expected = "<result>" + param1.ToString() + "</result>";
+
+ if ((LoadXSL(xslFile) == 1) && (Transform_ArgList("AddParameter.xml") == 1))
+ VerifyResult(expected);
+ else
+ Assert.True(false);
+ }
+
+ //All the below variations, param is sent from client code
+
+ //global param is xsl:param local param is xsl:param
+ //[Variation(id = 29, Pri = 2, Desc = "Param sent, global param used, local param exists with a default value", Params = new object[] { "AddParameterB1.xsl", "default local" })]
+ [InlineData("AddParameterB1.xsl", "default local")]
+ //[Variation(id = 30, Pri = 2, Desc = "Param sent, global param used, local param exists with no default value", Params = new object[] { "AddParameterB2.xsl", "" })]
+ [InlineData("AddParameterB2.xsl", "")]
+ //[Variation(id = 31, Pri = 2, Desc = "Param sent, global param used, local param doesn't exist but reference to param exists", Params = new object[] { "AddParameterB3.xsl", "outside param" })]
+ [InlineData("AddParameterB3.xsl", "outside param")]
+ //[Variation(id = 32, Pri = 2, Desc = "Param sent, global param used, local param exists with a default value and with-param sends a value", Params = new object[] { "AddParameterB4.xsl", "with-param" })]
+ [InlineData("AddParameterB4.xsl", "with-param")]
+ //[Variation(id = 33, Pri = 2, Desc = "Param sent, global param used, local param exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterB5.xsl", "" })]
+ [InlineData("AddParameterB5.xsl", "")]
+ //[Variation(id = 34, Pri = 2, Desc = "Param sent, global param used, local param doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterB6.xsl", "outside param" })]
+ [InlineData("AddParameterB6.xsl", "outside param")]
+ //[Variation(id = 35, Pri = 2, Desc = "Param sent, global param used, local param doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterB7.xsl", "outside param" })]
+ [InlineData("AddParameterB7.xsl", "outside param")]
+
+ //global param is xsl:variable local param is xsl:param
+ //[Variation(id = 36, Pri = 2, Desc = "Param sent, global variable used, local param exists with a default value", Params = new object[] { "AddParameterDB1.xsl", "default local" })]
+ [InlineData("AddParameterDB1.xsl", "default local")]
+ //[Variation(id = 37, Pri = 2, Desc = "Param sent, global variable used, local param exists with no default value", Params = new object[] { "AddParameterDB2.xsl", "" })]
+ [InlineData("AddParameterDB2.xsl", "")]
+ //[Variation(id = 38, Pri = 2, Desc = "Param sent, global variable used, local param doesn't exist but reference to param exists", Params = new object[] { "AddParameterDB3.xsl", "default global" })]
+ [InlineData("AddParameterDB3.xsl", "default global")]
+ //[Variation(id = 39, Pri = 2, Desc = "Param sent, global variable used, local param exists with a default value and with-param sends a value", Params = new object[] { "AddParameterDB4.xsl", "with-param" })]
+ [InlineData("AddParameterDB4.xsl", "with-param")]
+ //[Variation(id = 40, Pri = 2, Desc = "Param sent, global variable used, local param exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterDB5.xsl", "" })]
+ [InlineData("AddParameterDB5.xsl", "")]
+ //[Variation(id = 41, Pri = 2, Desc = "Param sent, global variable used, local param doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterDB6.xsl", "default global" })]
+ [InlineData("AddParameterDB6.xsl", "default global")]
+ //[Variation(id = 42, Pri = 2, Desc = "Param sent, global variable used, local param doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterDB7.xsl", "default global" })]
+ [InlineData("AddParameterDB7.xsl", "default global")]
+
+ //global param is xsl:param local param is xsl:variable
+ //[Variation(id = 43, Pri = 2, Desc = "Param sent, global param used, local variable exists with a default value", Params = new object[] { "AddParameterEB1.xsl", "default local" })]
+ [InlineData("AddParameterEB1.xsl", "default local")]
+ //[Variation(id = 44, Pri = 2, Desc = "Param sent, global param used, local variable exists with no default value", Params = new object[] { "AddParameterEB2.xsl", "" })]
+ [InlineData("AddParameterEB2.xsl", "")]
+ //[Variation(id = 45, Pri = 2, Desc = "Param sent, global param used, local variable doesn't exist but reference to param exists", Params = new object[] { "AddParameterEB3.xsl", "outside param" })]
+ [InlineData("AddParameterEB3.xsl", "outside param")]
+ //[Variation(id = 46, Pri = 2, Desc = "Param sent, global param used, local variable exists with a default value and with-param sends a value", Params = new object[] { "AddParameterEB4.xsl", "default local" })]
+ [InlineData("AddParameterEB4.xsl", "default local")]
+ //[Variation(id = 47, Pri = 2, Desc = "Param sent, global param used, local variable exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterEB5.xsl", "" })]
+ [InlineData("AddParameterEB5.xsl", "")]
+ //[Variation(id = 48, Pri = 2, Desc = "Param sent, global param used, local variable doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterEB6.xsl", "outside param" })]
+ [InlineData("AddParameterEB6.xsl", "outside param")]
+ //[Variation(id = 49, Pri = 2, Desc = "Param sent, global param used, local variable doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterEB7.xsl", "outside param" })]
+ [InlineData("AddParameterEB7.xsl", "outside param")]
+
+ //global param is xsl:variable local param is xsl:variable
+ //[Variation(id = 50, Pri = 2, Desc = "Param sent, global variable used, local variable exists with a default value", Params = new object[] { "AddParameterFB1.xsl", "default local" })]
+ [InlineData("AddParameterFB1.xsl", "default local")]
+ //[Variation(id = 51, Pri = 2, Desc = "Param sent, global variable used, local variable exists with no default value", Params = new object[] { "AddParameterFB2.xsl", "" })]
+ [InlineData("AddParameterFB2.xsl", "")]
+ //[Variation(id = 52, Pri = 2, Desc = "Param sent, global variable used, local variable doesn't exist but reference to param exists", Params = new object[] { "AddParameterFB3.xsl", "default global" })]
+ [InlineData("AddParameterFB3.xsl", "default global")]
+ //[Variation(id = 53, Pri = 2, Desc = "Param sent, global variable used, local variable exists with a default value and with-param sends a value", Params = new object[] { "AddParameterFB4.xsl", "default local" })]
+ [InlineData("AddParameterFB4.xsl", "default local")]
+ //[Variation(id = 54, Pri = 2, Desc = "Param sent, global variable used, local variable exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterFB5.xsl", "" })]
+ [InlineData("AddParameterFB5.xsl", "")]
+ //[Variation(id = 55, Pri = 2, Desc = "Param sent, global variable used, local variable doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterFB6.xsl", "default global" })]
+ [InlineData("AddParameterFB6.xsl", "default global")]
+ //[Variation(id = 56, Pri = 2, Desc = "Param sent, global variable used, local variable doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterFB7.xsl", "default global" })]
+ [InlineData("AddParameterFB7.xsl", "default global")]
+ [Theory]
+ public void AddParam2(object param0, object param1)
+ {
+ string xslFile = param0.ToString();
+ string expected = "<result>" + param1.ToString() + "</result>";
+
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("param1", "", "outside param");
+
+ if ((LoadXSL(xslFile) == 1) && (Transform_ArgList("AddParameter.xml") == 1))
+ VerifyResult(expected);
+ else
+ Assert.True(false);
+ }
+
+ //All the below variations, empty param is sent from client code
+ //global param is xsl:param local param is xsl:param
+ //[Variation(id = 57, Pri = 2, Desc = "Param sent, global param used, local param exists with a default value", Params = new object[] { "AddParameterB1.xsl", "default local" })]
+ [InlineData("AddParameterB1.xsl", "default local")]
+ //[Variation(id = 58, Pri = 2, Desc = "Param sent, global param used, local param exists with no default value", Params = new object[] { "AddParameterB2.xsl", "" })]
+ [InlineData("AddParameterB2.xsl", "")]
+ //[Variation(id = 59, Pri = 2, Desc = "Param sent, global param used, local param doesn't exist but reference to param exists", Params = new object[] { "AddParameterB3.xsl", "" })]
+ [InlineData("AddParameterB3.xsl", "")]
+ //[Variation(id = 60, Pri = 2, Desc = "Param sent, global param used, local param exists with a default value and with-param sends a value", Params = new object[] { "AddParameterB4.xsl", "with-param" })]
+ [InlineData("AddParameterB4.xsl", "with-param")]
+ //[Variation(id = 61, Pri = 2, Desc = "Param sent, global param used, local param exists with no default value and with-param doesn't send a value", Params = new object[] { "AddParameterB5.xsl", "" })]
+ [InlineData("AddParameterB5.xsl", "")]
+ //[Variation(id = 62, Pri = 2, Desc = "Param sent, global param used, local param doesn't exist, reference to param, with-param sends a value", Params = new object[] { "AddParameterB6.xsl", "" })]
+ [InlineData("AddParameterB6.xsl", "")]
+ //[Variation(id = 63, Pri = 2, Desc = "Param sent, global param used, local param doesn't exist, reference to param, with-param sends no value", Params = new object[] { "AddParameterB7.xsl", "" })]
+ [InlineData("AddParameterB7.xsl", "")]
+ [Theory]
+ public void AddParam3(object param0, object param1)
+ {
+ string xslFile = param0.ToString();
+ string expected = "<result>" + param1.ToString() + "</result>";
+
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("param1", "", "");
+
+ if ((LoadXSL(xslFile) == 1) && (Transform_ArgList("AddParameter.xml") == 1))
+ VerifyResult(expected);
+ else
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XsltArgumentList.AddExtensionObject */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Reader , Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ // TODO: Fix security issue
+ ////[TestCase(Name="XsltArgumentList - AddExtensionObject : URI, Reader", Desc="URI,READER")]
+ ////[TestCase(Name="XsltArgumentList - AddExtensionObject : URI, Stream", Desc="URI,STREAM")]
+ ////[TestCase(Name="XsltArgumentList - AddExtensionObject : URI, Writer", Desc="URI,WRITER")]
+ ////[TestCase(Name="XsltArgumentList - AddExtensionObject : URI, TextWriter", Desc="URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - AddExtensionObject : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CArgAddExtObj : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgAddExtObj(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation(Desc = "Basic Verification Test", Pri = 0)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject1()
+ {
+ MyObject obj = new MyObject(1, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObjectDef.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(430.402026847) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("namespace System.Xml.Tests = null")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject2()
+ {
+ MyObject obj = new MyObject(2, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddExtensionObject(null, obj);
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("System.ArgumentNullException not generated for null namespace System.Xml.Tests");
+ Assert.True(false);
+ }
+
+ //[Variation("namespace System.Xml.Tests is empty string - Bug 200998")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject3()
+ {
+ MyObject obj = new MyObject(3, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szEmpty, obj);
+ return; //shouldn't throw exception as per bug 200998
+ }
+
+ //[Variation("Very long namespace System.Xml.Tests")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject4()
+ {
+ m_xsltArg = new XsltArgumentList();
+ MyObject obj = new MyObject(4, _output);
+
+ m_xsltArg.AddExtensionObject(szLongNS, obj);
+
+ if ((LoadXSL("MyObjectLongNS.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(522.0563223871) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Different Data Types")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject6()
+ {
+ m_xsltArg = new XsltArgumentList();
+ String obj = "0.00";
+
+ // string
+ m_xsltArg.AddExtensionObject("myArg1", obj);
+ retObj = m_xsltArg.GetExtensionObject("myArg1");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "0.00", retObj);
+ if (retObj.ToString() != "0.00")
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", "0.00", "string");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ int i = 8;
+
+ m_xsltArg.AddExtensionObject("myArg2", i);
+ retObj = m_xsltArg.GetExtensionObject("myArg2");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value:{1}", i, retObj);
+ if (!i.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} with conversion from int to double", i);
+ _output.WriteLine("Retrieved: {0}", retObj.ToString());
+ Assert.True(false);
+ }
+
+ //must also be same instance!!!
+ if (i != (int)retObj)
+ Assert.True(false);
+
+ Boolean bF = (1 == 0);
+
+ m_xsltArg.AddExtensionObject("myArg3", bF);
+ retObj = m_xsltArg.GetExtensionObject("myArg3");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bF.ToString(), retObj);
+ if (!bF.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", bF.ToString(), "boolean");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ Boolean bT = (1 == 1);
+
+ m_xsltArg.AddExtensionObject("myArg4", bT);
+ retObj = m_xsltArg.GetExtensionObject("myArg4");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bT.ToString(), retObj);
+ if (!bT.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", bT.ToString(), "boolean");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ double d = 3.14;
+
+ m_xsltArg.AddExtensionObject("myArg5", d);
+ retObj = m_xsltArg.GetExtensionObject("myArg5");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", d.ToString(), retObj);
+ if (!d.Equals(retObj))
+ {
+ _output.WriteLine("Failed to add/get a value for {0} of type {1}", bT.ToString(), "boolean");
+ _output.WriteLine("Retrieved: {0} ", retObj);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddExtensionObject("myArg6", "3");
+ retObj = m_xsltArg.GetExtensionObject("myArg6");
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", bT.ToString(), retObj);
+
+ if ((LoadXSL("MyObject_DataTypes.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(499.4069850096) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Same Namespace different objects")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject7()
+ {
+ MyObject obj1 = new MyObject(1, _output);
+ MyObject obj2 = new MyObject(2, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj1);
+ try
+ {
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj2);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not launch exception 'System.ArgumentException' for an item already added");
+ Assert.True(false);
+ }
+
+ //[Variation("Case sensitivity")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject8()
+ {
+ MyObject obj = new MyObject(1, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject("urn:my-object", obj);
+
+ retObj = m_xsltArg.GetExtensionObject("urn:my-object");
+ if (((MyObject)retObj).MyValue() != obj.MyValue())
+ {
+ _output.WriteLine("Set and retrieved value appear to be different");
+ Assert.True(false);
+ }
+ m_xsltArg.AddExtensionObject("URN:MY-OBJECT", obj);
+ m_xsltArg.AddExtensionObject("urn:My-Object", obj);
+ m_xsltArg.AddExtensionObject("urn-my:object", obj);
+
+ if ((LoadXSL("MyObjectDef.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(430.402026847) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Set a null object")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject9()
+ {
+ MyObject obj = new MyObject(9, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.AddExtensionObject(szDefaultNS, null);
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not launch exception 'System.ArgumentNullException' for adding a null-valued item");
+ Assert.True(false);
+ }
+
+ //[Variation("Unitialized and NULL return values from the methods in the extension object")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject10()
+ {
+ MyObject obj = new MyObject(10, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_Null.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(424.8906559839) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Add many objects")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject11()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ MyObject obj1 = new MyObject(100, _output);
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj1);
+
+ for (int i = 1; i < 500; i++)
+ {
+ MyObject obj = new MyObject(i, _output);
+ m_xsltArg.AddExtensionObject(szDefaultNS + i, obj);
+ }
+ if ((LoadXSL("MyObjectDef.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(430.402026847) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Whitespace")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject12()
+ {
+ int i = 1;
+ m_xsltArg = new XsltArgumentList();
+
+ foreach (String str in szWhiteSpace)
+ {
+ MyObject obj = new MyObject(i, _output);
+ m_xsltArg.AddExtensionObject(szDefaultNS + str, obj);
+ i++;
+ }
+ try
+ {
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw expected exception");
+ Assert.True(false);
+ }
+
+ //[Variation("Add object many times")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject13()
+ {
+ MyObject obj = new MyObject(13, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ try
+ {
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not exception for adding an extension object that already exists");
+ Assert.True(false);
+ }
+
+ //[Variation("Add and Remove multiple times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject14()
+ {
+ MyObject obj = new MyObject(14, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ for (int i = 0; i < 400; i++)
+ {
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ m_xsltArg.RemoveExtensionObject(szDefaultNS);
+ }
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+
+ if ((LoadXSL("MyObjectDef.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(430.402026847) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI non-existent")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject15()
+ {
+ MyObject obj = new MyObject(15, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szSimple, obj);
+ try
+ {
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw expected exception");
+ Assert.True(false);
+ }
+
+ //[Variation("Accessing Private and protected Items")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject16()
+ {
+ MyObject obj = new MyObject(1, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ try
+ {
+ LoadXSL("MyObject_PrivateAccess.xsl");
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ try
+ {
+ LoadXSL("MyObject_ProtectedAccess.xsl");
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ try
+ {
+ LoadXSL("MyObject_DefaultAccess.xsl");
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ }
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Writing To Output")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject17()
+ {
+ MyObject obj = new MyObject(17, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_ConsoleWrite.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(421.8660259804) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Recursive Functions")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject18()
+ {
+ MyObject obj = new MyObject(18, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_Recursion.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(459.4210605285) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Overloaded Functions")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject19()
+ {
+ MyObject obj = new MyObject(19, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_Overloads.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(481.1053900491) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Function-exists tests")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject20()
+ {
+ MyObject obj = new MyObject(20, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_FnExists.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(534.2681508201) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Argument Tests")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject21()
+ {
+ MyObject obj = new MyObject(1, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_Arguments.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(513.296131727) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Methods returning void and valid types")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject22()
+ {
+ MyObject obj = new MyObject(22, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_ReturnValidTypes.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(514.0958814743) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Multiple Objects in same NameSpace")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject24()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ double d = 1;
+ int i = 1;
+
+ m_xsltArg.AddExtensionObject("urn:myspace", d);
+ try
+ {
+ m_xsltArg.AddExtensionObject("urn:myspace", i);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not thrown for URI namespace System.Xml.Tests in use");
+ Assert.True(false);
+ }
+
+ //[Variation("Case Sensitivity")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject25()
+ {
+ MyObject obj = new MyObject(25, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if (LoadXSL("MyObject_CaseSensitive.xsl") == 1)
+ {
+ try
+ {
+ Transform_ArgList("fruits.xml");
+ CheckResult(419.3031944636);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not thrown for wrong-case spelling of methods");
+ Assert.True(false);
+ }
+
+ //[Variation("Object namespace System.Xml.Tests found")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject26()
+ {
+ MyObject obj = new MyObject(26, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_NotFoundNS.xsl") == 1))
+ {
+ try
+ {
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not thrown for NS not found");
+ Assert.True(false);
+ }
+
+ //[Variation("Maintaining State")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject27()
+ {
+ MyObject obj = new MyObject(27, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_KeepingState.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(439.7536748395) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Deliberately Messing Up the Stylesheet")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject28()
+ {
+ MyObject obj = new MyObject(28, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_KillerStrings.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(495.5795381156) == 1 || CheckResult(503.3730396353) == 1)) //multiple baseline
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Function not found in Object")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject29()
+ {
+ MyObject obj = new MyObject(29, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ if ((LoadXSL("MyObject_NotFound.xsl") == 1))
+ {
+ try
+ {
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not thrown for method not found");
+ Assert.True(false);
+ }
+
+ //[Variation("Using Default XSLT namespace - Bug305503")]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject31()
+ {
+ MyObject obj = new MyObject(31, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szXslNS, obj);
+ return;
+ }
+
+ //[Variation("Extension objects should not be cached during Transform()")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void AddExtObject32()
+ {
+ if (LoadXSL("Bug78587.xsl") == 1)
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddExtensionObject("id", new Id("first"));
+ m_xsltArg.AddExtensionObject("capitalizer", new Capitalizer());
+
+ // Transform once
+ if ((Transform_ArgList("Bug78587.xml") == 1) && (CheckResult(438.9506396879) == 1))
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddExtensionObject("id", new Id("second"));
+ m_xsltArg.AddExtensionObject("capitalizer", new Capitalizer());
+
+ // Transform again to make sure that extension objects from first transform are not cached
+ if ((Transform_ArgList("Bug78587.xml") == 1) && (CheckResult(440.0296788876) == 1))
+ return;
+ }
+ }
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XsltArgumentList.RemoveParam */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltArgumentList - RemoveParam : Reader , Reader", Desc = "READER,READER")]
+ // TODO: Fix security issue
+ ////[TestCase(Name="XsltArgumentList - RemoveParam : URI, Stream", Desc="URI,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - RemoveParam : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltArgumentList - RemoveParam : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CArgRemoveParam : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgRemoveParam(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation(Desc = "Basic Verification Test", Pri = 0)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam1()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test2");
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Value of Removed Object is not null : {0}", retObj);
+ Assert.True(false);
+ }
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+
+ _output.WriteLine("Added Value:{0}\nRetrieved Value: {1}", "Test1", retObj);
+ if (retObj.ToString() != "Test1")
+ {
+ _output.WriteLine("Value of removed object is not as expected : {0}", retObj);
+ Assert.True(false);
+ }
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.6003003605) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Param name is null")]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam2()
+ {
+ m_xsltArg = new XsltArgumentList();
+ retObj = m_xsltArg.RemoveParam(null, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for null parameter name");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Param name is empty string")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam3()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.RemoveParam(szEmpty, szEmpty);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Param name is non-existent")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam4()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.RemoveParam(szSimple, szEmpty);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Invalid Param name")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam5()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.RemoveParam(szInvalid, szEmpty);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Very long param name")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam6()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam(szLongString, szEmpty, "Test1");
+ m_xsltArg.RemoveParam(szLongString, szEmpty);
+
+ if ((LoadXSL("showParamLongName.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(400.2204182193) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI is null")]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam7()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ retObj = m_xsltArg.RemoveParam("myArg1", null);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not return NULL for null URI namespace");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Namespace URI is empty string")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam8()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI is non-existent")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam9()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ m_xsltArg.RemoveParam("myArg1", "http://www.xsltTest.com");
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.6003003605) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Very long namespace System.Xml.Tests")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam10()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szLongString, "Test1");
+ m_xsltArg.RemoveParam("myArg1", szLongString);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Different Data Types")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam11()
+ {
+ double d1 = double.PositiveInfinity;
+ double d2 = double.NegativeInfinity;
+ double d3 = double.NaN;
+ double d4 = 2.000001;
+ double d5 = 0.00;
+ double d6 = double.MaxValue;
+ double d7 = double.MinValue;
+
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, d1);
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d1);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, d2);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d2);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg3", szEmpty, d3);
+ m_xsltArg.RemoveParam("myArg3", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg3", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d3);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg4", szEmpty, d4);
+ m_xsltArg.RemoveParam("myArg4", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg4", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d4);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg5", szEmpty, d5);
+ m_xsltArg.RemoveParam("myArg5", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg5", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d5);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg6", szEmpty, d6);
+ m_xsltArg.RemoveParam("myArg6", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg6", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d6);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg7", szEmpty, d7);
+ m_xsltArg.RemoveParam("myArg7", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg7", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", d7);
+ Assert.True(false);
+ }
+
+ String obj = "0.00";
+
+ // string
+ m_xsltArg.AddParam("myArg1", szEmpty, obj);
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", obj);
+ Assert.True(false);
+ }
+
+ //int
+ int i = 2;
+
+ m_xsltArg.AddParam("myArg2", szEmpty, i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ Boolean bF = (1 == 0);
+ m_xsltArg.AddParam("myArg4", szEmpty, bF);
+ m_xsltArg.RemoveParam("myArg4", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg4", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", bF);
+ Assert.True(false);
+ }
+
+ Boolean bT = (1 == 1);
+ m_xsltArg.AddParam("myArg5", szEmpty, bT);
+ m_xsltArg.RemoveParam("myArg5", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg5", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", bT);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (Int16)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (UInt16)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (Int32)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (UInt32)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (Int64)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (UInt64)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (Single)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ m_xsltArg.AddParam("myArg2", szEmpty, (Decimal)i);
+ m_xsltArg.RemoveParam("myArg2", szEmpty);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Failed to remove {0}", i);
+ Assert.True(false);
+ }
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Case Sensitivity")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam12()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ m_xsltArg.RemoveParam("myarg1", szEmpty);
+ m_xsltArg.RemoveParam("MYARG1", szEmpty);
+ m_xsltArg.RemoveParam("myArg1 ", szEmpty);
+
+ // perform a transform for kicks and ensure all is ok.
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.6003003605) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Whitespace")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam13()
+ {
+ int i = 1;
+ m_xsltArg = new XsltArgumentList();
+
+ foreach (String str in szWhiteSpace)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, "Test" + str);
+ m_xsltArg.RemoveParam("myArg" + i, szEmpty);
+ retObj = m_xsltArg.GetParam("myArg" + i, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Error removing case #{0} from this test", i);
+ Assert.True(false);
+ }
+ i++;
+ }
+
+ i = 1;
+ foreach (String str in szWhiteSpace)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, "Test"); // dont add whitespace to name here since addparam would throw
+ m_xsltArg.RemoveParam("myArg" + str, szEmpty);
+ retObj = m_xsltArg.GetParam("myArg" + str, szEmpty);
+ if (retObj != null)
+ {
+ _output.WriteLine("Error removing case #{0} in the second batch from this test", i);
+ Assert.True(false);
+ }
+ i++;
+ }
+
+ // perform a transform for kicks and ensure all is ok.
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(421.3863242307) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Call Multiple Times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam14()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+ for (int i = 0; i < 500; i++)
+ m_xsltArg.RemoveParam("myArg1", szEmpty);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Using Default XSLT Namespace - Bug305503")]
+ [InlineData()]
+ [Theory]
+ public void RemoveParam15()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.RemoveParam("myParam", szDefaultNS);
+
+ return;
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.RemoveExtensionObject */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltArgumentList - RemoveExtensionObject : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltArgumentList - RemoveExtensionObject : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ // TODO: Fix security issue
+ ////[TestCase(Name="XsltArgumentList - RemoveExtensionObject : URI, Reader", Desc="URI,READER")]
+ //[TestCase(Name = "XsltArgumentList - RemoveExtensionObject : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ public class CArgRemoveExtObj : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgRemoveExtObj(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation(Desc = "Basic Verification Test", Pri = 0)]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj1()
+ {
+ MyObject obj = new MyObject(1, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ m_xsltArg.RemoveExtensionObject(szDefaultNS);
+
+ try
+ {
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw expected exception");
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI is null")]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj2()
+ {
+ MyObject obj = new MyObject(2, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ try
+ {
+ m_xsltArg.RemoveExtensionObject(null);
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not generated for null parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Multiple Times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj3()
+ {
+ MyObject obj = new MyObject(10, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+
+ for (int i = 0; i < 500; i++)
+ m_xsltArg.RemoveExtensionObject(szDefaultNS);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Namespace URI is non-existent")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj4()
+ {
+ MyObject obj = new MyObject(4, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ m_xsltArg.RemoveExtensionObject(szSimple);
+
+ if ((LoadXSL("MyObjectDef.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(430.402026847) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Very long namespace System.Xml.Tests")]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj5()
+ {
+ m_xsltArg = new XsltArgumentList();
+ MyObject obj = new MyObject(5, _output);
+
+ m_xsltArg.AddExtensionObject("urn:" + szLongNS, obj);
+ m_xsltArg.RemoveExtensionObject("urn:" + szLongNS);
+
+ try
+ {
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not throw expected exception");
+ Assert.True(false);
+ }
+
+ //[Variation("Different Data Types")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj6()
+ {
+ MyObject obj = new MyObject(6, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject("urn:my-object", obj);
+ m_xsltArg.RemoveExtensionObject("urn:my-object");
+
+ m_xsltArg.AddExtensionObject("urn:my-object", 2);
+ m_xsltArg.RemoveExtensionObject("urn:my-object");
+
+ m_xsltArg.AddExtensionObject("urn:my-object", "Test String");
+ m_xsltArg.RemoveExtensionObject("urn:my-object");
+
+ m_xsltArg.AddExtensionObject("urn:my-object", (double)5.1);
+ m_xsltArg.RemoveExtensionObject("urn:my-object");
+
+ m_xsltArg.AddExtensionObject("urn:my-object", true);
+ m_xsltArg.RemoveExtensionObject("urn:my-object");
+
+ m_xsltArg.AddExtensionObject("urn:my-object", false);
+ m_xsltArg.RemoveExtensionObject("urn:my-object");
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Case Sensitivity")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj7()
+ {
+ MyObject obj = new MyObject(7, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject("urn:my-object", obj);
+
+ m_xsltArg.RemoveExtensionObject("URN:MY-OBJECT");
+ m_xsltArg.RemoveExtensionObject("urn:My-Object");
+ m_xsltArg.RemoveExtensionObject("urn-my:object");
+ m_xsltArg.RemoveExtensionObject("urn:my-object ");
+
+ if ((LoadXSL("MyObjectDef.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(430.402026847) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Whitespace")]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj8()
+ {
+ int i = 1;
+ m_xsltArg = new XsltArgumentList();
+
+ foreach (String str in szWhiteSpace)
+ {
+ MyObject obj = new MyObject(i, _output);
+
+ m_xsltArg.AddExtensionObject(szDefaultNS + str, obj);
+ m_xsltArg.RemoveExtensionObject(szDefaultNS + str);
+ retObj = m_xsltArg.GetExtensionObject(szDefaultNS + str);
+ if (retObj != null)
+ {
+ _output.WriteLine("Error deleting case #{0} for whitespace arg", i);
+ Assert.True(false);
+ }
+ i++;
+ }
+
+ try
+ {
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ Transform_ArgList("fruits.xml", true);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ _output.WriteLine("Did not exception for object that could not be executed");
+ Assert.True(false);
+ }
+
+ //[Variation("Using default XSLT namespace - Bug305503")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void RemoveExtObj9()
+ {
+ MyObject obj = new MyObject(10, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.RemoveExtensionObject(szDefaultNS);
+
+ // ensure we can still do a transform
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Clear */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltArgumentList - Clear", Desc = "XsltArgumentList.Clear")]
+ public class CArgClear : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CArgClear(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation(Desc = "Basic Verification Test", Pri = 0)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear1()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj.ToString() != "Test1")
+ return; //return TEST_SKIPPED;
+
+ m_xsltArg.Clear();
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj != null)
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Clear with nothing loaded")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear2()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.Clear();
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Clear Params")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear3()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj.ToString() != "Test1")
+ return; //return TEST_SKIPPED;
+
+ m_xsltArg.Clear();
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj != null)
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Clear Extension Objects")]
+ [InlineData()]
+ [Theory]
+ public void Clear4()
+ {
+ MyObject obj = new MyObject(26, _output);
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ m_xsltArg.Clear();
+ retObj = m_xsltArg.GetExtensionObject(szDefaultNS);
+ if (retObj != null)
+ {
+ _output.WriteLine("Did not appear to clear an extension object");
+ Assert.True(false);
+ }
+
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ {
+ try
+ {
+ Transform_ArgList("fruits.xml");
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not thrown for NS not found");
+ Assert.True(false);
+ }
+
+ //[Variation("Clear Many Objects")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear5()
+ {
+ m_xsltArg = new XsltArgumentList();
+ String obj = "Test";
+
+ for (int i = 0; i < 200; i++)
+ {
+ m_xsltArg.AddParam("myArg2", szEmpty, obj + i);
+ retObj = m_xsltArg.GetParam("myArg2", szEmpty);
+ if (retObj.ToString() != (obj + i))
+ {
+ _output.WriteLine("Failed to add/remove iteration {0}", i);
+ _output.WriteLine("{0} : {1}", retObj, obj + i);
+
+ Assert.True(false);
+ }
+ m_xsltArg.Clear();
+ }
+
+ for (int i = 0; i < 200; i++)
+ {
+ m_xsltArg.AddParam("myArg" + i, szEmpty, obj + i);
+ retObj = m_xsltArg.GetParam("myArg" + i, szEmpty);
+ if (retObj.ToString() != (obj + i))
+ {
+ _output.WriteLine("Failed in 2nd part to add/remove iteration {0}", i);
+ Assert.True(false);
+ }
+ }
+
+ // _output.WriteLine(retObj.GetType());
+
+ m_xsltArg.Clear();
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Clear Multiple Times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear6()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj.ToString() != "Test1")
+ return; //return TEST_SKIPPED;
+
+ for (int i = 0; i < 300; i++)
+ m_xsltArg.Clear();
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj != null)
+ Assert.True(false);
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Loading one object, but clearing another")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear7()
+ {
+ m_xsltArg = new XsltArgumentList();
+ XsltArgumentList m_2 = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj.ToString() != "Test1")
+ return; //return TEST_SKIPPED;
+
+ m_2.Clear();
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) &&
+ (CheckResult(457.6003003605) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Clear after objects have been \"Removed\"")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void Clear8()
+ {
+ m_xsltArg = new XsltArgumentList();
+
+ m_xsltArg.AddParam("myArg1", szEmpty, "Test1");
+ retObj = m_xsltArg.GetParam("myArg1", szEmpty);
+ if (retObj.ToString() != "Test1")
+ return; //return TEST_SKIPPED;
+ retObj = m_xsltArg.RemoveParam("myArg1", szEmpty);
+ m_xsltArg.Clear();
+
+ if ((LoadXSL("showParam.xsl") != 1) || (Transform_ArgList("fruits.xml") != 1) ||
+ (CheckResult(466.5112789241) != 1))
+ Assert.True(false);
+
+ MyObject obj = new MyObject(26, _output);
+
+ m_xsltArg.AddExtensionObject(szDefaultNS, obj);
+ m_xsltArg.RemoveExtensionObject(szDefaultNS);
+ m_xsltArg.Clear();
+
+ if ((LoadXSL("MyObjectDef.xsl") == 1))
+ {
+ try
+ {
+ Transform_ArgList("fruits.xml");
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not thrown for NS not found");
+ Assert.True(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs
new file mode 100644
index 0000000000..ddbc0b3d45
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransform.cs
@@ -0,0 +1,2652 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.Collections;
+using System.IO;
+using System.Security;
+using System.Security.Policy;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.Xml.Tests
+{
+ //[TestCase(Name = "Null argument tests", Desc = "This testcase passes NULL arguments to all XslTransform methods")]
+ public class CNullArgumentTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CNullArgumentTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Load(IXPathNavigable = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var1()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Load((IXPathNavigable)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Load(XmlReader = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var2()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Load((XmlReader)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Load(IXPathNavigable = null, XmlResolver = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var3()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Load((IXPathNavigable)null, (XmlResolver)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Load(XmlReader = null, XmlResolver = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var4()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Load((XmlReader)null, (XmlResolver)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Load(IXPathNavigable = null, XmlResolver = null, Evidence = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var5()
+ {
+ /*try
+ {
+#pragma warning disable 0618
+ new XslTransform().Load((IXPathNavigable)null, (XmlResolver)null, (Evidence)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);*/
+ }
+
+ //[Variation("Load(XmlReader = null, XmlResolver = null, Evidence = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var6()
+ {
+ /*try
+ {
+#pragma warning disable 0618
+ new XslTransform().Load((XmlReader)null, (XmlResolver)null, (Evidence)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);*/
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var7()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, XmlResolver = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var8()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (XmlResolver)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, TextWriter = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var9()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (TextWriter)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, TextWriter = null, XmlResolver = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var10()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (TextWriter)null, (XmlResolver)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, Stream = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var11()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (Stream)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, Stream = null, XmlResolver = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var12()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (Stream)null, (XmlResolver)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, XmlWriter = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var13()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (XmlWriter)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Transform(IXPathNavigable = null, XsltArgumentList = null, XmlWriter = null, XmlResolver = null)", Pri = 1)]
+ [InlineData()]
+ [Theory]
+ public void Var14()
+ {
+ try
+ {
+#pragma warning disable 0618
+ new XslTransform().Transform((IXPathNavigable)null, (XsltArgumentList)null, (XmlWriter)null, (XmlResolver)null);
+#pragma warning restore 0618
+ }
+ catch (ArgumentNullException)
+ {
+ return;
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Did not throw ArgumentNullException");
+ }
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Resolver - Integrity */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.XmlResolver : Reader, Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltTransform.XmlResolver : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CXmlResolverTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CXmlResolverTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Set XmlResolver property to null, load style sheet with import/include, should not affect transform")]
+ [InlineData()]
+ [Theory(Skip = "Resolving of External URIs is no longer allowed")]
+ public void XmlResolver1()
+ {
+ try
+ {
+ if (LoadXSL("xmlResolver_main.xsl") == 1)
+ {
+ xslt.XmlResolver = null;
+ if ((Transform("fruits.xml") == 1) && (CheckResult(428.8541842246) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine("Should not throw error loading stylesheet with include/import when resolver property is set to NULL!");
+ _output.WriteLine(e.ToString());
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Set XmlResolver property to null, load style sheet with document function, should not resolve during transform")]
+ [InlineData()]
+ [Theory]
+ public void XmlResolver2()
+ {
+ // "xmlResolver_document_function.xsl" contains
+ // <xsl:for-each select="document('xmlResolver_document_function.xml')//elem">
+
+ if (LoadXSL("xmlResolver_document_function.xsl") == 1)
+ {
+ xslt.XmlResolver = null;
+ if ((Transform("fruits.xml") == 1) && (CheckResult(375.6079891948) == 1))
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Problem loading stylesheet with document function and resolver set to NULL!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Default XmlResolver, load style sheet with document function, should resolve during transform")]
+ [InlineData()]
+ [Theory(Skip = "SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.")]
+ public void XmlResolver3()
+ {
+ // "xmlResolver_document_function.xsl" contains
+ // <xsl:for-each select="document('xmlResolver_document_function.xml')//elem">
+
+ // SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.
+ //if (MyInputType() == InputType.URI)
+ // return TEST_SKIPPED;
+
+ if (LoadXSL("xmlResolver_document_function.xsl") == 1)
+ {
+ if ((Transform("fruits.xml") == 1) && (CheckResult(377.8217373898) == 1))
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Problem loading stylesheet with document function and default resolver!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("document() has absolute URI")]
+ [InlineData()]
+ [Theory(Skip = "When style sheet URI = Intranet zone, XmlSecureResolver does not resolve document function")]
+ public void XmlResolver7()
+ {
+ // Skip this test for Load(URI)
+ // Reason: When style sheet URI = Intranet zone, XmlSecureResolver does not resolve document function
+
+ //if (MyInputType() == InputType.URI)
+ // return TEST_SKIPPED;
+
+ // copy file on the local machine
+
+ try
+ {
+ if (!Directory.Exists("c:\\temp"))
+ {
+ Directory.CreateDirectory("c:\\temp");
+ }
+ string xmlFile = FullFilePath("xmlResolver_document_function.xml");
+ File.Copy(xmlFile, @"c:\temp\xmlResolver_document_function.xml", true);
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Could not copy file to local. Some other issues prevented this test from running");
+ return; //return TEST_SKIPPED;
+ }
+
+ if (LoadXSL("xmlResolver_document_function_absolute_uri.xsl") == 1)
+ {
+ if ((Transform("fruits.xml") == 1) && (CheckResult(377.8217373898) == 1))
+ return;
+ else
+ {
+ _output.WriteLine("Failed to resolve document function with absolute URI.");
+ Assert.True(false);
+ }
+ }
+ else
+ {
+ _output.WriteLine("Failed to load style sheet!");
+ Assert.True(false);
+ }
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Load - Integrity */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Reader, Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load() - Integrity : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CLoadTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Call Load with null value")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric1()
+ {
+ try
+ {
+ LoadXSL(null);
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws System.ArgumentException here for null
+ return;
+ }
+ _output.WriteLine("Exception not generated for null parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Load with valid, then invalid, then valid again")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric2()
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ LoadXSL("IDontExist.xsl");
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ try
+ {
+ Transform("fruits.xml");
+ }
+ catch (System.InvalidOperationException e)
+ {
+ CheckExpectedError(e, "System.Xml", "Xslt_NoStylesheetLoaded", new string[] { "" });
+ return;
+ }
+ }
+ }
+ else
+ {
+ _output.WriteLine("Failed to load style sheet!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Load an invalid, then a valid and transform")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric3()
+ {
+ try
+ {
+ LoadXSL("IDontExist.xsl");
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ if ((LoadXSL("ShowParam.xsl") == 1) && (Transform("fruits.xml") == 1)
+ && (CheckResult(466.5112789241) == 1))
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file name");
+ Assert.True(false);
+ }
+
+ //[Variation("Call several overloaded functions")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric4()
+ {
+ if (MyInputType() != InputType.Reader)
+ LoadXSL("showParamLongName.xsl", InputType.Reader);
+ if (MyInputType() != InputType.URI)
+ LoadXSL("showParamLongName.xsl", InputType.URI);
+ if (MyInputType() != InputType.Navigator)
+ LoadXSL("showParamLongName.xsl", InputType.Navigator);
+
+ if ((LoadXSL("ShowParam.xsl") == 0) || (Transform("fruits.xml") == 0)
+ || (CheckResult(466.5112789241) == 0))
+ Assert.True(false);
+
+ if (MyInputType() != InputType.Navigator)
+ LoadXSL("showParamLongName.xsl", InputType.Navigator);
+ if (MyInputType() != InputType.URI)
+ LoadXSL("showParamLongName.xsl", InputType.URI);
+ if (MyInputType() != InputType.Reader)
+ LoadXSL("showParamLongName.xsl", InputType.Reader);
+
+ if ((LoadXSL("ShowParam.xsl") == 1) && (Transform("fruits.xml") == 1)
+ && (CheckResult(466.5112789241) == 1))
+ return;
+
+ Assert.True(false);
+ }
+
+ //[Variation("Call same overloaded Load() many times then transform")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric5()
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ if (LoadXSL("showParam.xsl") != 1)
+ {
+ _output.WriteLine("Failed to load stylesheet showParam.xsl on the {0} attempt", i);
+ Assert.True(false);
+ }
+ }
+ if ((LoadXSL("ShowParam.xsl") == 1) && (Transform("fruits.xml") == 1)
+ && (CheckResult(466.5112789241) == 1))
+ return;
+ Assert.True(false);
+ }
+
+ //[Variation("Call load with non-existing stylesheet")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric6()
+ {
+ try
+ {
+ LoadXSL("IDontExist.xsl");
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Verify that style sheet is closed properly after Load - Shared Read Access")]
+ [InlineData()]
+ [Theory(Skip = "Resolving of External URIs is no longer allowed")]
+ public void LoadGeneric7()
+ {
+ FileStream s2;
+
+ // check immediately after load and after transform
+ if (LoadXSL("XmlResolver_main.xsl") == 1)
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_main.xsl"), FileMode.Open, FileAccess.Read, FileShare.Read);
+ s2.Dispose();
+ if ((Transform("fruits.xml") == 1) && (CheckResult(428.8541842246) == 1))
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_main.xsl"), FileMode.Open, FileAccess.Read, FileShare.Read);
+ s2.Dispose();
+ return;
+ }
+ }
+ Assert.True(false);
+ }
+
+ /*
+ //[Variation("Verify that style sheet is closed properly after Load - ReadWrite Access")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric8()
+ {
+ FileStream s2;
+
+ // check immediately after load and after transform
+
+ if(LoadXSL("XmlResolver_main.xsl") == TEST_PASS)
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_main.xsl"), FileMode.Open, FileAccess.ReadWrite);
+ s2.Dispose();
+ if((Transform("fruits.xml") == TEST_PASS) && (CheckResult(428.8541842246)== TEST_PASS))
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_main.xsl"), FileMode.Open, FileAccess.ReadWrite);
+ s2.Dispose();
+ return;
+ }
+ }
+ _output.WriteLine("Appeared to not close style sheet file properly after loading.");
+ Assert.True(false);
+ }
+ */
+
+ //[Variation("Verify that included files are closed properly after Load - Read Access")]
+ [InlineData()]
+ [Theory(Skip = "Resolving of External URIs is no longer allowed")]
+ public void LoadGeneric9()
+ {
+ FileStream s2;
+
+ // check immediately after load and after transform
+ if (LoadXSL("XmlResolver_main.xsl") == 1)
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_sub.xsl"), FileMode.Open, FileAccess.Read);
+ s2.Dispose();
+ if ((Transform("fruits.xml") == 1) && (CheckResult(428.8541842246) == 1))
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_Include.xsl"), FileMode.Open, FileAccess.Read, FileShare.Read);
+ s2.Dispose();
+ return;
+ }
+ }
+ _output.WriteLine("Appeared to not close file properly after loading.");
+ Assert.True(false);
+ }
+
+ /*
+ //[Variation("Verify that included files are closed properly after Load - ReadWrite Access")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric10()
+ {
+ FileStream s2;
+
+ // check immediately after load and after transform
+ if(LoadXSL("XmlResolver_main.xsl") == TEST_PASS)
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_sub.xsl"), FileMode.Open, FileAccess.ReadWrite);
+ s2.Dispose();
+ if((Transform("fruits.xml") == TEST_PASS) && (CheckResult(428.8541842246)== TEST_PASS))
+ {
+ s2 = new FileStream(FullFilePath("XmlResolver_Include.xsl"), FileMode.Open, FileAccess.ReadWrite);
+ s2.Dispose();
+ return;
+ }
+ }
+ _output.WriteLine("Appeared to not close file properly after loading.");
+ Assert.True(false);
+ }
+ */
+
+ //[Variation("Load stylesheet with entity reference: Bug #68450 ")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric11()
+ {
+ if (MyDocType().ToString() == "DataDocument")
+ // Skip the test for DataDocument
+ return;
+ else
+ {
+ if (LoadXSL("books_entity_ref.xsl", InputType.Reader) != 1)
+ {
+ _output.WriteLine("Failed to load stylesheet books_entity_ref.xsl");
+ Assert.True(false);
+ }
+ if ((LoadXSL("books_entity_ref.xsl") == 1) && (Transform("books_entity_ref.xml") == 1)
+ && (CheckResult(371.4148215954) == 1))
+ return;
+ Assert.True(false);
+ }
+ }
+
+ //[Variation("Load with invalid stylesheet and verify that file is closed properly")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric12()
+ {
+ Stream strmTemp;
+
+ try
+ {
+ int i = LoadXSL("xslt_error.xsl");
+ }
+ catch (System.Xml.Xsl.XsltCompileException)
+ {
+ // Try to open the xsl file
+ try
+ {
+ strmTemp = new FileStream(FullFilePath("xslt_error.xsl"), FileMode.Open, FileAccess.Read);
+ }
+ catch (Exception ex)
+ {
+ _output.WriteLine("Did not close stylesheet properly after load");
+ _output.WriteLine(ex.Message);
+ Assert.True(false);
+ }
+ return;
+ }
+ _output.WriteLine("Did not throw compile exception for stylesheet");
+ Assert.True(false);
+ }
+ }
+
+ /**************************************************************************/
+ /* XslTransform.Load(,XmlResolver) - Integrity */
+ /**************************************************************************/
+
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Reader, Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver) - Integrity : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ public class CLoadXmlResolverTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadXmlResolverTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Call Load with null source value and null resolver")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric1()
+ {
+ try
+ {
+ LoadXSL_Resolver(null, null);
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws ArgumentException
+ return;
+ }
+ _output.WriteLine("Did not throw an exception for null argument!");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with null source value and valid resolver")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric2()
+ {
+ try
+ {
+ LoadXSL_Resolver(null, new XmlUrlResolver());
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws ArgumentException
+ return;
+ }
+ _output.WriteLine("Did not throw an exception for null argument!");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with null XmlResolver, style sheet does not have include/import, should not error")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric3()
+ {
+ if (LoadXSL_Resolver("ShowParam.xsl", null) == 1)
+ {
+ if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ else
+ {
+ _output.WriteLine("Failed to load style sheet!");
+ Assert.True(false);
+ }
+ }
+
+ //[Variation("Call Load with null XmlResolver and style sheet has import/include, should fail")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric4()
+ {
+ try
+ {
+ LoadXSL_Resolver("xmlResolver_main.xsl", null);
+ }
+ catch (System.Xml.Xsl.XsltCompileException e)
+ {
+ CheckExpectedError(e.InnerException, "System.Xml", "Xml_NullResolver", new string[] { "" });
+ return;
+ }
+ _output.WriteLine("Exception not thrown for null resolver");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with null custom resolver and style sheet has import/include, should fail")]
+ [InlineData()]
+ [Theory(Skip = "By design bug #84957: Skip this test for Load(url, resolver)")]
+ public void LoadGeneric5()
+ {
+ // By design bug #84957: Skip this test for Load(url, resolver)
+ //if (MyInputType() == InputType.URI)
+ //{
+ // _output.WriteLine("By design bug #84957: Skip this test for Load(url, resolver)");
+ // return TEST_SKIPPED;
+ //}
+
+ CustomNullResolver myResolver = new CustomNullResolver(null);
+ try
+ {
+ LoadXSL_Resolver("xmlResolver_main.xsl", myResolver);
+ }
+ catch (System.Xml.Xsl.XsltCompileException e)
+ {
+ CheckExpectedError(e.InnerException, "System.Data.Sqlxml", "Xslt_CantResolve", new string[] { new Uri(FullFilePath("XmlResolver_Include.xsl", false)).ToString() });
+ return;
+ }
+ _output.WriteLine("Exception not thrown for null resolver");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with null custom resolver and style sheet has no import/include, should not error")]
+ [InlineData()]
+ [Theory(Skip = "By design bug #84957: Skip this test for Load(url, resolver)")]
+ public void LoadGeneric6()
+ {
+ // By design bug #84957: Skip this test for Load(url, resolver)
+
+ //if (MyInputType() == InputType.URI)
+ //{
+ // _output.WriteLine("By design bug #84957: Skip this test for Load(url, resolver)");
+ // return TEST_SKIPPED;
+ //}
+
+ CustomNullResolver myResolver = new CustomNullResolver(null);
+ if (LoadXSL_Resolver("ShowParam.xsl", myResolver) == 1)
+ {
+ if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ else
+ {
+ _output.WriteLine("Failed to load style sheet!");
+ Assert.True(false);
+ }
+ }
+
+ //[Variation("Style sheet has import/include, call Load first with custom null resolver and then default resolver, should not fail")]
+ [InlineData()]
+ [Theory(Skip = "By design bug #84957: Skip this test for Load(url, resolver)")]
+ public void LoadGeneric7()
+ {
+ // By design bug #84957: Skip this test for Load(url, resolver)
+
+ //if (MyInputType() == InputType.URI)
+ //{
+ // _output.WriteLine("By design bug #84957: Skip this test for Load(url, resolver)");
+ // return TEST_SKIPPED;
+ //}
+
+ CustomNullResolver myResolver = new CustomNullResolver(null);
+
+ try
+ {
+ LoadXSL_Resolver("xmlResolver_main.xsl", myResolver);
+ }
+ catch (System.Xml.Xsl.XsltCompileException e)
+ {
+ CheckExpectedError(e.InnerException, "System.Data.Sqlxml", "Xslt_CantResolve", new string[] { new Uri(FullFilePath("XmlResolver_Include.xsl", false)).ToString() });
+ if (LoadXSL("xmlResolver_main.xsl") == 1)
+ {
+ if ((Transform("fruits.xml") == 1) && (CheckResult(428.8541842246) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ else
+ {
+ _output.WriteLine("Failed to load stylesheet using default resolver");
+ Assert.True(false);
+ }
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Style sheet has import/include, call Load first with default resolver and then with custom null resolver, should fail")]
+ [InlineData()]
+ [Theory(Skip = "By design bug #84957: Skip this test for Load(url, resolver)")]
+ public void LoadGeneric8()
+ {
+ // By design bug #84957: Skip this test for Load(url, resolver)
+
+ //if (MyInputType() == InputType.URI)
+ //{
+ // _output.WriteLine("By design bug #84957: Skip this test for Load(url, resolver)");
+ // return TEST_SKIPPED;
+ //}
+
+ CustomNullResolver myResolver = new CustomNullResolver(null);
+
+ if ((LoadXSL("xmlResolver_main.xsl") == 1))
+ {
+ try
+ {
+ LoadXSL_Resolver("xmlResolver_main.xsl", myResolver);
+ }
+ catch (System.Xml.Xsl.XsltCompileException e)
+ {
+ CheckExpectedError(e.InnerException, "System.Data.Sqlxml", "Xslt_CantResolve", new string[] { new Uri(FullFilePath("XmlResolver_Include.xsl", false)).ToString() });
+ return;
+ }
+ _output.WriteLine("No exception generated when loading with an invalid resolver after loading with valid resolver");
+ Assert.True(false);
+ }
+ _output.WriteLine("Could not load style sheet with default resolver");
+ Assert.True(false);
+ }
+
+ //[Variation("Load with resolver with credentials, then load XSL that does not need cred.")]
+ [InlineData()]
+ [Theory(Skip = "Resolving of External URIs is no longer allowed")]
+ public void LoadGeneric9()
+ {
+ if ((LoadXSL_Resolver("xmlResolver_Main.xsl", GetDefaultCredResolver()) == 1))
+ {
+ if ((LoadXSL("xmlResolver_Main.xsl") == 1) && (Transform("fruits.xml") == 1)
+ && (CheckResult(428.8541842246) == 1))
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Failed to load!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load() many times with null resolver then perform a transform")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric10()
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ if (LoadXSL_Resolver("showParam.xsl", null) != 1)
+ {
+ _output.WriteLine("Failed to load stylesheet showParam.xsl on the {0} attempt", i);
+ Assert.True(false);
+ }
+ }
+ if ((LoadXSL_Resolver("showParam.xsl", null) == 1) && (Transform("fruits.xml") == 1)
+ && (CheckResult(466.5112789241) == 1))
+ return;
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with null Resolver, file does not exist")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric11()
+ {
+ try
+ {
+ LoadXSL_Resolver("IDontExist.xsl", null);
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Load non existing stylesheet with null resolver and try to transform")]
+ [InlineData()]
+ [Theory]
+ public void LoadGeneric12()
+ {
+ if (LoadXSL_Resolver("showParam.xsl", null) == 1)
+ {
+ try
+ {
+ LoadXSL_Resolver("IDontExist.xsl", null);
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ //no stylesheet loaded, should throw error
+ try
+ {
+ Transform("fruits.xml");
+ }
+ catch (System.InvalidOperationException e2)
+ {
+ CheckExpectedError(e2, "system.xml", "Xslt_NoStylesheetLoaded", new string[] { "IDontExist.xsl" });
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ }
+ else
+ {
+ _output.WriteLine("Errors loading initial file");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Load(Url, Resolver) */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Load(Url, Resolver) : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltTransform.Load(Url, Resolver) : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load(Url, Resolver) : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load(Url, Resolver) : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ public class CLoadUrlResolverTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadUrlResolverTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Basic check for usage of credentials on resolver, load XSL that needs cred. with correct resolver")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrlResolver1()
+ {
+ // XsltResolverTestMain.xsl is placed in IIS virtual directory
+ // which requires integrated Windows NT authentication
+ if ((LoadXSL_Resolver(("XmlResolver/XsltResolverTestMain.xsl"), GetDefaultCredResolver()) == 1) &&
+ (Transform("fruits.xml") == 1) && (CheckResult(382.4519733094) == 1))
+ return;
+
+ Assert.True(false);
+ }
+
+ //[Variation("Load XSL that needs cred. with null resolver, should fail")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrlResolver2()
+ {
+ try
+ {
+ LoadXSL_Resolver(("XmlResolver/XsltResolverTestMain.xsl"), null);
+ }
+ catch (System.Xml.Xsl.XsltException)
+ {
+ //return CheckExpectedError(e, "system.xml", "Xml_NullResolver");
+ return;
+ }
+ _output.WriteLine("Should not have been able to retrieve and resolve style sheet with null resolver");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with null source value")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrlResolver3()
+ {
+ try
+ {
+ LoadXSL_Resolver(null, new XmlUrlResolver());
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws ArgumentException
+ return;
+ }
+ _output.WriteLine("Did not throw an exception for null argument!");
+ Assert.True(false);
+ }
+ }
+
+ /****************************************************************************************/
+ /* XslTransform.Load(Reader/Navigator,XmlResolver,Evidence) - Integrity */
+ /****************************************************************************************/
+
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Reader, Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltTransform.Load(,XmlResolver,Evidence) : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CLoadReaderResolverEvidenceTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadReaderResolverEvidenceTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Call Load with null source value, null evidence")]
+ [InlineData()]
+ [Theory(Skip = "URI does not apply in this case, as Load(Url, Resolver) computes evidence from the Url")]
+ public void LoadGeneric1()
+ {
+ /*try
+ {
+ LoadXSL_Resolver_Evidence(null, new XmlUrlResolver(), null);
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws ArgumentException
+ return;
+ }
+ _output.WriteLine("Did not throw an exception for null argument!");
+ Assert.True(false);*/
+ }
+
+ //[Variation("Call Load with style sheet that has script, pass null evidence, should throw security exception")]
+ [InlineData()]
+ [Theory(Skip = "")]
+ public void LoadGeneric2()
+ {
+ /*
+ try
+ {
+ LoadXSL_Resolver_Evidence("scripting_unsafe_object.xsl", new XmlUrlResolver(), null);
+ }
+ catch(System.Security.Policy.PolicyException e)
+ {
+ _output.WriteLine(e.ToString());
+ return;
+ }
+ _output.WriteLine("Did not throw a security exception for null evidence!");
+ Assert.True(false);
+ */
+ //return TEST_SKIPPED;
+ }
+
+ //[Variation("Call Load with style sheet that has script, pass correct evidence")]
+ [InlineData()]
+ [Theory(Skip = "Not InProc")]
+ public void LoadGeneric3()
+ {
+ //if (_isInProc)
+ // return TEST_SKIPPED;
+
+ /*Evidence evidence = new Evidence();
+ evidence.AddHost(new Zone(SecurityZone.MyComputer));
+ try
+ {
+ LoadXSL_Resolver_Evidence("scripting_unsafe_object.xsl", new XmlUrlResolver(), evidence);
+ }
+ catch (System.Security.Policy.PolicyException)
+ {
+ _output.WriteLine("Should not throw a security exception for correct evidence!");
+ Assert.True(false);
+ }
+ return;*/
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Load(Url) */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Load(Url) Integrity : URI, Stream", Desc = "URI,STREAM")]
+ public class CLoadStringTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadStringTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Call Load with an invalid uri")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl1()
+ {
+ try
+ {
+ LoadXSL("IDontExist.xsl", InputType.URI);
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Load file with empty string")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl2()
+ {
+ try
+ {
+ LoadXSL(szEmpty, InputType.URI);
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws ArgumentException
+ return;
+ }
+ _output.WriteLine("Exception not generated for an empty string filename");
+ Assert.True(false);
+ }
+
+ //[Variation("Load with \".\"")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl3()
+ {
+ try
+ {
+ LoadXSL(".", InputType.URI);
+ }
+ catch (System.UnauthorizedAccessException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Load with \"..\"")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl()
+ {
+ try
+ {
+ LoadXSL("..", InputType.URI);
+ }
+ catch (System.UnauthorizedAccessException)
+ {
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ Assert.True(false);
+ }
+
+ //[Variation("Load with \"\\\\\"")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl5()
+ {
+ try
+ {
+ LoadXSL("\\\\", InputType.URI);
+ }
+ catch (System.ArgumentException)
+ {
+ // System.Xml.XmlUrlResolver.ResolveUri(Uri baseUri, String relativeUri) throws ArgumentException
+ return;
+ }
+ _output.WriteLine("Exception not generated for non-existent file parameter name");
+ Assert.True(false);
+ }
+
+ /*
+
+ //[Variation("Call Load with style sheet that has script, pass Url which does not have correct evidence, should fail")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl6()
+ {
+ try
+ {
+ LoadXSL_Resolver(FullHttpPath("XmlResolver/scripting_unsafe_object.xsl"), GetDefaultCredResolver());
+ }
+ catch(System.Security.Policy.PolicyException)
+ {
+ return;
+ }
+ _output.WriteLine("Should throw a security exception for incorrect evidence!");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Load with style sheet that has script, pass Url which has correct evidence, should pass")]
+ [InlineData()]
+ [Theory]
+ public void LoadUrl7()
+ {
+ try
+ {
+ LoadXSL("scripting_unsafe_object.xsl");
+ }
+ catch(System.Security.Policy.PolicyException)
+ {
+ _output.WriteLine("Should not throw a security exception for correct evidence!");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ */
+ }
+
+ /***********************************************************/
+ /* XslTransform.Load(IXPathNavigable) */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform .Load(IXPathNavigable) : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CLoadXPathNavigableTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadXPathNavigableTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Basic Verification Test")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadNavigator1()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+ String _strXslFile = "showParam.xsl";
+
+ _strXslFile = FullFilePath(_strXslFile);
+ _output.WriteLine("Compiling {0}", _strXslFile);
+
+#pragma warning disable 0618
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
+ xrLoad.Dispose();
+ xslt.Load(xdTemp);
+
+ if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
+ return;
+ Assert.True(false);
+ }
+
+ //[Variation("Create Navigator and navigate away from root")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadNavigator2()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
+#pragma warning restore 0618
+ XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
+ xrLoad.Dispose();
+ XPathNavigator xP = ((IXPathNavigable)xdTemp).CreateNavigator();
+
+ xP.MoveToNext();
+ xslt.Load(xP);
+
+ if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
+ return;
+ Assert.True(false);
+ }
+
+ //[Variation("Basic check for usage of credentials on resolver, load XSL that needs cred. with correct resolver")]
+ [InlineData()]
+ [Theory]
+ public void LoadNavigator3()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("XmlResolver/XsltResolverTestMain.xsl")));
+#pragma warning restore 0618
+ xrLoad.XmlResolver = GetDefaultCredResolver();
+
+ XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
+ XPathNavigator xP = ((IXPathNavigable)xdTemp).CreateNavigator();
+
+ xslt.Load(xP, GetDefaultCredResolver());
+ if ((Transform("fruits.xml") == 1) && (CheckResult(382.4519733094) == 1))
+ return;
+
+ Assert.True(false);
+ }
+
+ //[Variation("Regression case for bug 80768")]
+ [InlineData()]
+ [Theory(Skip = "Not InProc")]
+ public void LoadNavigator4()
+ {
+ //if (_isInProc)
+ // return TEST_SKIPPED;
+
+#pragma warning disable 0618
+ xslt = new XslTransform();
+
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("Bug80768.xsl")));
+#pragma warning restore 0618
+ XPathDocument xd = new XPathDocument(xrLoad, XmlSpace.Preserve);
+
+ xslt.Load(xd);
+
+ FileStream fs = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
+ XPathNavigator xn = new MyNavigator(FullFilePath("foo.xml"));
+ xslt.Transform(xn, null, fs);
+ fs.Dispose();
+
+ if (CheckResult(383.0855503831) == 1)
+ return;
+ else
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Load(Reader) */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Load(Reader) : Reader, Stream", Desc = "READER,STREAM")]
+ public class CLoadReaderTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CLoadReaderTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Basic Verification Test")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader1()
+ {
+ Boolean fTEST_FAIL = false;
+#pragma warning disable 0618
+ xslt = new XslTransform();
+
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ try
+ {
+ xslt.Load(xrTemp);
+ }
+ catch (Exception ex)
+ {
+ fTEST_FAIL = true;
+ throw (ex);
+ }
+ finally
+ {
+ xrTemp.Dispose();
+ }
+ if (fTEST_FAIL)
+ Assert.True(false);
+ if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
+ return;
+ Assert.True(false);
+ }
+
+ //[Variation("Calling with a closed reader, should throw exception")]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader2()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ xrTemp.Dispose();
+
+ try
+ {
+ xslt.Load(xrTemp);
+ }
+ catch (System.Xml.Xsl.XsltCompileException e)
+ {
+ CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" });
+ return;
+ }
+ _output.WriteLine("No exception thrown for a loading a closed reader!");
+ Assert.True(false);
+ }
+
+ //[Variation("Verify Reader isn't closed after Load")]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader3()
+ {
+ Boolean fTEST_FAIL = false;
+#pragma warning disable 0618
+ xslt = new XslTransform();
+
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ try
+ {
+ xslt.Load(xrTemp);
+ }
+ catch (Exception ex)
+ {
+ fTEST_FAIL = true;
+ throw (ex);
+ }
+ finally
+ {
+ if (!fTEST_FAIL || (xrTemp.ReadState != ReadState.Closed))
+ fTEST_FAIL = false;
+ xrTemp.Dispose();
+ }
+ if (fTEST_FAIL)
+ {
+ _output.WriteLine("Appear to have accidently closed the Reader");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Verify position of node in Reader is at EOF after Load")]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader4()
+ {
+ Boolean fTEST_FAIL = false;
+#pragma warning disable 0618
+ xslt = new XslTransform();
+
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ try
+ {
+ xslt.Load(xrTemp);
+ }
+ catch (Exception ex)
+ {
+ fTEST_FAIL = true;
+ throw (ex);
+ }
+ finally
+ {
+ if (!fTEST_FAIL && (!xrTemp.EOF))
+ fTEST_FAIL = false;
+ xrTemp.Dispose();
+ }
+ if (fTEST_FAIL)
+ {
+ _output.WriteLine("Reader does not appear to be at the end of file.");
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Load with reader position at EOF, should throw exception")]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader5()
+ {
+ Boolean fTEST_FAIL = false;
+#pragma warning disable 0618
+ xslt = new XslTransform();
+
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ xslt.Load(xrTemp);
+ try
+ {
+ xslt.Load(xrTemp); // should now be at end and should give exception
+ fTEST_FAIL = true;
+ }
+ catch (System.Xml.Xsl.XsltCompileException e)
+ {
+ CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" });
+ }
+ finally
+ {
+ xrTemp.Dispose();
+ }
+ if (fTEST_FAIL)
+ Assert.True(false);
+ return;
+ }
+
+ //[Variation("Load with NULL reader, should throw System.ArgumentNullException")]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader6()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+
+ XmlTextReader xrTemp = null;
+
+ try
+ {
+ xslt.Load(xrTemp); // should now be at end and should give exception
+ }
+ catch (System.ArgumentNullException)
+ {
+ return;
+ }
+ _output.WriteLine("Failed to throw System.ArgumentNullException for NULL reader input");
+ Assert.True(false);
+ }
+
+ //[Variation("Basic check for usage of credentials on resolver, load XSL that needs cred. with correct resolver")]
+ [InlineData()]
+ [Theory]
+ public void LoadXmlReader7()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("XmlResolver/XsltResolverTestMain.xsl")));
+#pragma warning restore 0618
+ xrLoad.XmlResolver = GetDefaultCredResolver();
+ xslt.Load(xrLoad, GetDefaultCredResolver());
+ xrLoad.Dispose();
+
+ if ((Transform("fruits.xml") == 1) && (CheckResult(382.4519733094) == 1))
+ return;
+
+ Assert.True(false);
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Transform - Integrity */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Reader , Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltTransform.Transform() Integrity : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CTransformTestGeneric : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CTransformTestGeneric(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Basic Verification Test")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric1()
+ {
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform("fruits.xml") == 1) &&
+ (CheckResult(466.5112789241) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Load and Transform multiple times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric2()
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ if ((LoadXSL("showParam.xsl") != 1) || (Transform("fruits.xml") != 1) ||
+ (CheckResult(466.5112789241) != 1))
+ Assert.True(false);
+ }
+ return;
+ }
+
+ //[Variation("Load once, Transform many times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric3()
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ if ((Transform("fruits.xml") != 1) || (CheckResult(466.5112789241) != 1))
+ {
+ _output.WriteLine("Test failed to transform after {0} iterations", i);
+ Assert.True(false);
+ }
+ }
+ return;
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Call Transform without loading")]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric4()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+ try
+ {
+ Transform("fruits.xml");
+ }
+ catch (System.InvalidOperationException e)
+ {
+ CheckExpectedError(e, "system.xml", "Xslt_NoStylesheetLoaded", new string[] { "" });
+ return;
+ }
+ _output.WriteLine("Exception not given for a transform that didn't have a Load method instantiated");
+ Assert.True(false);
+ }
+
+ //[Variation("Closing XSL and XML files used in transform, Read access")]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric5()
+ {
+ FileStream s2;
+
+ if ((LoadXSL("showParam.xsl") == 1) && (Transform("fruits.xml") == 1))
+ {
+ s2 = new FileStream(FullFilePath("showParam.xsl"), FileMode.Open, FileAccess.Read);
+ s2.Dispose();
+
+ s2 = new FileStream(FullFilePath("fruits.xml"), FileMode.Open, FileAccess.Read);
+ s2.Dispose();
+
+ return;
+ }
+ _output.WriteLine("Encountered errors performing transform and could not verify if files were closed");
+ Assert.True(false);
+ }
+
+ /*
+ //[Variation("Closing XSL and XML files used in transform, ReadWrite access")]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric6()
+ {
+ FileStream s2;
+
+ if((LoadXSL("showParam.xsl") == TEST_PASS) && (Transform("fruits.xml") == TEST_PASS))
+ {
+ s2 = new FileStream(FullFilePath("showParam.xsl"), FileMode.Open, FileAccess.ReadWrite);
+ s2.Dispose();
+
+ s2 = new FileStream(FullFilePath("fruits.xml"), FileMode.Open, FileAccess.ReadWrite);
+ s2.Dispose();
+
+ return;
+ }
+ _output.WriteLine("Encountered errors performing transform and could not verify if files were closed");
+ Assert.True(false);
+ }
+ */
+
+ //[Variation("Bug358103 - ArgumentOutOfRangeException in forwards-compatible mode for <foo bar='{+1}'/>")]
+ [InlineData()]
+ [Theory]
+ public void TransformGeneric7()
+ {
+ try
+ {
+ LoadXSL("ForwardComp2.xsl");
+ Transform("data.xml", true);
+ }
+ catch (XsltException)
+ {
+ //LineInfo lInfo = new LineInfo(e.LineNumber, e.LinePosition, new Uri(FullFilePath("forwardcomp2.xsl", false), UriKind.Relative).ToString());
+ //CheckExpectedError(e, "System.xml", "Xslt_InvalidXPath", new string[] { "string(+1)" }, lInfo);
+ return;
+ }
+ _output.WriteLine("XsltException (Xslt_InvalidXPath) was expected");
+ Assert.True(false);
+ }
+ }
+
+ /*************************************************************/
+ /* XslTransform(,Resolver) - Integrity */
+ /*************************************************************/
+
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Reader, Reader", Desc = "READER,READER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Reader, Stream", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Reader, Writer", Desc = "READER,WRITER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Reader, TextWriter", Desc = "READER,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : URI, Reader", Desc = "URI,READER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : URI, Stream", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : URI, Writer", Desc = "URI,WRITER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Navigator, Reader", Desc = "NAVIGATOR,READER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
+ //[TestCase(Name = "XsltTransform.Transform(,XmlResolver) : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CTransformResolverTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CTransformResolverTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Pass null XmlResolver, load style sheet with import/include, should not affect transform")]
+ [InlineData()]
+ [Theory(Skip = "Resolving of External URIs is no longer allowed")]
+ public void XmlResolver1()
+ {
+ try
+ {
+ if (LoadXSL("xmlResolver_main.xsl") == 1)
+ {
+ if ((TransformResolver("fruits.xml", null) == 1) && (CheckResult(428.8541842246) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Pass null XmlResolver, load style sheet with document function, should not resolve during transform")]
+ [InlineData()]
+ [Theory]
+ public void XmlResolver2()
+ {
+ // "xmlResolver_document_function.xsl" contains
+ // <xsl:for-each select="document('xmlResolver_document_function.xml')//elem">
+
+ if (LoadXSL("xmlResolver_document_function.xsl") == 1)
+ {
+ if ((TransformResolver("fruits.xml", null) == 1) && (CheckResult(375.6079891948) == 1))
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Problem loading stylesheet!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Default XmlResolver, load style sheet with document function, should resolve during transform")]
+ [InlineData()]
+ [Theory(Skip = "SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.")]
+ public void XmlResolver3()
+ {
+ // "xmlResolver_document_function.xsl" contains
+ // <xsl:for-each select="document('xmlResolver_document_function.xml')//elem">
+
+ // SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.
+ //if (MyInputType() == InputType.URI)
+ // return TEST_SKIPPED;
+
+ if (LoadXSL("xmlResolver_document_function.xsl") == 1)
+ {
+ if ((Transform("fruits.xml") == 1) && (CheckResult(377.8217373898) == 1))
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Problem loading stylesheet with document function and default resolver!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("document() has absolute URI")]
+ [InlineData()]
+ [Theory(Skip = "When style sheet URI = Intranet zone, XmlSecureResolver does not resolve document function")]
+ public void XmlResolver5()
+ {
+ // Skip this test for Load(URI)
+ // Reason: When style sheet URI = Intranet zone, XmlSecureResolver does not resolve document function
+
+ //if (MyInputType() == InputType.URI)
+ // return TEST_SKIPPED;
+
+ // copy file on the local machine
+
+ try
+ {
+ if (!Directory.Exists("c:\\temp"))
+ {
+ Directory.CreateDirectory("c:\\temp");
+ }
+ string xmlFile = FullFilePath("xmlResolver_document_function.xml");
+ File.Copy(xmlFile, @"c:\temp\xmlResolver_document_function.xml", true);
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ _output.WriteLine("Could not copy file to local. Some other issues prevented this test from running");
+ return; //return TEST_SKIPPED;
+ }
+
+ if (LoadXSL("xmlResolver_document_function_absolute_uri.xsl") == 1)
+ {
+ if ((TransformResolver("fruits.xml", new XmlUrlResolver()) == 1) && (CheckResult(377.8217373898) == 1))
+ return;
+ else
+ {
+ _output.WriteLine("Failed to resolve document function with absolute URI.");
+ Assert.True(false);
+ }
+ }
+ else
+ {
+ _output.WriteLine("Failed to load style sheet!");
+ Assert.True(false);
+ }
+ }
+ }
+
+ /***********************************************************/
+ /* XslTransform.Transform - (String, String) */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Transform(String, String) : Reader , String", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(String, String) : URI, String", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(String, String) : Navigator, String", Desc = "NAVIGATOR,STREAM")]
+ public class CTransformStrStrTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CTransformStrStrTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Basic Verification Test")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr1()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ CallTransform(xslt, szFullFilename, _strOutFile);
+ if (CheckResult(466.5112789241) == 1)
+ return;
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Input is null")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr2()
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform(null, _strOutFile);
+ }
+ catch (System.ArgumentException)
+ { return; }
+ }
+ _output.WriteLine("Exception not generated for null input filename");
+ Assert.True(false);
+ }
+
+ //[Variation("Output file is null")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr3()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform(szFullFilename, null);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for null output filename");
+ Assert.True(false);
+ }
+
+ //[Variation("Input is nonexisting file")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr4()
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform("IDontExist.xsl", _strOutFile);
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for invalid input file");
+ Assert.True(false);
+ }
+
+ //[Variation("Output file is invalid")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr5()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform(szFullFilename, szInvalid);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for invalid output destination");
+ Assert.True(false);
+ }
+
+ //[Variation("Input is empty string")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr6()
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform(szEmpty, _strOutFile);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for empty string input file");
+ Assert.True(false);
+ }
+
+ //[Variation("Output file is empty string")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr7()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform(szFullFilename, szEmpty);
+ }
+ catch (System.ArgumentException)
+ {
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for empty output file name");
+ Assert.True(false);
+ }
+
+ //[Variation("Call Transform many times")]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr8()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ for (int i = 0; i < 50; i++)
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ CallTransform(xslt, szFullFilename, _strOutFile);
+ if (CheckResult(466.5112789241) != 1)
+ {
+ _output.WriteLine("Failed to process Load after calling {0} times", i);
+ Assert.True(false);
+ }
+ }
+ }
+ return;
+ }
+
+ //[Variation("Call without loading")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr9()
+ {
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+ try
+ {
+ xslt.Transform(FullFilePath("fruits.xml"), _strOutFile);
+ }
+ catch (System.InvalidOperationException e)
+ {
+ CheckExpectedError(e, "System.xml", "Xslt_NoStylesheetLoaded", new string[] { "" });
+ return;
+ }
+ _output.WriteLine("Exception attempting a transform without loading an XSL file");
+ Assert.True(false);
+ }
+
+ //[Variation("Output to unreachable destination")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr10()
+ {
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform("fruits.xml", "http://www.IdontExist.com/index.xml");
+ }
+ catch (System.Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ return;
+ }
+ }
+ _output.WriteLine("Exception not generated for invalid output destination");
+ Assert.True(false);
+ }
+
+ //[Variation("Input filename is \'.\', \'..\', and \'\\\\\'")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr11()
+ {
+ int iCount = 0;
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform("..", _strOutFile);
+ }
+ catch (System.Exception)
+ {
+ iCount++;
+ }
+
+ try
+ {
+ xslt.Transform(".", _strOutFile);
+ }
+ catch (System.Exception)
+ {
+ iCount++;
+ }
+
+ try
+ {
+ xslt.Transform("\\\\", _strOutFile);
+ }
+ catch (System.Exception)
+ {
+ iCount++;
+ }
+ }
+
+ if (iCount.Equals(3))
+ return;
+
+ _output.WriteLine("Exception not generated for invalid input sources");
+ Assert.True(false);
+ }
+
+ //[Variation("Output filename is \'.\', \'..\', and \'\\\\\'")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr12()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+ int iCount = 0;
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ try
+ {
+ xslt.Transform(szFullFilename, "..");
+ }
+ catch (System.Exception)
+ {
+ iCount++;
+ }
+
+ try
+ {
+ xslt.Transform(szFullFilename, ".");
+ }
+ catch (System.Exception)
+ {
+ iCount++;
+ }
+
+ try
+ {
+ xslt.Transform(szFullFilename, "\\\\");
+ }
+ catch (System.Exception)
+ {
+ iCount++;
+ }
+ }
+
+ if (iCount.Equals(3))
+ return;
+ _output.WriteLine("Exception not generated for invalid ouput destinations");
+ Assert.True(false);
+ }
+
+ //[Variation("Closing files after transform")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr13()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+ Stream strmTemp;
+
+ if (LoadXSL("showParam.xsl") == 1)
+ {
+ CallTransform(xslt, szFullFilename, _strOutFile);
+ StreamReader fs = null;
+
+ // check if I can open and close the xml file
+ fs = new StreamReader(new FileStream(szFullFilename, FileMode.Open, FileAccess.Read));
+ fs.Dispose();
+
+ strmTemp = new FileStream(szFullFilename, FileMode.Open, FileAccess.Read);
+ strmTemp.Dispose();
+
+ // check if I can open and close the output file
+ fs = new StreamReader(new FileStream(_strOutFile, FileMode.Open, FileAccess.Read));
+ fs.Dispose();
+
+ strmTemp = new FileStream(_strOutFile, FileMode.Open, FileAccess.Read);
+ strmTemp.Dispose();
+
+ return;
+ }
+ Assert.True(false);
+ }
+
+ /*
+ //[Variation("Transform(test.xml, test.xml)")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStr14()
+ {
+ String szFullFilename = FullFilePath("Bug75295.xml");
+
+ // Copy this file to current directory
+ File.Delete("out.xml");
+ File.Copy(szFullFilename, "out.xml");
+
+ if(LoadXSL("Bug75295.xsl") == TEST_PASS)
+ {
+ xslt.Transform("out.xml", "out.xml");
+
+ if (CheckResult(270.5223692973) == TEST_PASS)
+ return;
+ }
+ Assert.True(false);
+ }
+ */
+ }
+
+ /***********************************************************/
+ /* XslTransform.Transform - (String, String, Resolver) */
+ /***********************************************************/
+
+ //[TestCase(Name = "XsltTransform.Transform(String, String, Resolver) : Reader , String", Desc = "READER,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(String, String, Resolver) : URI, String", Desc = "URI,STREAM")]
+ //[TestCase(Name = "XsltTransform.Transform(String, String, Resolver) : Navigator, String", Desc = "NAVIGATOR,STREAM")]
+ public class CTransformStrStrResolverTest : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CTransformStrStrResolverTest(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Pass null XmlResolver, load style sheet with import/include, should not affect transform")]
+ [InlineData()]
+ [Theory(Skip = "Resolving of External URIs is no longer allowed")]
+ public void TransformStrStrResolver1()
+ {
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ try
+ {
+ if (LoadXSL("xmlResolver_main.xsl") == 1)
+ {
+ xslt.Transform(szFullFilename, "out.xml", null);
+ if (CheckResult(428.8541842246) == 1)
+ return;
+ else
+ Assert.True(false);
+ }
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine(e.ToString());
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Pass null XmlResolver, load style sheet with document function, should not resolve during transform")]
+ [InlineData()]
+ [Theory]
+ public void TransformStrStrResolver2()
+ {
+ // "xmlResolver_document_function.xsl" contains
+ // <xsl:for-each select="document('xmlResolver_document_function.xml')//elem">
+
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ if (LoadXSL("xmlResolver_document_function.xsl") == 1)
+ {
+ CallTransform(xslt, szFullFilename, "out.xml", null);
+ if (CheckResult(375.6079891948) == 1)
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Problem loading stylesheet!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+
+ //[Variation("Pass XmlUrlResolver, load style sheet with document function, should resolve during transform")]
+ [InlineData()]
+ [Theory(Skip = "SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.")]
+ public void TransformStrStrResolver3()
+ {
+ // "xmlResolver_document_function.xsl" contains
+ // <xsl:for-each select="document('xmlResolver_document_function.xml')//elem">
+
+ // SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.
+ //if (MyInputType() == InputType.URI)
+ // return TEST_SKIPPED;
+
+ String szFullFilename = FullFilePath("fruits.xml");
+
+ if (LoadXSL("xmlResolver_document_function.xsl") == 1)
+ {
+ xslt.Transform(szFullFilename, "out.xml", new XmlUrlResolver());
+ if (CheckResult(377.8217373898) == 1)
+ return;
+ }
+ else
+ {
+ _output.WriteLine("Problem loading stylesheet with document function and default resolver!");
+ Assert.True(false);
+ }
+ Assert.True(false);
+ }
+ }
+
+ // This testcase is for bugs 109429, 111075 and 109644 fixed in Everett SP1
+ //[TestCase(Name = "NDP1_1SP1 Bugs (URI,STREAM)", Desc = "URI,STREAM")]
+ //[TestCase(Name = "NDP1_1SP1 Bugs (NAVIGATOR,TEXTWRITER)", Desc = "NAVIGATOR,TEXTWRITER")]
+ public class CNDP1_1SP1Test : XsltApiTestCaseBase
+ {
+ private ITestOutputHelper _output;
+ public CNDP1_1SP1Test(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ //[Variation("Local parameter gets overwritten with global param value", Pri = 1)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void var1()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("param1", string.Empty, "global-param1-arg");
+
+ if ((LoadXSL("paramScope.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) && (CheckResult(473.4644857331) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Local parameter gets overwritten with global variable value", Pri = 1)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void var2()
+ {
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddParam("param1", string.Empty, "global-param1-arg");
+
+ if ((LoadXSL("varScope.xsl") == 1) && (Transform_ArgList("fruits.xml") == 1) && (CheckResult(473.4644857331) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Subclassed XPathNodeIterator returned from an extension object or XsltFunction is not accepted by XPath", Pri = 1)]
+ [InlineData()]
+ [Theory(Skip = "SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.")]
+ public void var3()
+ {
+ // SQLBU Defect Tracking Bug 430834: Skipping when input type is URI, see bug for more details.
+ //if (MyInputType() == InputType.URI)
+ // return TEST_SKIPPED;
+
+ m_xsltArg = new XsltArgumentList();
+ m_xsltArg.AddExtensionObject("http://foo.com", new MyXsltExtension());
+
+ if ((LoadXSL("Bug111075.xsl") == 1) && (Transform_ArgList("Bug111075.xml") == 1) && (CheckResult(444.7202431861) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+
+ //[Variation("Iterator using for-each over a variable is not reset correctly while using msxsl:node-set()", Pri = 1)]
+ [ActiveIssue(9877)]
+ [InlineData()]
+ [Theory]
+ public void var4()
+ {
+ if ((LoadXSL("Bug109644.xsl") == 1) && (Transform("foo.xml") == 1) && (CheckResult(417.2501860011) == 1))
+ return;
+ else
+ Assert.True(false);
+ }
+ }
+
+ internal class MyArrayIterator : XPathNodeIterator
+ {
+ protected ArrayList array;
+ protected int index;
+
+ public MyArrayIterator(ArrayList array)
+ {
+ this.array = array;
+ this.index = 0;
+ }
+
+ public MyArrayIterator(MyArrayIterator it)
+ {
+ this.array = it.array;
+ this.index = it.index;
+ }
+
+ public override XPathNodeIterator Clone()
+ {
+ return new MyArrayIterator(this);
+ }
+
+ public override bool MoveNext()
+ {
+ if (index < array.Count)
+ {
+ index++;
+ return true;
+ }
+ return false;
+ }
+
+ public override XPathNavigator Current
+ {
+ get
+ {
+ return (index > 0) ? (XPathNavigator)array[index - 1] : null;
+ }
+ }
+
+ public override int CurrentPosition
+ {
+ get
+ {
+ return index;
+ }
+ }
+
+ public override int Count
+ {
+ get
+ {
+ return array.Count;
+ }
+ }
+
+ public void Reset()
+ {
+ index = 0;
+ }
+
+ // BUGBUG: DCR 104760
+ public override IEnumerator GetEnumerator()
+ {
+ MyArrayIterator it = (MyArrayIterator)this.Clone();
+ it.Reset();
+ return (IEnumerator)it;
+ }
+ }
+
+ internal class MyXsltExtension
+ {
+ public XPathNodeIterator distinct(XPathNodeIterator nodeset)
+ {
+ Hashtable nodelist = new Hashtable();
+ while (nodeset.MoveNext())
+ {
+ if (!nodelist.Contains(nodeset.Current.Value))
+ {
+ nodelist.Add(nodeset.Current.Value, nodeset.Current);
+ }
+ }
+ return new MyArrayIterator(new ArrayList(nodelist.Values));
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransformMultith.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransformMultith.cs
new file mode 100644
index 0000000000..af2869b75d
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXslTransformMultith.cs
@@ -0,0 +1,182 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+using XmlCoreTest.Common;
+
+namespace System.Xml.Tests
+{
+ public class CSameInstanceXslTransformTestCase : XsltApiTestCaseBase
+ {
+ // Variables from init string
+ protected string _strPath; // Path of the data files
+
+ // Other global variables
+#pragma warning disable 0618
+ public XslTransform xsltSameInstance; // Used for same instance testing of XsltArgumentList
+#pragma warning restore 0618
+
+ protected int threadCount = 5;
+
+ private ITestOutputHelper _output;
+ public CSameInstanceXslTransformTestCase(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ Init(null);
+ }
+
+ public new void Init(object objParam)
+ {
+#pragma warning disable 0618
+ xsltSameInstance = new XslTransform();
+#pragma warning restore 0618
+ _strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");
+ return;
+ }
+
+ public virtual void Load(string _strXslFile, string _strXmlFile)
+ {
+ }
+
+ public virtual int Transform(object args)
+ {
+ return 0;
+ }
+
+ //[Variation("Basic Test", Params = new object[] { "xslt_multithreading_test.xsl", "foo.xml" })]
+ [InlineData("xslt_multithreading_test.xsl", "foo.xml")]
+ //[Variation("AVTs", Params = new object[] { "xslt_multith_AVTs.xsl", "xslt_multith_AVTs.xml" })]
+ [InlineData("xslt_multith_AVTs.xsl", "xslt_multith_AVTs.xml")]
+ //[Variation("xsl:key", Params = new object[] { "xslt_multith_keytest.xsl", "xslt_multith_keytest.xml" })]
+ [InlineData("xslt_multith_keytest.xsl", "xslt_multith_keytest.xml")]
+ //[Variation("xsl:sort", Params = new object[] { "xslt_multith_sorting.xsl", "xslt_multith_sorting.xml" })]
+ [InlineData("xslt_multith_sorting.xsl", "xslt_multith_sorting.xml")]
+ //[Variation("Attribute Sets", Params = new object[] { "xslt_mutith_attribute_sets.xsl", "xslt_mutith_attribute_sets.xml" })]
+ [InlineData("xslt_mutith_attribute_sets.xsl", "xslt_mutith_attribute_sets.xml")]
+ //[Variation("Boolean Expression AND", Params = new object[] { "xslt_mutith_boolean_expr_and.xsl", "xslt_mutith_boolean_expr_and.xml" })]
+ [InlineData("xslt_mutith_boolean_expr_and.xsl", "xslt_mutith_boolean_expr_and.xml")]
+ //[Variation("Boolean Expression OR", Params = new object[] { "xslt_mutith_boolean_expr_or.xsl", "xslt_mutith_boolean_expr_or.xml" })]
+ [InlineData("xslt_mutith_boolean_expr_or.xsl", "xslt_mutith_boolean_expr_or.xml")]
+ //[Variation("FormatNubmer function", Params = new object[] { "xslt_mutith_format_number.xsl", "xslt_mutith_format_number.xml" })]
+ [InlineData("xslt_mutith_format_number.xsl", "xslt_mutith_format_number.xml")]
+ //[Variation("Position() function", Params = new object[] { "xslt_mutith_position_func.xsl", "xslt_mutith_position_func.xml" })]
+ [InlineData("xslt_mutith_position_func.xsl", "xslt_mutith_position_func.xml")]
+ //[Variation("preserve space", Params = new object[] { "xslt_mutith_preserve_space.xsl", "xslt_mutith_preserve_space.xml" })]
+ [InlineData("xslt_mutith_preserve_space.xsl", "xslt_mutith_preserve_space.xml")]
+ //[Variation("Variable nodeset", Params = new object[] { "xslt_mutith_variable_nodeset.xsl", "xslt_mutith_variable_nodeset.xml" })]
+ [InlineData("xslt_mutith_variable_nodeset.xsl", "xslt_mutith_variable_nodeset.xml")]
+ //[Variation("Forward global variable reference", Params = new object[] { "xslt_mutith_variable_global_forward_ref.xsl", "xslt_mutith_variable_nodeset.xml" })]
+ [InlineData("xslt_mutith_variable_global_forward_ref.xsl", "xslt_mutith_variable_nodeset.xml")]
+ //[Variation("Forward global variable reference deep", Params = new object[] { "xslt_mutith_variable_global_forward_ref_deep.xsl", "xslt_mutith_variable_nodeset.xml" })]
+ [InlineData("xslt_mutith_variable_global_forward_ref_deep.xsl", "xslt_mutith_variable_nodeset.xml")]
+ //[Variation("Local and global variables", Params = new object[] { "xslt_mutith_variable_local_and_global.xsl", "xslt_mutith_variable_local_and_global.xsl" })]
+ [InlineData("xslt_mutith_variable_local_and_global.xsl", "xslt_mutith_variable_local_and_global.xsl")]
+ [Theory]
+ public void Variations(object param0, object param1)
+ {
+ String xslFile = (String)param0;
+ String xmlFile = (String)param1;
+
+ Load(xslFile, xmlFile);
+
+ CThreads rThreads = new CThreads(_output);
+
+ for (int i = 0; i < threadCount; i++)
+ rThreads.Add(new ThreadFunc(Transform), i + 1);
+
+ //Wait until they are complete
+ rThreads.Start();
+ rThreads.Wait();
+
+ return;
+ }
+ }
+
+ //[TestCase(Name = "Same instance testing: Transform() - READER")]
+ public class SameInstanceXslTransformReader : CSameInstanceXslTransformTestCase
+ {
+ private XPathDocument _xd; // Loads XML file
+
+ private ITestOutputHelper _output;
+ public SameInstanceXslTransformReader(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ public override void Load(string _strXslFile, string _strXmlFile)
+ {
+#pragma warning disable 0618
+ XmlValidatingReader xrData = new XmlValidatingReader(new XmlTextReader(_strPath + _strXmlFile));
+#pragma warning restore 0618
+ _xd = new XPathDocument(xrData, XmlSpace.Preserve);
+ xrData.Dispose();
+
+#pragma warning disable 0618
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(_strPath + _strXslFile));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ xsltSameInstance.Load(xrTemp);
+ }
+
+ public override int Transform(object args)
+ {
+ for (int i = 1; i <= 100; i++)
+ {
+ XmlReader xr = null;
+ xr = xsltSameInstance.Transform(_xd, null);
+ }
+
+ //_output.WriteLine("Transform: Thread " + args + ": Done with READER transform...");
+ return 1;
+ }
+ }
+
+ //[TestCase(Name = "Same instance testing: Transform() - TEXTWRITER")]
+ public class SameInstanceXslTransformWriter : CSameInstanceXslTransformTestCase
+ {
+ private XPathDocument _xd; // Loads XML file
+
+ private ITestOutputHelper _output;
+ public SameInstanceXslTransformWriter(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ public override void Load(string _strXslFile, string _strXmlFile)
+ {
+#pragma warning disable 0618
+ XmlValidatingReader xrData = new XmlValidatingReader(new XmlTextReader(_strPath + _strXmlFile));
+#pragma warning restore 0618
+ _xd = new XPathDocument(xrData, XmlSpace.Preserve);
+ xrData.Dispose();
+
+#pragma warning disable 0618
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(_strPath + _strXslFile));
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ xsltSameInstance.Load(xrTemp);
+ }
+
+ public override int Transform(object args)
+ {
+ for (int i = 1; i <= 100; i++)
+ {
+ using (XmlTextWriter tw = new XmlTextWriter(System.IO.TextWriter.Null))
+ {
+ xsltSameInstance.Transform(_xd, null, tw);
+ }
+ }
+
+ //_output.WriteLine("Transform: Thread " + args + ": Done with WRITER transform...");
+ return 1;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltArgumentListMultith.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltArgumentListMultith.cs
new file mode 100644
index 0000000000..e606815d90
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltArgumentListMultith.cs
@@ -0,0 +1,301 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+using XmlCoreTest.Common;
+
+namespace System.Xml.Tests
+{
+ public class CSameInstanceXsltArgTestCase : XsltApiTestCaseBase
+ {
+ // Variables from init string
+ protected string _strPath; // Path of the data files
+
+ // Other global variables
+ public XsltArgumentList xsltArg1; // Shared XsltArgumentList for same instance testing
+
+ private ITestOutputHelper _output;
+ public CSameInstanceXsltArgTestCase(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ Init(null);
+ }
+
+ public new void Init(object objParam)
+ {
+ // Get parameter info
+ _strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");
+
+ xsltArg1 = new XsltArgumentList();
+
+ MyObject obj1 = new MyObject(1, _output);
+ MyObject obj2 = new MyObject(2, _output);
+ MyObject obj3 = new MyObject(3, _output);
+ MyObject obj4 = new MyObject(4, _output);
+ MyObject obj5 = new MyObject(5, _output);
+
+ xsltArg1.AddExtensionObject("urn:my-obj1", obj1);
+ xsltArg1.AddExtensionObject("urn:my-obj2", obj2);
+ xsltArg1.AddExtensionObject("urn:my-obj3", obj3);
+ xsltArg1.AddExtensionObject("urn:my-obj4", obj4);
+ xsltArg1.AddExtensionObject("urn:my-obj5", obj5);
+
+ xsltArg1.AddParam("myArg1", szEmpty, "Test1");
+ xsltArg1.AddParam("myArg2", szEmpty, "Test2");
+ xsltArg1.AddParam("myArg3", szEmpty, "Test3");
+ xsltArg1.AddParam("myArg4", szEmpty, "Test4");
+ xsltArg1.AddParam("myArg5", szEmpty, "Test5");
+
+ return;
+ }
+ }
+
+ //[TestCase(Name = "Same instance testing: XsltArgList - GetParam", Desc = "GetParam test cases")]
+ public class CSameInstanceXsltArgumentListGetParam : CSameInstanceXsltArgTestCase
+ {
+ private ITestOutputHelper _output;
+ public CSameInstanceXsltArgumentListGetParam(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Same instance testing:
+ // Multiple GetParam() over same ArgumentList
+ ////////////////////////////////////////////////////////////////
+ public int GetParam1(object args)
+ {
+ Object retObj;
+
+ for (int i = 1; i <= 100; i++)
+ {
+ retObj = xsltArg1.GetParam(((object[])args)[1].ToString(), szEmpty);
+ _output.WriteLine("GetParam: Thread " + ((object[])args)[0] + "\tIteration " + i + "\tAdded Value: {0}\tRetrieved Value:{1}\n", "Test1", retObj.ToString());
+ if (retObj.ToString() != "Test1")
+ {
+ _output.WriteLine("ERROR!!!");
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ public int GetParam2(object args)
+ {
+ Object retObj;
+
+ for (int i = 1; i <= 100; i++)
+ {
+ retObj = xsltArg1.GetParam(((object[])args)[1].ToString(), szEmpty);
+ string expected = "Test" + ((object[])args)[0];
+ _output.WriteLine("GetParam: Thread " + ((object[])args)[0] + "\tIteration " + i + "\tAdded Value: {0}\tRetrieved Value:{1}\n", expected, retObj.ToString());
+ if (retObj.ToString() != expected)
+ {
+ _output.WriteLine("ERROR!!!");
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ //[Variation("Multiple GetParam for same parameter name")]
+ [InlineData()]
+ [Theory]
+ public void proc1()
+ {
+ CThreads rThreads = new CThreads(_output);
+ rThreads.Add(new ThreadFunc(GetParam1), new Object[] { 1, "myArg1" });
+ rThreads.Add(new ThreadFunc(GetParam1), new Object[] { 2, "myArg1" });
+ rThreads.Add(new ThreadFunc(GetParam1), new Object[] { 3, "myArg1" });
+ rThreads.Add(new ThreadFunc(GetParam1), new Object[] { 4, "myArg1" });
+ rThreads.Add(new ThreadFunc(GetParam1), new Object[] { 5, "myArg1" });
+
+ //Wait until they are complete
+ rThreads.Start();
+ rThreads.Wait();
+
+ return;
+ }
+
+ //[Variation("Multiple GetParam for different parameter name")]
+ [InlineData()]
+ [Theory]
+ public void proc2()
+ {
+ CThreads rThreads = new CThreads(_output);
+ rThreads.Add(new ThreadFunc(GetParam2), new Object[] { 1, "myArg1" });
+ rThreads.Add(new ThreadFunc(GetParam2), new Object[] { 2, "myArg2" });
+ rThreads.Add(new ThreadFunc(GetParam2), new Object[] { 3, "myArg3" });
+ rThreads.Add(new ThreadFunc(GetParam2), new Object[] { 4, "myArg4" });
+ rThreads.Add(new ThreadFunc(GetParam2), new Object[] { 5, "myArg5" });
+
+ //Wait until they are complete
+ rThreads.Start();
+ rThreads.Wait();
+
+ return;
+ }
+ }
+
+ //[TestCase(Name = "Same instance testing: XsltArgList - GetExtensionObject", Desc = "GetExtensionObject test cases")]
+ public class CSameInstanceXsltArgumentListGetExtnObject : CSameInstanceXsltArgTestCase
+ {
+ private ITestOutputHelper _output;
+ public CSameInstanceXsltArgumentListGetExtnObject(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Same instance testing:
+ // Multiple GetExtensionObject() over same ArgumentList
+ ////////////////////////////////////////////////////////////////
+ public int GetExtnObject1(object args)
+ {
+ Object retObj;
+
+ for (int i = 1; i <= 100; i++)
+ {
+ retObj = xsltArg1.GetExtensionObject(((object[])args)[1].ToString());
+ _output.WriteLine("GetExtensionObject: Thread " + ((object[])args)[0] + "\tIteration " + i + "\tValue returned: " + ((MyObject)retObj).MyValue());
+ if (((MyObject)retObj).MyValue() != 1)
+ {
+ _output.WriteLine("ERROR!!! Set and retrieved value appear to be different");
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ public int GetExtnObject2(object args)
+ {
+ Object retObj;
+
+ for (int i = 1; i <= 100; i++)
+ {
+ retObj = xsltArg1.GetExtensionObject(((object[])args)[1].ToString());
+ _output.WriteLine("GetExtensionObject: Thread " + ((object[])args)[0] + "\tIteration " + i + "\tValue returned: " + ((MyObject)retObj).MyValue());
+ if (((MyObject)retObj).MyValue() != (int)((object[])args)[0])
+ {
+ _output.WriteLine("ERROR!!! Set and retrieved value appear to be different");
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ //[Variation("Multiple GetExtensionObject for same namespace System.Xml.Tests")]
+ [InlineData()]
+ [Theory]
+ public void proc1()
+ {
+ CThreads rThreads = new CThreads(_output);
+ rThreads.Add(new ThreadFunc(GetExtnObject1), new Object[] { 1, "urn:my-obj1" });
+ rThreads.Add(new ThreadFunc(GetExtnObject1), new Object[] { 2, "urn:my-obj1" });
+ rThreads.Add(new ThreadFunc(GetExtnObject1), new Object[] { 3, "urn:my-obj1" });
+ rThreads.Add(new ThreadFunc(GetExtnObject1), new Object[] { 4, "urn:my-obj1" });
+ rThreads.Add(new ThreadFunc(GetExtnObject1), new Object[] { 5, "urn:my-obj1" });
+
+ //Wait until they are complete
+ rThreads.Start();
+ rThreads.Wait();
+
+ return;
+ }
+
+ //[Variation("Multiple GetExtensionObject for different namespace System.Xml.Tests")]
+ [InlineData()]
+ [Theory]
+ public void proc2()
+ {
+ CThreads rThreads = new CThreads(_output);
+ rThreads.Add(new ThreadFunc(GetExtnObject2), new Object[] { 1, "urn:my-obj1" });
+ rThreads.Add(new ThreadFunc(GetExtnObject2), new Object[] { 2, "urn:my-obj2" });
+ rThreads.Add(new ThreadFunc(GetExtnObject2), new Object[] { 3, "urn:my-obj3" });
+ rThreads.Add(new ThreadFunc(GetExtnObject2), new Object[] { 4, "urn:my-obj4" });
+ rThreads.Add(new ThreadFunc(GetExtnObject2), new Object[] { 5, "urn:my-obj5" });
+
+ //Wait until they are complete
+ rThreads.Start();
+ rThreads.Wait();
+
+ return;
+ }
+ }
+
+ //[TestCase(Name = "Same instance testing: XsltArgList - Transform", Desc = "Multiple transforms")]
+ public class CSameInstanceXsltArgumentListTransform : CSameInstanceXsltArgTestCase
+ {
+ private ITestOutputHelper _output;
+ public CSameInstanceXsltArgumentListTransform(ITestOutputHelper output) : base(output)
+ {
+ _output = output;
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Same instance testing:
+ // Multiple Transform() using shared ArgumentList
+ ////////////////////////////////////////////////////////////////
+ public int SharedArgList(object args)
+ {
+ string _strXslFile = ((object[])args)[1].ToString();
+ string _strXmlFile = ((object[])args)[2].ToString();
+
+ if (_strXslFile.Substring(0, 5) != "http:")
+ _strXslFile = _strPath + _strXslFile;
+ if (_strXmlFile.Substring(0, 5) != "http:")
+ _strXmlFile = _strPath + _strXmlFile;
+
+#pragma warning disable 0618
+ XmlValidatingReader xrData = new XmlValidatingReader(new XmlTextReader(_strXmlFile));
+ XPathDocument xd = new XPathDocument(xrData, XmlSpace.Preserve);
+ xrData.Dispose();
+
+ XslTransform xslt = new XslTransform();
+ XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ xrTemp.ValidationType = ValidationType.None;
+ xrTemp.EntityHandling = EntityHandling.ExpandCharEntities;
+ xslt.Load(xrTemp);
+
+ XmlReader xrXSLT = null;
+
+ for (int i = 1; i <= 100; i++)
+ {
+ xrXSLT = xslt.Transform(xd, xsltArg1);
+ _output.WriteLine("SharedArgumentList: Thread " + ((object[])args)[0] + "\tIteration " + i + "\tDone with transform...");
+ }
+ return 1;
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Same instance testing:
+ // Multiple Transform() using shared ArgumentList
+ ////////////////////////////////////////////////////////////////
+ //[Variation("Multiple transforms using shared ArgumentList")]
+ [InlineData()]
+ [Theory]
+ public void proc1()
+ {
+ CThreads rThreads = new CThreads(_output);
+ rThreads.Add(new ThreadFunc(SharedArgList), new object[] { 1, "xsltarg_multithreading1.xsl", "foo.xml" });
+ rThreads.Add(new ThreadFunc(SharedArgList), new object[] { 2, "xsltarg_multithreading2.xsl", "foo.xml" });
+ rThreads.Add(new ThreadFunc(SharedArgList), new object[] { 3, "xsltarg_multithreading3.xsl", "foo.xml" });
+ rThreads.Add(new ThreadFunc(SharedArgList), new object[] { 4, "xsltarg_multithreading4.xsl", "foo.xml" });
+ rThreads.Add(new ThreadFunc(SharedArgList), new object[] { 5, "xsltarg_multithreading5.xsl", "foo.xml" });
+
+ //Wait until they are complete
+ rThreads.Start();
+ rThreads.Wait();
+
+ return;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltChecksum.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltChecksum.cs
new file mode 100644
index 0000000000..68a1f9fa08
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/CXsltChecksum.cs
@@ -0,0 +1,116 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+
+public class CXsltChecksum
+{
+ private bool _fTrace; // Flag for turning on trace in CXsltCache
+ private string _strXml; // XML from the cache
+
+ private ITestOutputHelper _output;
+
+ // --------------------------------------------------------------------------------------------------
+ // Constructor
+ // --------------------------------------------------------------------------------------------------
+ public CXsltChecksum(bool fTrace, ITestOutputHelper output)
+ {
+ _fTrace = fTrace;
+ _output = output;
+ }
+
+ // --------------------------------------------------------------------------------------------------
+ // Properties
+ // --------------------------------------------------------------------------------------------------
+ public string Xml
+ {
+ get
+ {
+ return _strXml;
+ }
+ }
+
+ public double Calc(XmlReader xr)
+ {
+ Decimal dResult = 0; // Numerical value of the checksum
+ int i = 0; // Generic counter
+ int iLength = 0; // Length of the data
+ CXmlCache xc; // Cached output from XslTransform
+
+ _strXml = "";
+
+ // Load the data into the cache
+ xc = new CXmlCache();
+ xc.ExpandAttributeValues = true;
+ xc.Trace = _fTrace;
+
+ xc.Load(xr);
+ _strXml = xc.Xml;
+
+ // If there is data to write and omit-xml-declaration is "no", then write the XmlDecl to the stream
+
+ if (_strXml.Length > 0)
+ _strXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + _strXml;
+
+ // Calculate the checksum
+ iLength = _strXml.Length;
+
+ for (i = 0; i < iLength; i++)
+ {
+ dResult += Math.Round((Decimal)(_strXml[i] / (i + 1.0)), 10);
+ //_output.WriteLine("#{0}({1})", _strXml[i].ToByte(), dResult);
+ }
+ return Convert.ToDouble(dResult, NumberFormatInfo.InvariantInfo);
+ }
+
+ public double Calc(string strFileName)
+ {
+ Decimal dResult = 0; // Numerical value of the checksum
+ int i = 0; // Generic counter
+ int cBytesRead = 1; // # of bytes read at one time
+ int cTotalRead = 0; // Total # of bytes read so far
+ Decimal dEndBuffer = 0; // Buffer to remove from the end (This is necessary because
+ // notepad adds CR/LF onto the end of every file
+
+ Char[] rgBuffer = new Char[4096];
+ _strXml = "";
+
+ try
+ {
+ using (StreamReader fs = new StreamReader(new FileStream(strFileName, FileMode.Open, FileAccess.Read)))
+ {
+ cBytesRead = fs.Read(rgBuffer, 0, 4096);
+
+ while (cBytesRead > 0)
+ {
+ // Keep XML property up to date
+ _strXml = String.Concat(_strXml, new String(rgBuffer, 0, cBytesRead));
+
+ // Calculate the checksum
+ for (i = 0; i < cBytesRead; i++)
+ {
+ dResult += Math.Round((Decimal)(rgBuffer[i] / (cTotalRead + i + 1.0)), 10);
+ //_output.WriteLine("#{0}({1}) -- {2}", rgBuffer[i], dResult, rgBuffer[i].ToChar());
+ }
+ cTotalRead += cBytesRead;
+ dEndBuffer = 0;
+
+ // Keep reading (in case file is bigger than 4K)
+ cBytesRead = fs.Read(rgBuffer, 0, 4096);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _output.WriteLine(ex.Message);
+ return 0;
+ }
+ return Convert.ToDouble(dResult - dEndBuffer, NumberFormatInfo.InvariantInfo);
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/DataHelper.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/DataHelper.cs
new file mode 100644
index 0000000000..90a973cc54
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/DataHelper.cs
@@ -0,0 +1,297 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.Globalization;
+using System.Xml;
+
+public class CustomUrlResolver : XmlUrlResolver
+{
+ private ITestOutputHelper _output;
+ public CustomUrlResolver(ITestOutputHelper output)
+ {
+ _output = output;
+ }
+
+ public override Object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
+ {
+ _output.WriteLine("Getting {0}", absoluteUri);
+ return base.GetEntity(absoluteUri, role, ofObjectToReturn);
+ }
+}
+
+public class CustomNullResolver : XmlUrlResolver
+{
+ private ITestOutputHelper _output;
+ public CustomNullResolver(ITestOutputHelper output)
+ {
+ _output = output;
+ }
+
+ public override Object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
+ {
+ _output.WriteLine("Getting {0}", absoluteUri);
+ return null;
+ }
+}
+
+// These two classes are for bug 78587 repro
+public class Id
+{
+ private string _id;
+
+ public Id(string id)
+ {
+ _id = id;
+ }
+
+ public string GetId()
+ {
+ return _id;
+ }
+}
+
+public class Capitalizer
+{
+ public string Capitalize(string str)
+ {
+ return str.ToUpper();
+ }
+}
+
+public class MyObject
+{
+ private int _iUniqueVal;
+ private double _dNotUsed;
+ private String _strTestTmp;
+
+ private ITestOutputHelper _output;
+
+ // State Tests
+ public MyObject(int n, ITestOutputHelper output)
+ {
+ _iUniqueVal = n;
+ _output = output;
+ }
+
+ public MyObject(double n, ITestOutputHelper output)
+ {
+ _dNotUsed = n;
+ _output = output;
+ }
+
+ public void DecreaseCounter()
+ {
+ _iUniqueVal--;
+ }
+
+ public String ReduceCount(double n)
+ {
+ _iUniqueVal -= (int)n;
+ return _iUniqueVal.ToString();
+ }
+
+ public String AddToString(String str)
+ {
+ _strTestTmp = String.Concat(_strTestTmp, str);
+ return _strTestTmp;
+ }
+
+ public override String ToString()
+ {
+ String S = String.Format("My Custom Object has a value of {0}", _iUniqueVal);
+ return S;
+ }
+
+ public String PublicFunction()
+ {
+ return "Inside Public Function";
+ }
+
+ private String PrivateFunction()
+ {
+ return "Inside Private Function";
+ }
+
+ protected String ProtectedFunction()
+ {
+ return "Inside Protected Function";
+ }
+
+ private String DefaultFunction()
+ {
+ return "Default Function";
+ }
+
+ // Return types tests
+ public int MyValue()
+ {
+ return _iUniqueVal;
+ }
+
+ public double GetUnitialized()
+ {
+ return _dNotUsed;
+ }
+
+ public String GetNull()
+ {
+ return null;
+ }
+
+ // Basic Tests
+ public String Fn1()
+ {
+ return "Test1";
+ }
+
+ public String Fn2()
+ {
+ return "Test2";
+ }
+
+ public String Fn3()
+ {
+ return "Test3";
+ }
+
+ //Output Tests
+ public void ConsoleWrite()
+ {
+ _output.WriteLine("\r\r\n\n> Where did I see this");
+ }
+
+ public String MessMeUp()
+ {
+ return ">\" $tmp >;\'\t \n&";
+ }
+
+ public String MessMeUp2()
+ {
+ return "<xsl:variable name=\"tmp\"/>";
+ }
+
+ public String MessMeUp3()
+ {
+ return "</xsl:stylesheet>";
+ }
+
+ //Recursion Tests
+ public String RecursionSample()
+ {
+ return (Factorial(5)).ToString();
+ }
+
+ public int Factorial(int n)
+ {
+ if (n < 1)
+ return 1;
+ return (n * Factorial(n - 1));
+ }
+
+ //Overload by type
+ public String OverloadType(String str)
+ {
+ return "String Overlaod";
+ }
+
+ public String OverloadType(int i)
+ {
+ return "Int Overlaod";
+ }
+
+ public String OverloadType(double d)
+ {
+ return "Double Overload";
+ }
+
+ //Overload by arg
+ public String OverloadArgTest(string s1)
+ {
+ return "String";
+ }
+
+ public String OverloadArgTest(string s1, string s2)
+ {
+ return "String, String";
+ }
+
+ public String OverloadArgTest(string s1, double d, string s2)
+ {
+ return "String, Double, String";
+ }
+
+ public String OverloadArgTest(string s1, string s2, double d)
+ {
+ return "String, String, Double";
+ }
+
+ // Overload conversion tests
+ public String IntArg(int i)
+ {
+ return "Int";
+ }
+
+ public String BoolArg(Boolean i)
+ {
+ return "Boolean";
+ }
+
+ // Arg Tests
+ public String ArgBoolTest(Boolean bFlag)
+ {
+ if (bFlag)
+ return "Statement is True";
+ return "Statement is False";
+ }
+
+ public String ArgDoubleTest(double d)
+ {
+ String s = String.Format("Received a double with value {0}", Convert.ToString(d, NumberFormatInfo.InvariantInfo));
+ return s;
+ }
+
+ public String ArgStringTest(String s)
+ {
+ String s1 = String.Format("Received a string with value: {0}", s);
+ return s1;
+ }
+
+ //Return tests
+ public String ReturnString()
+ {
+ return "Hello world";
+ }
+
+ public int ReturnInt()
+ {
+ return 10;
+ }
+
+ public double ReturnDouble()
+ {
+ return 022.4127600;
+ }
+
+ public Boolean ReturnBooleanTrue()
+ {
+ return true;
+ }
+
+ public Boolean ReturnBooleanFalse()
+ {
+ return false;
+ }
+
+ public MyObject ReturnOther()
+ {
+ return this;
+ }
+
+ public void DoNothing()
+ {
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs
new file mode 100644
index 0000000000..080e7e5410
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs
@@ -0,0 +1,410 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Linq;
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.Reflection;
+using System.Resources;
+using System.Text.RegularExpressions;
+using System.Xml;
+
+namespace System.Xml.Tests
+{
+ public class LineInfo
+ {
+ public int LineNumber { get; private set; }
+
+ public int LinePosition { get; private set; }
+
+ public string FilePath { get; private set; }
+
+ public LineInfo(int lineNum, int linePos)
+ {
+ LineNumber = lineNum;
+ LinePosition = linePos;
+ FilePath = String.Empty;
+ }
+
+ public LineInfo(int lineNum, int linePos, string filePath)
+ {
+ LineNumber = lineNum;
+ LinePosition = linePos;
+ FilePath = filePath;
+ }
+ }
+
+ [Flags]
+ public enum ExceptionVerificationFlags
+ {
+ None = 0,
+ IgnoreMultipleDots = 1,
+ IgnoreLineInfo = 2,
+ }
+
+ public class ExceptionVerifier
+ {
+ private readonly Assembly _asm;
+ private Assembly _locAsm;
+ private readonly Hashtable _resources;
+
+ private string _actualMessage;
+ private string _expectedMessage;
+ private Exception _ex;
+
+ private ExceptionVerificationFlags _verificationFlags = ExceptionVerificationFlags.None;
+
+ private ITestOutputHelper _output;
+
+ public bool IgnoreMultipleDots
+ {
+ get
+ {
+ return (_verificationFlags & ExceptionVerificationFlags.IgnoreMultipleDots) != 0;
+ }
+ set
+ {
+ if (value)
+ _verificationFlags = _verificationFlags | ExceptionVerificationFlags.IgnoreMultipleDots;
+ else
+ _verificationFlags = _verificationFlags & (~ExceptionVerificationFlags.IgnoreMultipleDots);
+ }
+ }
+
+ public bool IgnoreLineInfo
+ {
+ get
+ {
+ return (_verificationFlags & ExceptionVerificationFlags.IgnoreLineInfo) != 0;
+ }
+ set
+ {
+ if (value)
+ _verificationFlags = _verificationFlags | ExceptionVerificationFlags.IgnoreLineInfo;
+ else
+ _verificationFlags = _verificationFlags & (~ExceptionVerificationFlags.IgnoreLineInfo);
+ }
+ }
+
+ private const string ESCAPE_ANY = "~%anything%~";
+ private const string ESCAPE_NUMBER = "~%number%~";
+
+ public ExceptionVerifier(string assemblyName, ExceptionVerificationFlags flags, ITestOutputHelper output)
+ {
+ _output = output;
+
+ if (assemblyName == null)
+ throw new VerifyException("Assembly name cannot be null");
+
+ _verificationFlags = flags;
+
+ try
+ {
+ switch (assemblyName.ToUpper())
+ {
+ case "SYSTEM.XML":
+ {
+ var dom = new XmlDocument();
+ _asm = dom.GetType().GetTypeInfo().Assembly;
+ }
+ break;
+ //case "SYSTEM.DATA":
+ //{
+ // var ds = new DataSet();
+ // asm = ds.GetType().Assembly;
+ //}
+ // break;
+ default:
+ throw new FileLoadException("Cannot load assembly from " + GetRuntimeInstallDir() + assemblyName + ".dll");
+ //asm = Assembly.LoadFrom(GetRuntimeInstallDir() + assemblyName + ".dll");
+ //break;
+ }
+
+ if (_asm == null)
+ throw new VerifyException("Can not load assembly " + assemblyName);
+
+ // let's determine if this is a loc run, if it is then we need to load satellite assembly
+ _locAsm = null;
+ if (!CultureInfo.CurrentCulture.Equals(new CultureInfo("en-US")) && !CultureInfo.CurrentCulture.Equals(new CultureInfo("en")))
+ {
+ try
+ {
+ throw new NotImplementedException("Cannot Load Satellite assembly");
+ // load satellite assembly
+ //locAsm = asm.GetSatelliteAssembly(new CultureInfo(CultureInfo.CurrentCulture.Parent.IetfLanguageTag));
+ }
+ catch (FileNotFoundException e1)
+ {
+ _output.WriteLine(e1.ToString());
+ }
+ catch (FileLoadException e2)
+ {
+ _output.WriteLine(e2.ToString());
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ _output.WriteLine("Exception: " + e.Message);
+ _output.WriteLine("Stack: " + e.StackTrace);
+ throw new VerifyException("Error while loading assembly");
+ }
+
+ string[] resArray;
+ Stream resStream = null;
+ var bFound = false;
+
+ // Check that assembly manifest has resources
+ if (null != _locAsm)
+ resArray = _locAsm.GetManifestResourceNames();
+ else
+ resArray = _asm.GetManifestResourceNames();
+
+ foreach (var s in resArray)
+ {
+ if (s.EndsWith(".resources"))
+ {
+ resStream = null != _locAsm ? _locAsm.GetManifestResourceStream(s) : _asm.GetManifestResourceStream(s);
+ bFound = true;
+ if (bFound && resStream != null)
+ {
+ // Populate hashtable from resources
+ var resReader = new ResourceReader(resStream);
+ if (_resources == null)
+ {
+ _resources = new Hashtable();
+ }
+ var ide = resReader.GetEnumerator();
+ while (ide.MoveNext())
+ {
+ if (!_resources.ContainsKey(ide.Key.ToString()))
+ _resources.Add(ide.Key.ToString(), ide.Value.ToString());
+ }
+ resReader.Dispose();
+ }
+ //break;
+ }
+ }
+
+ if (!bFound || resStream == null)
+ throw new VerifyException("GetManifestResourceStream() failed");
+ }
+
+ private static string GetRuntimeInstallDir()
+ {
+ // Get mscorlib path
+ var s = typeof(object).GetTypeInfo().Module.FullyQualifiedName;
+ // Remove mscorlib.dll from the path
+ return Directory.GetParent(s).ToString() + "\\";
+ }
+
+ public ExceptionVerifier(string assemblyName, ITestOutputHelper output)
+ : this(assemblyName, ExceptionVerificationFlags.None, output)
+ { }
+
+ private void ExceptionInfoOutput()
+ {
+ // Use reflection to obtain "res" property value
+ var exceptionType = _ex.GetType();
+ var fInfo = exceptionType.GetField("res", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase) ??
+ exceptionType.GetTypeInfo().BaseType.GetField("res", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
+
+ if (fInfo == null)
+ throw new VerifyException("Cannot obtain Resource ID from Exception.");
+
+ _output.WriteLine(
+ "\n===== Original Exception Message =====\n" + _ex.Message +
+ "\n===== Resource Id =====\n" + fInfo.GetValue(_ex) +
+ "\n===== HelpLink =====\n" + _ex.HelpLink +
+ "\n===== Source =====\n" + _ex.Source /*+
+ "\n===== TargetSite =====\n" + ex.TargetSite + "\n"*/);
+
+ _output.WriteLine(
+ "\n===== InnerException =====\n" + _ex.InnerException +
+ "\n===== StackTrace =====\n" + _ex.StackTrace);
+ }
+
+ public string[] ReturnAllMatchingResIds(string message)
+ {
+ var ide = _resources.GetEnumerator();
+ var list = new ArrayList();
+
+ _output.WriteLine("===== All mached ResIDs =====");
+ while (ide.MoveNext())
+ {
+ var resMessage = ide.Value.ToString();
+
+ resMessage = ESCAPE_ANY + Regex.Replace(resMessage, @"\{\d*\}", ESCAPE_ANY) + ESCAPE_ANY;
+ resMessage = MakeEscapes(resMessage).Replace(ESCAPE_ANY, ".*");
+ if (Regex.Match(message, resMessage, RegexOptions.Singleline).ToString() == message)
+ {
+ list.Add(ide.Key);
+ _output.WriteLine(" [" + ide.Key.ToString() + "] = \"" + ide.Value.ToString() + "\"");
+ }
+ }
+
+ return (string[])list.ToArray(typeof(string[]));
+ }
+
+ // Common helper methods used by different overloads of IsExceptionOk()
+ private static void CheckNull(Exception e)
+ {
+ if (e == null)
+ {
+ throw new VerifyException("NULL exception passed to IsExceptionOk()");
+ }
+ }
+
+ private void CompareMessages()
+ {
+ if (IgnoreMultipleDots && _expectedMessage.EndsWith("."))
+ _expectedMessage = _expectedMessage.TrimEnd(new char[] { '.' }) + ".";
+ _expectedMessage = Regex.Escape(_expectedMessage);
+ _expectedMessage = _expectedMessage.Replace(ESCAPE_ANY, ".*");
+ _expectedMessage = _expectedMessage.Replace(ESCAPE_NUMBER, @"\d*");
+
+ // ignore case
+ _expectedMessage = _expectedMessage.ToLowerInvariant();
+ _actualMessage = _actualMessage.ToLowerInvariant();
+ if (Regex.Match(_actualMessage, _expectedMessage, RegexOptions.Singleline).ToString() != _actualMessage)
+ {
+ // Unescape before printing the expected message string
+ _expectedMessage = Regex.Unescape(_expectedMessage);
+ _output.WriteLine("Mismatch in error message");
+ _output.WriteLine("===== Expected Message =====\n" + _expectedMessage);
+ _output.WriteLine("===== Expected Message Length =====\n" + _expectedMessage.Length);
+ _output.WriteLine("===== Actual Message =====\n" + _actualMessage);
+ _output.WriteLine("===== Actual Message Length =====\n" + _actualMessage.Length);
+ throw new VerifyException("Mismatch in error message");
+ }
+ }
+
+ public void IsExceptionOk(Exception e, string expectedResId)
+ {
+ CheckNull(e);
+ _ex = e;
+ if (expectedResId == null)
+ {
+ // Pint actual exception info and quit
+ // This can be used to dump exception properties, verify them and then plug them into our expected results
+ ExceptionInfoOutput();
+ throw new VerifyException("Did not pass resource ID to verify");
+ }
+
+ IsExceptionOk(e, new object[] { expectedResId });
+ }
+
+ public void IsExceptionOk(Exception e, string expectedResId, string[] paramValues)
+ {
+ var list = new ArrayList { expectedResId };
+
+ foreach (var param in paramValues)
+ list.Add(param);
+
+ IsExceptionOk(e, list.ToArray());
+ }
+
+ public void IsExceptionOk(Exception e, string expectedResId, string[] paramValues, LineInfo lineInfo)
+ {
+ var list = new ArrayList { expectedResId, lineInfo };
+
+ foreach (var param in paramValues)
+ list.Add(param);
+
+ IsExceptionOk(e, list.ToArray());
+ }
+
+ public void IsExceptionOk(Exception e, object[] IdsAndParams)
+ {
+ CheckNull(e);
+ _ex = e;
+
+ _actualMessage = e.Message;
+ _expectedMessage = ConstructExpectedMessage(IdsAndParams);
+
+ CompareMessages();
+ }
+
+ private static string MakeEscapes(string str)
+ {
+ return new[] { "\\", "$", "{", "[", "(", "|", ")", "*", "+", "?" }.Aggregate(str, (current, esc) => current.Replace(esc, "\\" + esc));
+ }
+
+ public string ConstructExpectedMessage(object[] IdsAndParams)
+ {
+ var lineInfoMessage = "";
+ var paramList = new ArrayList();
+ var paramsStartPosition = 1;
+
+ // Verify that input list contains at least one element - ResId
+ if (IdsAndParams.Length == 0 || !(IdsAndParams[0] is string))
+ throw new VerifyException("ResID at IDsAndParams[0] missing!");
+ string expectedResId = (IdsAndParams[0] as string);
+
+ // Verify that resource id exists in resources
+ if (!_resources.ContainsKey(expectedResId))
+ {
+ ExceptionInfoOutput();
+ throw new VerifyException("Resources in [" + _asm.GetName().Name + "] does not contain string resource: " + expectedResId);
+ }
+
+ // If LineInfo exist, construct LineInfo message
+ if (IdsAndParams.Length > 1 && (IdsAndParams[1] is LineInfo))
+ {
+ if (!IgnoreLineInfo)
+ {
+ var lineInfo = (IdsAndParams[1] as LineInfo);
+
+ // Xml_ErrorPosition = "Line {0}, position {1}."
+ lineInfoMessage = String.IsNullOrEmpty(lineInfo.FilePath) ? _resources["Xml_ErrorPosition"].ToString() : _resources["Xml_ErrorFilePosition"].ToString();
+
+ var lineNumber = lineInfo.LineNumber.ToString();
+ var linePosition = lineInfo.LinePosition.ToString();
+ lineInfoMessage = String.IsNullOrEmpty(lineInfo.FilePath) ? String.Format(lineInfoMessage, lineNumber, linePosition) : String.Format(lineInfoMessage, lineInfo.FilePath, lineNumber, linePosition);
+ }
+ else
+ lineInfoMessage = ESCAPE_ANY;
+
+ lineInfoMessage = " " + lineInfoMessage;
+ paramsStartPosition = 2;
+ }
+
+ string message = _resources[expectedResId].ToString();
+ for (var i = paramsStartPosition; i < IdsAndParams.Length; i++)
+ {
+ if (IdsAndParams[i] is object[])
+ paramList.Add(ConstructExpectedMessage(IdsAndParams[i] as object[]));
+ else
+ {
+ if (IdsAndParams[i] == null)
+ paramList.Add(ESCAPE_ANY);
+ else
+ paramList.Add(IdsAndParams[i] as string);
+ }
+ }
+
+ try
+ {
+ message = string.Format(message, paramList.ToArray());
+ }
+ catch (FormatException)
+ {
+ throw new VerifyException("Mismatch in number of parameters!");
+ }
+
+ return message + lineInfoMessage;
+ }
+ }
+
+ public class VerifyException : Exception
+ {
+ public VerifyException(string msg)
+ : base(msg)
+ { }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/MyNavigator.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/MyNavigator.cs
new file mode 100644
index 0000000000..997ad1fb0e
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/MyNavigator.cs
@@ -0,0 +1,181 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+/// <summary>
+/// Summary description for Class3.
+/// </summary>
+public class MyNavigator : XPathNavigator
+{
+ private XPathNavigator _xn;
+ private string _strFileName;
+
+ public MyNavigator(string filename)
+ {
+ _strFileName = filename;
+ _xn = new XPathDocument(filename, XmlSpace.None).CreateNavigator();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.Clone"]/*' />
+ public override XPathNavigator Clone()
+ {
+ return new MyNavigator(_strFileName);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.NodeType"]/*' />
+ public override XPathNodeType NodeType { get { return _xn.NodeType; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.LocalName"]/*' />
+ public override string LocalName { get { return _xn.LocalName; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.NamespaceURI"]/*' />
+ public override string NamespaceURI { get { return _xn.NamespaceURI; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.Name"]/*' />
+ public override string Name { get { return _xn.Name; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.Prefix"]/*' />
+ public override string Prefix { get { return _xn.Prefix; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.Value"]/*' />
+ public override string Value { get { return _xn.Value; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.BaseURI"]/*' />
+ public override String BaseURI { get { return _xn.BaseURI; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.XmlLang"]/*' />
+ public override String XmlLang { get { return _xn.XmlLang; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.IsEmptyElement"]/*' />
+ public override bool IsEmptyElement { get { return _xn.IsEmptyElement; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.NameTable"]/*' />
+ public override XmlNameTable NameTable { get { return _xn.NameTable; } }
+
+ // Attributes
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.HasAttributes"]/*' />
+ public override bool HasAttributes { get { return _xn.HasAttributes; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.GetAttribute"]/*' />
+ public override string GetAttribute(string localName, string namespaceURI)
+ {
+ return _xn.GetAttribute(localName, namespaceURI);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToAttribute"]/*' />
+ public override bool MoveToAttribute(string localName, string namespaceURI)
+ {
+ return _xn.MoveToAttribute(localName, namespaceURI);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToFirstAttribute"]/*' />
+ public override bool MoveToFirstAttribute()
+ {
+ return _xn.MoveToFirstAttribute();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToNextAttribute"]/*' />
+ public override bool MoveToNextAttribute()
+ {
+ return _xn.MoveToNextAttribute();
+ }
+
+ // Namespaces
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.GetNamespace"]/*' />
+ public override string GetNamespace(string name)
+ {
+ return _xn.GetNamespace(name);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToNamespace"]/*' />
+ public override bool MoveToNamespace(string name)
+ {
+ return _xn.MoveToNamespace(name);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToFirstNamespace1"]/*' />
+ public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
+ {
+ return _xn.MoveToFirstNamespace(namespaceScope);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToNextNamespace1"]/*' />
+ public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope)
+ {
+ return _xn.MoveToNextNamespace(namespaceScope);
+ }
+
+ // Tree
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToNext"]/*' />
+ public override bool MoveToNext()
+ {
+ return _xn.MoveToNext();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToPrevious"]/*' />
+ public override bool MoveToPrevious()
+ {
+ return _xn.MoveToPrevious();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToFirst"]/*' />
+ public override bool MoveToFirst()
+ {
+ return _xn.MoveToFirst();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.HasChildren"]/*' />
+ public override bool HasChildren { get { return _xn.HasChildren; } }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToFirstChild"]/*' />
+ public override bool MoveToFirstChild()
+ {
+ return _xn.MoveToFirstChild();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToParent"]/*' />
+ public override bool MoveToParent()
+ {
+ return _xn.MoveToParent();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToRoot"]/*' />
+ public override void MoveToRoot()
+ {
+ _xn.MoveToRoot();
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveTo"]/*' />
+ public override bool MoveTo(XPathNavigator other)
+ {
+ return _xn.MoveTo(other);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.MoveToId"]/*' />
+ public override bool MoveToId(string id)
+ {
+ return _xn.MoveToId(id);
+ }
+
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.IsSamePosition"]/*' />
+ public override bool IsSamePosition(XPathNavigator other)
+ {
+ return _xn.IsSamePosition(other);
+ }
+
+ // Selection
+ /// <include file='doc\XPathNavigator.uex' path='docs/doc[@for="XPathNavigator.Compile"]/*' />
+ //[PermissionSetAttribute(SecurityAction.Deny, Name = "FullTrust")]
+ public override XPathExpression Compile(string xpath)
+ {
+ //XPathDocument xn = new XPathDocument(_strFileName);
+ if (xpath.IndexOf("custom", 0, xpath.Length) >= 0)
+ xpath = "custom:dangerous()";
+
+ return _xn.Compile(xpath);
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/Program.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/Program.cs
new file mode 100644
index 0000000000..8252e1c5a2
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/Program.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using ModuleCore;
+
+namespace XslCompiledTransformTests
+{
+ internal class Program
+ {
+ public static int Main()
+ {
+ var args = @"DocType:XmlDocument trace:false Host:None";
+ return 100 + TestRunner.Execute(args);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj b/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj
new file mode 100644
index 0000000000..24329a1f51
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/System.Xml.Xsl.XslTransformApi.Tests.csproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{ACF79A18-2655-452C-B4AC-10125F0AD7A8}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AssemblyName>System.Xml.Xsl.XslTransformApi.Tests</AssemblyName>
+ <RootNamespace>System.Xml.Tests</RootNamespace>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="cthread.cs" />
+ <Compile Include="CThreads.cs" />
+ <Compile Include="CXmlCache.cs" />
+ <Compile Include="CXslTArgumentList.cs" />
+ <Compile Include="CXsltArgumentListMultith.cs" />
+ <Compile Include="CXsltChecksum.cs" />
+ <Compile Include="CXslTransform.cs" />
+ <Compile Include="CXslTransformMultith.cs" />
+ <Compile Include="DataHelper.cs" />
+ <Compile Include="ExceptionVerifier.cs" />
+ <Compile Include="MyNavigator.cs" />
+ <Compile Include="ThreadFunc.cs" />
+ <Compile Include="XSLTransform.cs" />
+ <Compile Include="XunitAssemblyAttributes.cs" />
+ <Content Include="..\TestFiles\**\*.*">
+ <Link>TestFiles\%(RecursiveDir)%(Filename)%(Extension)</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(CommonTestPath)\System\Xml\ModuleCore\ModuleCore.csproj" />
+ <ProjectReference Include="$(CommonTestPath)\System\Xml\XmlCoreTest\XmlCoreTest.csproj" />
+ <ProjectReference Include="$(CommonTestPath)\System\Xml\xmlDiff\XmlDiff.csproj" />
+ <ProjectReference Include="..\..\..\src\System.Xml.csproj" />
+ <ProjectReference Include="..\..\..\..\System.Xml.ReaderWriter\src\System.Xml.ReaderWriter.csproj" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="project.json" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project> \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/ThreadFunc.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/ThreadFunc.cs
new file mode 100644
index 0000000000..1a58cb7ca1
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/ThreadFunc.cs
@@ -0,0 +1,8 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Xml.Tests
+{
+ public delegate int ThreadFunc(object obj);
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs
new file mode 100644
index 0000000000..6c677f36d4
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/XSLTransform.cs
@@ -0,0 +1,1026 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+using Xunit.Abstractions;
+using System;
+using System.IO;
+using System.Net;
+using System.Security.Policy;
+using System.Text;
+using System.Xml;
+using System.Xml.XmlDiff;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+using XmlCoreTest.Common;
+
+namespace System.Xml.Tests
+{
+ public enum TransformType
+ {
+ Reader, Stream, Writer, TextWriter
+ }
+
+ public enum InputType
+ {
+ Reader, URI, Navigator
+ }
+
+ public enum DocType
+ {
+ XmlDocument, XPathDocument, Unknown
+ }
+
+ public enum ReaderType
+ {
+ XmlTextReader, XmlNodeReader, XmlValidatingReader, XsltReader, Unknown
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Module declaration for LTM usage
+ //
+ ////////////////////////////////////////////////////////////////
+ //[TestModule(Name = "XSLTransform API Tests", Desc = "XSLTransform API Tests", Pri = 1)]
+ public class XSLTransformModule
+ {
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Base class for test cases
+ //
+ ////////////////////////////////////////////////////////////////
+ public class XsltApiTestCaseBase
+ {
+ // Generic data for all derived test cases
+ public String szXslNS = "http://www.w3.org/1999/XSL/Transform";
+
+ public String szDefaultNS = "urn:my-object";
+ public String szEmpty = "";
+ public String szInvalid = "*?%(){}[]&!@#$";
+ public String szLongString = "ThisIsAVeryLongStringToBeStoredAsAVariableToDetermineHowLargeThisBufferForAVariableNameCanBeAndStillFunctionAsExpected";
+ public String szLongNS = "http://www.miocrosoft.com/this/is/a/very/long/namespace/uri/to/do/the/api/testing/for/xslt/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/0123456789/";
+ public String[] szWhiteSpace = { " ", "\n", "\t", "\r", "\t\n \r\t" };
+ public String szSimple = "myArg";
+
+ // Variables from init string
+ private string _strPath; // Path of the data files
+
+ private string _httpPath; // HTTP Path of the data files
+ private InputType _nInput; // reader, url, or navigator
+ private bool _fTrace; // Should we write out the results of the transform?
+ private TransformType _nTransform; // Type of XSL Transform to do
+ private DocType _docType; // Data document type
+ private ReaderType _readerType; // Reader type
+
+ // Other global variables
+ protected string _strOutFile = "out.xml"; // File to create when using write transforms
+
+#pragma warning disable 0618
+ protected XslTransform xslt; // Main XslTransform instance
+#pragma warning restore 0618
+ protected XmlReader xrXSLT; // for READER transforms
+ protected XsltArgumentList m_xsltArg; // For XsltArgumentList tests
+ public object retObj;
+
+ protected bool _isInProc; // Is the current test run in proc or /Host None?
+
+ private ITestOutputHelper _output;
+ public XsltApiTestCaseBase(ITestOutputHelper output)
+ {
+ _output = output;
+ this.Init(null);
+ }
+
+ public InputType MyInputType()
+ {
+ return _nInput;
+ }
+
+ public TransformType MyTransformType()
+ {
+ return _nTransform;
+ }
+
+ public DocType MyDocType()
+ {
+ return _docType;
+ }
+
+ public ReaderType MyReaderType()
+ {
+ return _readerType;
+ }
+
+ public TransformType GetTransformType(String s)
+ {
+ if (s.EndsWith(",READER"))
+ return TransformType.Reader;
+
+ if (s.EndsWith(",STREAM"))
+ return TransformType.Stream;
+
+ if (s.EndsWith(",WRITER"))
+ return TransformType.Writer;
+
+ if (s.EndsWith(",TEXTWRITER"))
+ return TransformType.TextWriter;
+
+ // TransformType not necessary, using default
+ return TransformType.Stream;
+ }
+
+ public XmlUrlResolver GetDefaultCredResolver()
+ {
+ XmlUrlResolver myDefaultCredResolver = new XmlUrlResolver();
+ //myDefaultCredResolver.Credentials = CredentialCache.DefaultCredentials;
+
+ return myDefaultCredResolver;
+ }
+
+ public InputType GetInputType(String s)
+ {
+ if (s.StartsWith("READER,"))
+ return InputType.Reader;
+ if (s.StartsWith("URI,"))
+ return InputType.URI;
+ if (s.StartsWith("NAVIGATOR,"))
+ return InputType.Navigator;
+
+ // Input Type not necessary, using default
+ return InputType.URI;
+ }
+
+ public DocType GetDocType(String s)
+ {
+ switch (s.ToUpper())
+ {
+ case "XPATHDOCUMENT":
+ return DocType.XPathDocument;
+
+ case "XMLDOCUMENT":
+ return DocType.XmlDocument;
+
+ default: // DocType Type not important, using default
+ return DocType.XPathDocument;
+ }
+ }
+
+ public ReaderType GetReaderType(String s)
+ {
+ //XmlTextReader, XmlNodeReader, XmlValidatingReader, XsltReader
+
+ switch (s.ToUpper())
+ {
+ case "XMLTEXTREADER":
+ return ReaderType.XmlTextReader;
+
+ case "XMLNODEREADER":
+ return ReaderType.XmlNodeReader;
+
+ case "XMLVALIDATINGREADER":
+ return ReaderType.XmlValidatingReader;
+
+ case "XSLTREADER":
+ return ReaderType.XsltReader;
+
+ default: // ReaderType Type not important, using default
+ return ReaderType.XmlValidatingReader;
+ }
+ }
+
+ public String InitStringValue(String str)
+ {
+ return String.Empty;
+ }
+
+ public void Init(object objParam)
+ {
+ // Get input and transform type from attribute
+ _nInput = GetInputType(String.Empty);
+ _nTransform = GetTransformType(String.Empty);
+
+ // Get parameter info from runtime variables passed to LTM
+ _fTrace = (InitStringValue("trace").ToUpper() == "TRUE");
+ _docType = GetDocType(InitStringValue("doctype"));
+ _readerType = GetReaderType(InitStringValue("readertype"));
+
+ // FullFilePath and FullHttpPath attempt to normalize file paths, however
+ // as an extra step we can normalize them here, when they are first read
+ // from the LTM file.
+ _strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");
+ _httpPath = FilePathUtil.GetHttpTestDataPath() + @"/XsltApi/";
+
+ return;
+ }
+
+ // Returns the full path of a file, based on LTM parameters
+ public String FullFilePath(String szFile)
+ {
+ return FullFilePath(szFile, true);
+ }
+
+ // Returns the full, lower-cased path of a file, based on LTM parameters
+ public String FullFilePath(String szFile, bool normalizeToLower)
+ {
+ if (szFile == null || szFile == String.Empty)
+ return szFile;
+ // why is this check here?
+ if (szFile.Length > 5)
+ {
+ if (szFile.Substring(0, 5) != "http:")
+ szFile = _strPath + szFile;
+ }
+ if (normalizeToLower)
+ return szFile.ToLower();
+ else
+ return szFile;
+ }
+
+ // Returns the full, lower-cased http path of a file, based on LTM parameters
+ public String FullHttpPath(String szFile)
+ {
+ if (szFile == null || szFile == String.Empty)
+ return szFile;
+
+ szFile = _httpPath + szFile;
+
+ return szFile.ToLower();
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // CheckExpectedError
+ // -------------------------------------------------------------------------------------------------------------
+ public void CheckExpectedError(Exception ex, string assembly, string res, string[] strParams)
+ {
+ CExceptionHandler handler = new CExceptionHandler(Path.Combine(_strPath, "exceptions.xml"), assembly, _output);
+ if (!handler.VerifyException(ex, res, strParams))
+ {
+ Assert.True(false);
+ }
+ return;
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // CheckExpectedError
+ // -------------------------------------------------------------------------------------------------------------
+ public void CheckExpectedError(Exception ex, string assembly, string res, string[] strParams, LineInfo lInfo)
+ {
+ CExceptionHandler handler = new CExceptionHandler(Path.Combine(_strPath, "exceptions.xml"), assembly, _output);
+ if (!handler.VerifyException(ex, res, strParams, lInfo))
+ {
+ Assert.True(false);
+ }
+ return;
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // LoadXML
+ // -------------------------------------------------------------------------------------------------------------
+ public IXPathNavigable LoadXML(String strFileLocation, DocType _docType)
+ {
+ switch (_docType)
+ {
+ case DocType.XmlDocument:
+ XmlDocument xmlDocument = new XmlDocument();
+ xmlDocument.Load(strFileLocation);
+ return (IXPathNavigable)xmlDocument;
+
+ case DocType.XPathDocument:
+ XPathDocument xPathDocument = new XPathDocument(strFileLocation);
+ return (IXPathNavigable)xPathDocument;
+
+ default:
+ return null;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // LoadXSL
+ // -------------------------------------------------------------------------------------------------------------
+ public int LoadXSL(String _strXslFile)
+ {
+ return LoadXSL(_strXslFile, _nInput);
+ }
+
+ public int LoadXSL(String _strXslFile, InputType inputType)
+ {
+ _strXslFile = FullFilePath(_strXslFile);
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+
+ switch (inputType)
+ {
+ case InputType.URI:
+ _output.WriteLine("Loading style sheet as URI {0}", _strXslFile);
+ xslt.Load(_strXslFile);
+ break;
+
+ case InputType.Reader:
+ switch (_readerType)
+ {
+ case ReaderType.XmlTextReader:
+ XmlTextReader trTemp = new XmlTextReader(_strXslFile);
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
+ xslt.Load(trTemp);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (trTemp != null)
+ trTemp.Dispose();
+ }
+ break;
+
+ case ReaderType.XmlNodeReader:
+ XmlDocument docTemp = new XmlDocument();
+ docTemp.Load(_strXslFile);
+ XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
+ xslt.Load(nrTemp);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (nrTemp != null)
+ nrTemp.Dispose();
+ }
+ break;
+
+ case ReaderType.XmlValidatingReader:
+ default:
+#pragma warning disable 0618
+ XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ vrTemp.ValidationType = ValidationType.None;
+ vrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
+ xslt.Load(vrTemp);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (vrTemp != null)
+ vrTemp.Dispose();
+ }
+ break;
+ }
+ break;
+
+ case InputType.Navigator:
+#pragma warning disable 0618
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ xrLoad.ValidationType = ValidationType.None;
+ XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
+ xrLoad.Dispose();
+ _output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
+ xslt.Load(xdTemp);
+ break;
+ }
+ return 1;
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // LoadXSL_Resolver
+ // -------------------------------------------------------------------------------------------------------------
+ public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
+ {
+ _strXslFile = FullFilePath(_strXslFile);
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+
+ switch (_nInput)
+ {
+ case InputType.URI:
+ _output.WriteLine("Loading style sheet as URI {0}", _strXslFile);
+ xslt.Load(_strXslFile, xr);
+ break;
+
+ case InputType.Reader:
+ switch (_readerType)
+ {
+ case ReaderType.XmlTextReader:
+ XmlTextReader trTemp = new XmlTextReader(_strXslFile);
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
+ xslt.Load(trTemp, xr);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (trTemp != null)
+ trTemp.Dispose();
+ }
+ break;
+
+ case ReaderType.XmlNodeReader:
+ XmlDocument docTemp = new XmlDocument();
+ docTemp.Load(_strXslFile);
+ XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
+ xslt.Load(nrTemp, xr);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (nrTemp != null)
+ nrTemp.Dispose();
+ }
+ break;
+
+ case ReaderType.XmlValidatingReader:
+ default:
+#pragma warning disable 0618
+ XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ vrTemp.ValidationType = ValidationType.None;
+ vrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
+ xslt.Load(vrTemp, xr);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (vrTemp != null)
+ vrTemp.Dispose();
+ }
+ break;
+ }
+ break;
+
+ case InputType.Navigator:
+#pragma warning disable 0618
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
+ xrLoad.Dispose();
+ _output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
+ xslt.Load(xdTemp, xr);
+ break;
+ }
+ return 1;
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // LoadXSL_Resolver_Evidence
+ // -------------------------------------------------------------------------------------------------------------
+ /*public int LoadXSL_Resolver_Evidence(String _strXslFile, XmlResolver xr, Evidence e)
+ {
+ _strXslFile = FullFilePath(_strXslFile);
+#pragma warning disable 0618
+ xslt = new XslTransform();
+#pragma warning restore 0618
+
+ switch (_nInput)
+ {
+ case InputType.Reader:
+ switch (_readerType)
+ {
+ case ReaderType.XmlTextReader:
+ XmlTextReader trTemp = new XmlTextReader(_strXslFile);
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
+ xslt.Load(trTemp, xr, e);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (trTemp != null)
+ trTemp.Dispose();
+ }
+ break;
+
+ case ReaderType.XmlNodeReader:
+ XmlDocument docTemp = new XmlDocument();
+ docTemp.Load(_strXslFile);
+ XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
+ xslt.Load(nrTemp, xr, e);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (nrTemp != null)
+ nrTemp.Dispose();
+ }
+ break;
+
+ case ReaderType.XmlValidatingReader:
+ default:
+#pragma warning disable 0618
+ XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ vrTemp.ValidationType = ValidationType.None;
+ vrTemp.EntityHandling = EntityHandling.ExpandEntities;
+ try
+ {
+ _output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
+ xslt.Load(vrTemp, xr, e);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (vrTemp != null)
+ vrTemp.Dispose();
+ }
+ break;
+ }
+ break;
+
+ case InputType.Navigator:
+#pragma warning disable 0618
+ XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
+#pragma warning restore 0618
+ XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
+ xrLoad.Dispose();
+ _output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
+ xslt.Load(xdTemp.CreateNavigator(), xr, e);
+ break;
+ }
+ return 1;
+ }*/
+
+ //VerifyResult
+ public void VerifyResult(string expectedValue)
+ {
+ XmlDiff.XmlDiff xmldiff = new XmlDiff.XmlDiff();
+ xmldiff.Option = XmlDiffOption.InfosetComparison | XmlDiffOption.IgnoreEmptyElement;
+
+ StreamReader sr = new StreamReader(new FileStream("out.xml", FileMode.Open, FileAccess.Read));
+ string actualValue = sr.ReadToEnd();
+ sr.Dispose();
+
+ //Output the expected and actual values
+ _output.WriteLine("Expected : " + expectedValue);
+ _output.WriteLine("Actual : " + actualValue);
+
+ //Load into XmlTextReaders
+ XmlTextReader tr1 = new XmlTextReader("out.xml");
+ XmlTextReader tr2 = new XmlTextReader(new StringReader(expectedValue));
+
+ bool bResult = xmldiff.Compare(tr1, tr2);
+
+ //Close the readers
+ tr1.Dispose();
+ tr2.Dispose();
+
+ if (bResult)
+ return;
+ else
+ Assert.True(false);
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // Transform
+ // -------------------------------------------------------------------------------------------------------------
+
+ private static readonly object s_outFileMemoryLock = new object();
+
+#pragma warning disable 0618
+ public void CallTransform(XslTransform xslt, String szFullFilename, String _strOutFile)
+ {
+ lock (s_outFileMemoryLock)
+ {
+ xslt.Transform(szFullFilename, _strOutFile);
+ }
+ }
+
+ public void CallTransform(XslTransform xslt, String szFullFilename, String _strOutFile, XmlResolver resolver)
+ {
+ lock (s_outFileMemoryLock)
+ {
+ xslt.Transform(szFullFilename, _strOutFile, resolver);
+ }
+ }
+#pragma warning restore 0618
+
+ public int Transform(String szXmlFile)
+ {
+ // Default value of errorCase is false
+ return Transform(szXmlFile, false);
+ }
+
+ public int Transform(String szXmlFile, bool errorCase)
+ {
+ lock (s_outFileMemoryLock)
+ {
+ szXmlFile = FullFilePath(szXmlFile);
+
+ _output.WriteLine("Loading XML {0}", szXmlFile);
+ IXPathNavigable xd = LoadXML(szXmlFile, _docType);
+
+ _output.WriteLine("Executing transform");
+ xrXSLT = null;
+ Stream strmTemp = null;
+ switch (_nTransform)
+ {
+ case TransformType.Reader:
+ xrXSLT = xslt.Transform(xd, null);
+ if (errorCase)
+ {
+ try
+ {
+ while (xrXSLT.Read()) { }
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (xrXSLT != null)
+ xrXSLT.Dispose();
+ }
+ }
+ break;
+
+ case TransformType.Stream:
+ try
+ {
+ strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
+ xslt.Transform(xd, null, strmTemp);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (strmTemp != null)
+ strmTemp.Dispose();
+ }
+ break;
+
+ case TransformType.Writer:
+ XmlWriter xw = null;
+ try
+ {
+ xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
+ xw.WriteStartDocument();
+ xslt.Transform(xd, null, xw);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (xw != null)
+ xw.Dispose();
+ }
+ break;
+
+ case TransformType.TextWriter:
+ TextWriter tw = null;
+ try
+ {
+ tw = new StreamWriter(new FileStream(_strOutFile, FileMode.Create, FileAccess.Write), Encoding.UTF8);
+ xslt.Transform(xd, null, tw);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (tw != null)
+ tw.Dispose();
+ }
+ break;
+ }
+ return 1;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // Transform_ArgList
+ // -------------------------------------------------------------------------------------------------------------
+
+ public int Transform_ArgList(String szXmlFile)
+ {
+ // Default value of errorCase is false
+ return Transform_ArgList(szXmlFile, false);
+ }
+
+ public int Transform_ArgList(String szXmlFile, bool errorCase)
+ {
+ lock (s_outFileMemoryLock)
+ {
+ szXmlFile = FullFilePath(szXmlFile);
+
+ _output.WriteLine("Loading XML {0}", szXmlFile);
+ IXPathNavigable xd = LoadXML(szXmlFile, _docType);
+
+ _output.WriteLine("Executing transform");
+ xrXSLT = null;
+ Stream strmTemp = null;
+ switch (_nTransform)
+ {
+ case TransformType.Reader:
+ xrXSLT = xslt.Transform(xd, m_xsltArg);
+ if (errorCase)
+ {
+ try
+ {
+ while (xrXSLT.Read()) { }
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (xrXSLT != null)
+ xrXSLT.Dispose();
+ }
+ }
+ break;
+
+ case TransformType.Stream:
+ try
+ {
+ strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
+ xslt.Transform(xd, m_xsltArg, strmTemp);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (strmTemp != null)
+ strmTemp.Dispose();
+ }
+ break;
+
+ case TransformType.Writer:
+ XmlWriter xw = null;
+ try
+ {
+ xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
+ xw.WriteStartDocument();
+ xslt.Transform(xd, m_xsltArg, xw);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (xw != null)
+ xw.Dispose();
+ }
+ break;
+
+ case TransformType.TextWriter:
+ TextWriter tw = null;
+ try
+ {
+ tw = new StreamWriter(new FileStream(_strOutFile, FileMode.Create, FileAccess.Write), Encoding.UTF8);
+ xslt.Transform(xd, m_xsltArg, tw);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (tw != null)
+ {
+ tw.Dispose();
+ }
+ }
+ break;
+ }
+ return 1;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // TransformResolver
+ // -------------------------------------------------------------------------------------------------------------
+
+ public int TransformResolver(String szXmlFile, XmlResolver xr)
+ {
+ // Default value of errorCase is false
+ return TransformResolver(szXmlFile, xr, false);
+ }
+
+ public int TransformResolver(String szXmlFile, XmlResolver xr, bool errorCase)
+ {
+ lock (s_outFileMemoryLock)
+ {
+ szXmlFile = FullFilePath(szXmlFile);
+
+ _output.WriteLine("Loading XML {0}", szXmlFile);
+ IXPathNavigable xd = LoadXML(szXmlFile, _docType);
+
+ _output.WriteLine("Executing transform");
+ xrXSLT = null;
+ Stream strmTemp = null;
+
+ switch (_nTransform)
+ {
+ case TransformType.Reader:
+ xrXSLT = xslt.Transform(xd, null, xr);
+ if (errorCase)
+ {
+ try
+ {
+ while (xrXSLT.Read()) { }
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (xrXSLT != null)
+ xrXSLT.Dispose();
+ }
+ }
+ break;
+
+ case TransformType.Stream:
+ try
+ {
+ strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
+ xslt.Transform(xd, null, strmTemp, xr);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (strmTemp != null)
+ strmTemp.Dispose();
+ }
+ break;
+
+ case TransformType.Writer:
+ XmlWriter xw = null;
+ try
+ {
+ xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
+ xw.WriteStartDocument();
+ xslt.Transform(xd, null, xw, xr);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (xw != null)
+ xw.Dispose();
+ }
+ break;
+
+ case TransformType.TextWriter:
+ TextWriter tw = null;
+ try
+ {
+ tw = new StreamWriter(new FileStream(_strOutFile, FileMode.Create, FileAccess.Write), Encoding.UTF8);
+ xslt.Transform(xd, null, tw, xr);
+ }
+ catch (Exception ex)
+ {
+ throw (ex);
+ }
+ finally
+ {
+ if (tw != null)
+ tw.Dispose();
+ }
+ break;
+ }
+ return 1;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // CheckResult
+ // -------------------------------------------------------------------------------------------------------------
+ public int CheckResult(double szExpResult)
+ {
+ lock (s_outFileMemoryLock)
+ {
+ double checksumActual;
+ CXsltChecksum check = new CXsltChecksum(_fTrace, _output);
+
+ if (_nTransform == TransformType.Reader)
+ checksumActual = check.Calc(xrXSLT);
+ else
+ checksumActual = check.Calc(_strOutFile);
+
+ if (szExpResult != checksumActual || _fTrace)
+ {
+ _output.WriteLine("XML: {0}", check.Xml);
+ _output.WriteLine("Actual checksum: {0}, Expected: {1}", checksumActual, szExpResult);
+ }
+ if (szExpResult != checksumActual)
+ return 0;
+
+ return 1;
+ }
+ }
+ }
+
+ internal class CExceptionHandler
+ {
+ private XPathDocument _doc;
+ private XPathNavigator _nav;
+ private ExceptionVerifier _exVer;
+
+ private ITestOutputHelper _output;
+
+ public CExceptionHandler(string strXmlFile, string ns, ITestOutputHelper output)
+ {
+ _output = output;
+
+ _exVer = new ExceptionVerifier(ns, ExceptionVerificationFlags.IgnoreMultipleDots, _output);
+
+ _doc = new XPathDocument(strXmlFile);
+ _nav = ((IXPathNavigable)_doc).CreateNavigator();
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // VerifyException
+ // -------------------------------------------------------------------------------------------------------------
+ public bool VerifyException(Exception ex, string res, string[] strParams)
+ {
+ try
+ {
+ _exVer.IsExceptionOk(ex, res, strParams);
+ return true;
+ }
+ catch (Exception exp)
+ {
+ _output.WriteLine(exp.Message);
+ return false;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------------------------
+ // VerifyException
+ // -------------------------------------------------------------------------------------------------------------
+ public bool VerifyException(Exception ex, string res, string[] strParams, LineInfo lInfo)
+ {
+ try
+ {
+ _exVer.IsExceptionOk(ex, res, strParams, lInfo);
+ return true;
+ }
+ catch (Exception exp)
+ {
+ _output.WriteLine(exp.Message);
+ return false;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/XunitAssemblyAttributes.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/XunitAssemblyAttributes.cs
new file mode 100644
index 0000000000..3662eacea4
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/XunitAssemblyAttributes.cs
@@ -0,0 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Xunit;
+
+// For testing purposes, we keep the output of the Transform in a file.
+// Since the content of the file ends up affecting the result of each test,
+// we want to avoid parallelism so that one test doesn't affect another.
+[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true, MaxParallelThreads = 1)]
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/cthread.cs b/src/System.Private.Xml/tests/Xslt/XslTransformApi/cthread.cs
new file mode 100644
index 0000000000..bf7008e279
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/cthread.cs
@@ -0,0 +1,190 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//ArrayList
+
+using System;
+using System.Reflection;
+using System.Threading;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace System.Xml.Tests
+{
+ ////////////////////////////////////////////////////////////////
+ // Delegate
+ //
+ ////////////////////////////////////////////////////////////////
+
+ ////////////////////////////////////////////////////////////////
+ // CThreads
+ //
+ ////////////////////////////////////////////////////////////////
+
+ ////////////////////////////////////////////////////////////////
+ // CThread
+ //
+ ////////////////////////////////////////////////////////////////
+ public class CThread
+ {
+ //Data
+ private ThreadFunc _threadfunc;
+
+ private int _nIterations;
+ private object _oParam;
+ private int _iReturn;
+ private Exception _eReturn;
+ private Thread _rThread;
+
+ private ITestOutputHelper _output;
+
+ //Constructor
+ public CThread(ThreadFunc func, object oParam, ITestOutputHelper output)
+ : this(1, func, oParam, output)
+ {
+ //Default to 1 iteration
+ }
+
+ public CThread(int iterations, ThreadFunc func, object oParam, ITestOutputHelper output)
+ {
+ //Note: notice there are no "setters" on this class, so you can't reuse this class
+ //for other thread functions, you need one class per thread function. This is exaclty
+ //how the System.Thread class works, you can't reuse it, once the thread is complete, its done
+ //so all the state set is for that thread...
+
+ _rThread = new Thread(new ThreadStart(InternalThreadStart));
+ _threadfunc = func;
+ _nIterations = iterations;
+ _oParam = oParam;
+ _output = output;
+ }
+
+ //Static
+ public static int MaxIterations = 30;
+
+ //Accessors
+ public virtual Thread Internal
+ {
+ get { return _rThread; }
+ }
+
+ public virtual int Iterations
+ {
+ get { return _nIterations; }
+ }
+
+ public virtual ThreadFunc Func
+ {
+ get { return _threadfunc; }
+ }
+
+ public virtual int ReturnCode
+ {
+ get { return _iReturn; }
+ }
+
+ public virtual object Param
+ {
+ get { return _oParam; }
+ }
+
+ private void InternalThreadStart()
+ {
+ //Note: We have a "wrapper" thread function thats always called.
+ //This allows us much greater control than the normal System.Thread class.
+ // 1. It allows us to call the function repeatedly (iterations)
+ // 2. It allows parameters to be passed into the thread function
+ // 3. It allows a return code from the thread function
+ // 4. etc...
+
+ //Iterate the specified number of times
+ for (int i = 0; i < Iterations; i++)
+ {
+ //call the user thread function
+ try
+ {
+ _iReturn = Func(Param);
+ }
+ catch (Exception e)
+ {
+ //Note: If we don't handle this exception it doesn't get handled by the
+ //main thread try-catch since its on a sperate thread. Instead of crashing the
+ //URT - or requiring every thread function to catch any exception (there not expecting)
+ //we will catch it and store the exception for later throw from the calling function
+ _iReturn = HandleException(e);
+ _eReturn = e;
+
+ //We should break out of this iteration
+ break;
+ }
+ }
+ }
+
+ public virtual void Start()
+ {
+ Internal.Start();
+ }
+
+ public virtual void Abort()
+ {
+ //Internal.Abort();
+ throw new NotImplementedException();
+ }
+
+ public virtual void Wait()
+ {
+ //Wait for this thread to complete...
+ Internal.Join();
+
+ //Now throw any exceptions that occured from within the thread to the caller
+ if (_eReturn != null)
+ throw _eReturn;
+ }
+
+ public virtual void Verify(int iReturnCode)
+ {
+ //Make sure the number of threads expected had the correct return code...
+ Assert.Equal(ReturnCode, iReturnCode);
+ }
+
+ public int HandleException(Exception e)
+ {
+ //TargetInvocationException is almost always the outer
+ //since we call the variation through late binding
+ if (e is TargetInvocationException && e.InnerException != null)
+ e = e.InnerException;
+
+ int eResult = 0; //TEST_FAIL
+ object actual = e.GetType();
+ object expected = null;
+ string message = e.Message;
+
+ //Log the exception back to LTM (or whatever has the console)
+ var eTest = e as OLEDB.Test.ModuleCore.CTestException;
+ if (eTest != null)
+ {
+ //Setup more meaningful info
+ actual = eTest.Actual;
+ expected = eTest.Expected;
+ eResult = eTest.Result;
+ switch (eResult)
+ {
+ case 1: //TEST_PASS
+ //case TEST_SKIPPED:
+ _output.WriteLine(eTest.Message);
+ return eResult; //were done
+
+ //case TEST_WARNING:
+ // break;
+ };
+ }
+
+ _output.WriteLine("Actual : {0}", actual);
+ _output.WriteLine("Expected: {0}", expected);
+ _output.WriteLine(e.Message);
+
+ return eResult;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml/tests/Xslt/XslTransformApi/project.json b/src/System.Private.Xml/tests/Xslt/XslTransformApi/project.json
new file mode 100644
index 0000000000..0efbdf9703
--- /dev/null
+++ b/src/System.Private.Xml/tests/Xslt/XslTransformApi/project.json
@@ -0,0 +1,37 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.2-beta-24322-03",
+ "System.Collections.NonGeneric": "4.0.2-beta-24322-03",
+ "System.Collections.Specialized": "4.0.2-beta-24322-03",
+ "System.IO": "4.1.1-beta-24322-03",
+ "System.IO.FileSystem": "4.0.2-beta-24322-03",
+ "System.IO.FileSystem.Primitives": "4.0.2-beta-24322-03",
+ "System.Linq.Expressions": "4.1.1-beta-24322-03",
+ "System.ObjectModel": "4.0.13-beta-24322-03",
+ "System.Resources.Reader": "4.0.1-beta-24322-03",
+ "System.Reflection": "4.1.1-beta-24322-03",
+ "System.Reflection.Extensions": "4.0.2-beta-24322-03",
+ "System.Reflection.TypeExtensions": "4.1.1-beta-24322-03",
+ "System.Runtime": "4.1.1-beta-24322-03",
+ "System.Runtime.Extensions": "4.1.1-beta-24322-03",
+ "System.Threading": "4.0.12-beta-24322-03",
+ "System.Threading.Thread": "4.0.1-beta-24322-03",
+ "System.Threading.Tasks": "4.0.12-beta-24322-03",
+ "test-runtime": {
+ "target": "project",
+ "exclude": "compile"
+ },
+ "Microsoft.xunit.netcore.extensions": "1.0.0-prerelease-00508-01",
+ "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00520-02"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ },
+ "supports": {
+ "coreFx.Test.netcoreapp1.0": {},
+ "coreFx.Test.net46": {},
+ "coreFx.Test.net461": {},
+ "coreFx.Test.net462": {},
+ "coreFx.Test.net463": {}
+ }
+}