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:
authorJose Perez Rodriguez <joperezr@microsoft.com>2017-01-06 01:03:56 +0300
committerJose Perez Rodriguez <joperezr@microsoft.com>2017-01-06 01:03:56 +0300
commit44b68e694948065c1b61457cec125d3d64c1fa22 (patch)
treefc7093fb753c57f29ce42de9dd64ecc435d2e95c /src/System.Private.Xml.Linq/tests
parentd4d3bbdf7b8b35b5a330c94427051582470531d0 (diff)
parent05ae65fd6b51f865750e8d400c60511fcdbbbfb5 (diff)
Merge branch master into dev/eng
Diffstat (limited to 'src/System.Private.Xml.Linq/tests')
-rw-r--r--src/System.Private.Xml.Linq/tests/System.Private.Xml.Linq.Tests.builds52
-rw-r--r--src/System.Private.Xml.Linq/tests/TreeManipulation/LoadFromStream.cs2
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Common/BridgeHelpers.cs2
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Common/CXmlCache.cs2
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Common/DNException.cs4
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Common/HelperExtensionMethods.cs2
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Common/XDocument.Common.csproj3
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/XDocument.Test.ModuleCore.csproj3
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testlog.cs76
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testparser.cs4
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testproperties.cs12
-rw-r--r--src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/util.cs6
-rw-r--r--src/System.Private.Xml.Linq/tests/XPath/XDocument/XDocumentXPathTest.cs4
-rw-r--r--src/System.Private.Xml.Linq/tests/misc/LoadSaveAsyncTests.cs206
-rw-r--r--src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj2
15 files changed, 302 insertions, 78 deletions
diff --git a/src/System.Private.Xml.Linq/tests/System.Private.Xml.Linq.Tests.builds b/src/System.Private.Xml.Linq/tests/System.Private.Xml.Linq.Tests.builds
index 1f3a1a8981..562f456691 100644
--- a/src/System.Private.Xml.Linq/tests/System.Private.Xml.Linq.Tests.builds
+++ b/src/System.Private.Xml.Linq/tests/System.Private.Xml.Linq.Tests.builds
@@ -2,44 +2,70 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
+ <Project Include="axes\System.Xml.Linq.Axes.Tests.csproj" />
<Project Include="axes\System.Xml.Linq.Axes.Tests.csproj">
- <TestTFMs>netcoreapp1.1;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>net46</TestTFMs>
</Project>
+ <Project Include="events\System.Xml.Linq.Events.Tests.csproj" />
<Project Include="events\System.Xml.Linq.Events.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="misc\System.Xml.Linq.Misc.Tests.csproj" />
<Project Include="misc\System.Xml.Linq.Misc.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="Properties\System.Xml.Linq.Properties.Tests.csproj" />
<Project Include="Properties\System.Xml.Linq.Properties.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="SDMSample\System.Xml.Linq.SDMSample.Tests.csproj" />
<Project Include="SDMSample\System.Xml.Linq.SDMSample.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="Streaming\System.Xml.Linq.Streaming.Tests.csproj" />
<Project Include="Streaming\System.Xml.Linq.Streaming.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="TreeManipulation\System.Xml.Linq.TreeManipulation.Tests.csproj" />
<Project Include="TreeManipulation\System.Xml.Linq.TreeManipulation.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="XDocument.Common\XDocument.Common.csproj" />
<Project Include="XDocument.Common\XDocument.Common.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="XDocument.Test.ModuleCore\XDocument.Test.ModuleCore.csproj" />
<Project Include="XDocument.Test.ModuleCore\XDocument.Test.ModuleCore.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="xNodeBuilder\System.Xml.Linq.xNodeBuilder.Tests.csproj" />
<Project Include="xNodeBuilder\System.Xml.Linq.xNodeBuilder.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="xNodeReader\System.Xml.Linq.xNodeReader.Tests.csproj" />
<Project Include="xNodeReader\System.Xml.Linq.xNodeReader.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="XPath\XDocument\System.Xml.XPath.XDocument.Tests.csproj" />
<Project Include="XPath\XDocument\System.Xml.XPath.XDocument.Tests.csproj">
- <TestTFMs>netcoreapp1.1;netcore50;net46</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>netcore50;net46</TestTFMs>
</Project>
+ <Project Include="Schema\System.Xml.Schema.Extensions.Tests.csproj" />
<Project Include="Schema\System.Xml.Schema.Extensions.Tests.csproj">
- <TestTFMs>netcoreapp1.1;net463</TestTFMs>
+ <OSGroup>Windows_NT</OSGroup>
+ <TestTFMs>net463</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
diff --git a/src/System.Private.Xml.Linq/tests/TreeManipulation/LoadFromStream.cs b/src/System.Private.Xml.Linq/tests/TreeManipulation/LoadFromStream.cs
index 528e52864d..a8ea8c5b7c 100644
--- a/src/System.Private.Xml.Linq/tests/TreeManipulation/LoadFromStream.cs
+++ b/src/System.Private.Xml.Linq/tests/TreeManipulation/LoadFromStream.cs
@@ -435,7 +435,7 @@ namespace XLinqTests
return XElement.Load(s, lo);
}
default:
- throw new TestFailedException("TEST FAILED: don't know how to create XDocument");
+ throw new TestFailedException("TEST FAILED: don't know how to create XElement");
}
}
#endregion
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Common/BridgeHelpers.cs b/src/System.Private.Xml.Linq/tests/XDocument.Common/BridgeHelpers.cs
index f01688ee2d..5185156c8e 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Common/BridgeHelpers.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Common/BridgeHelpers.cs
@@ -163,7 +163,7 @@ namespace CoreXml.Test.XLinq
}
}
- public string GetTestFileName()
+ public static string GetTestFileName()
{
return Path.Combine("TestData", "XmlReader", "API", pGenericXml);
}
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Common/CXmlCache.cs b/src/System.Private.Xml.Linq/tests/XDocument.Common/CXmlCache.cs
index e3d75e0315..f7b98a10da 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Common/CXmlCache.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Common/CXmlCache.cs
@@ -688,7 +688,7 @@ public class CXmlCache
protected CXmlNode prDocumentRootNode;
protected CXmlNode prRootNode = null;
internal static NodeFlags _eDefaultFlags = NodeFlags.None;
- static internal BufferWriter _rBufferWriter = new BufferWriter();
+ internal static BufferWriter _rBufferWriter = new BufferWriter();
//
// Constructor
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Common/DNException.cs b/src/System.Private.Xml.Linq/tests/XDocument.Common/DNException.cs
index fa93186c16..5857fc2701 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Common/DNException.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Common/DNException.cs
@@ -12,12 +12,12 @@ namespace CoreXml.Test.XLinq
public DNException(string s) : base(s) { }
- static internal Exception DocumentNavigatorNotOnLastNode()
+ internal static Exception DocumentNavigatorNotOnLastNode()
{
return new DNException("DocumentNavigatorNotOnLastNode");
}
- static internal Exception DocumentNavigatorNotOnFirstNode()
+ internal static Exception DocumentNavigatorNotOnFirstNode()
{
return new DNException("DocumentNavigatorNotOnFirstNode");
}
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Common/HelperExtensionMethods.cs b/src/System.Private.Xml.Linq/tests/XDocument.Common/HelperExtensionMethods.cs
index c74b7eef66..f055d72ef9 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Common/HelperExtensionMethods.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Common/HelperExtensionMethods.cs
@@ -12,8 +12,6 @@ using System.Xml.Linq;
using Microsoft.Test.ModuleCore;
-[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
-
namespace CoreXml.Test.XLinq
{
public static class Helpers
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Common/XDocument.Common.csproj b/src/System.Private.Xml.Linq/tests/XDocument.Common/XDocument.Common.csproj
index d4c26835b7..639dcc8b18 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Common/XDocument.Common.csproj
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Common/XDocument.Common.csproj
@@ -20,9 +20,6 @@
<Compile Include="InputSpace.cs" />
<Compile Include="ManagedNodeWriter.cs" />
<Compile Include="XLinqTestCase.cs" />
- <Compile Include="$(CommonPath)\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs">
- <Link>Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs</Link>
- </Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(CommonTestPath)\System\Xml\XmlCoreTest\XmlCoreTest.csproj" />
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/XDocument.Test.ModuleCore.csproj b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/XDocument.Test.ModuleCore.csproj
index a25f718e61..9e64ec7517 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/XDocument.Test.ModuleCore.csproj
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/XDocument.Test.ModuleCore.csproj
@@ -22,9 +22,6 @@
<Compile Include="testspec.cs" />
<Compile Include="testvariation.cs" />
<Compile Include="util.cs" />
- <Compile Include="$(CommonPath)\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs">
- <Link>Common\System\Diagnostics\CodeAnalysis\ExcludeFromCodeCoverageAttribute.cs</Link>
- </Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project> \ No newline at end of file
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testlog.cs b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testlog.cs
index 1e9ce31a81..67cca17a29 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testlog.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testlog.cs
@@ -33,7 +33,7 @@ namespace Microsoft.Test.ModuleCore
private static TestLogAssertHandler s_passerthandler = null;
//Accessors
- static public ITestLog Internal
+ public static ITestLog Internal
{
set
{
@@ -45,18 +45,18 @@ namespace Microsoft.Test.ModuleCore
}
}
- static public TraceLevel Level
+ public static TraceLevel Level
{
get { return s_plevel; }
set { s_plevel = value; }
}
- static public TestLogAssertHandler AssertHandler
+ public static TestLogAssertHandler AssertHandler
{
get { return s_passerthandler; }
}
- static internal void Dispose()
+ internal static void Dispose()
{
//Reset the info.
s_pinternal = null;
@@ -64,84 +64,84 @@ namespace Microsoft.Test.ModuleCore
}
//Helpers
- static public string NewLine
+ public static string NewLine
{
get { return "\n"; }
}
- static public bool WillTrace(TraceLevel level)
+ public static bool WillTrace(TraceLevel level)
{
return (s_plevel >= level);
}
- static public void Write(object value)
+ public static void Write(object value)
{
Write(TestLogFlags.Text, StringEx.ToString(value));
}
- static public void WriteLine(object value)
+ public static void WriteLine(object value)
{
WriteLine(TestLogFlags.Text, StringEx.ToString(value));
}
- static public void WriteLine()
+ public static void WriteLine()
{
WriteLine(TestLogFlags.Text, null);
}
- static public void Write(string text)
+ public static void Write(string text)
{
Write(TestLogFlags.Text, text);
}
- static public void Write(string text, params object[] args)
+ public static void Write(string text, params object[] args)
{
//Delegate
Write(TestLogFlags.Text, String.Format(text, args));
}
- static public void WriteLine(string text)
+ public static void WriteLine(string text)
{
WriteLine(TestLogFlags.Text, text);
}
- static public void WriteLine(string text, params object[] args)
+ public static void WriteLine(string text, params object[] args)
{
//Delegate
WriteLine(String.Format(text, args));
}
- static public void Write(char[] value)
+ public static void Write(char[] value)
{
WriteLine(TestLogFlags.Text, new string(value));
}
- static public void WriteLine(char[] value)
+ public static void WriteLine(char[] value)
{
WriteLine(TestLogFlags.Text, new string(value));
}
- static public void WriteXml(string text)
+ public static void WriteXml(string text)
{
Write(TestLogFlags.Xml, text);
}
- static public void WriteRaw(string text)
+ public static void WriteRaw(string text)
{
Write(TestLogFlags.Raw, text);
}
- static public void WriteIgnore(string text)
+ public static void WriteIgnore(string text)
{
Write(TestLogFlags.Ignore, text);
}
- static public void WriteLineIgnore(string text)
+ public static void WriteLineIgnore(string text)
{
WriteLine(TestLogFlags.Ignore, text);
}
- static public void Write(TestLogFlags flags, string text)
+ public static void Write(TestLogFlags flags, string text)
{
if (Internal != null)
Internal.Write(flags, FixupXml(text));
@@ -149,7 +149,7 @@ namespace Microsoft.Test.ModuleCore
Console.Write(text);
}
- static public void WriteLine(TestLogFlags flags, string text)
+ public static void WriteLine(TestLogFlags flags, string text)
{
if (Internal != null)
Internal.WriteLine(flags, FixupXml(text));
@@ -157,46 +157,46 @@ namespace Microsoft.Test.ModuleCore
Console.WriteLine(text);
}
- static public void Trace(String value)
+ public static void Trace(String value)
{
Trace(TraceLevel.Default, value);
}
- static public void TraceLine(String value)
+ public static void TraceLine(String value)
{
TraceLine(TraceLevel.Default, value);
}
- static public void TraceLine()
+ public static void TraceLine()
{
TraceLine(TraceLevel.Default, null);
}
- static public void Trace(TraceLevel level, String value)
+ public static void Trace(TraceLevel level, String value)
{
if (WillTrace(level))
Write(TestLogFlags.Trace | TestLogFlags.Ignore, value);
}
- static public void TraceLine(TraceLevel level, String value)
+ public static void TraceLine(TraceLevel level, String value)
{
if (WillTrace(level))
Write(TestLogFlags.Trace | TestLogFlags.Ignore, value + TestLog.NewLine);
}
- static public void TraceLine(TraceLevel level)
+ public static void TraceLine(TraceLevel level)
{
TraceLine(level, null);
}
- static public bool Compare(bool equal, string message)
+ public static bool Compare(bool equal, string message)
{
if (equal)
return true;
return Compare(false, true, message);
}
- static public bool Compare(object actual, object expected, string message)
+ public static bool Compare(object actual, object expected, string message)
{
if (InternalEquals(actual, expected))
return true;
@@ -208,7 +208,7 @@ namespace Microsoft.Test.ModuleCore
throw new TestFailedException(message, actual, expected, null);
}
- static public bool Compare(object actual, object expected1, object expected2, string message)
+ public static bool Compare(object actual, object expected1, object expected2, string message)
{
if (InternalEquals(actual, expected1) || InternalEquals(actual, expected2))
return true;
@@ -220,7 +220,7 @@ namespace Microsoft.Test.ModuleCore
throw new TestFailedException(message, actual, expected2, null);
}
- static public bool Equals(object actual, object expected, string message)
+ public static bool Equals(object actual, object expected, string message)
{
//Equals is identical to Compare, except that Equals doesn't throw.
//i.e. the test wants to record the failure and continue to do other things
@@ -232,17 +232,17 @@ namespace Microsoft.Test.ModuleCore
return false;
}
- static public bool Warning(bool equal, string message)
+ public static bool Warning(bool equal, string message)
{
return Warning(equal, true, message, null);
}
- static public bool Warning(object actual, object expected, string message)
+ public static bool Warning(object actual, object expected, string message)
{
return Warning(actual, expected, message, null);
}
- static public bool Warning(object actual, object expected, string message, Exception inner)
+ public static bool Warning(object actual, object expected, string message, Exception inner)
{
//See if these are equal
bool equal = InternalEquals(actual, expected);
@@ -261,20 +261,20 @@ namespace Microsoft.Test.ModuleCore
}
}
- static public bool Skip(string message)
+ public static bool Skip(string message)
{
//Delegate
return Skip(true, message);
}
- static public bool Skip(bool skip, string message)
+ public static bool Skip(bool skip, string message)
{
if (skip)
throw new TestSkippedException(message);
return false;
}
- static internal bool InternalEquals(object actual, object expected)
+ internal static bool InternalEquals(object actual, object expected)
{
//Handle null comparison
if (actual == null && expected == null)
@@ -286,7 +286,7 @@ namespace Microsoft.Test.ModuleCore
return expected.Equals(actual);
}
- static public void Error(TestResult result, object actual, object expected, string source, string message, string stack, String filename, int lineno)
+ public static void Error(TestResult result, object actual, object expected, string source, string message, string stack, String filename, int lineno)
{
//Log the error
if (Internal != null)
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testparser.cs b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testparser.cs
index 8a08d1af05..b8b215c7b2 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testparser.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testparser.cs
@@ -42,12 +42,12 @@ namespace Microsoft.Test.ModuleCore
//Methods
- static public Dictionary<string, string> ParseKeywords(string str)
+ public static Dictionary<string, string> ParseKeywords(string str)
{
return ParseKeywords(str, s_DefaultTokens);
}
- static public Dictionary<string, string> ParseKeywords(string str, Tokens tokens)
+ public static Dictionary<string, string> ParseKeywords(string str, Tokens tokens)
{
PARSE state = PARSE.Initial;
int index = 0;
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testproperties.cs b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testproperties.cs
index dbef76f664..7f3c450be6 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testproperties.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/testproperties.cs
@@ -20,7 +20,7 @@ namespace Microsoft.Test.ModuleCore
private static String s_pcommandline;
//Constructor
- static public TestProps Properties
+ public static TestProps Properties
{
get
{
@@ -104,7 +104,7 @@ namespace Microsoft.Test.ModuleCore
return ret;
}
- static internal void Dispose()
+ internal static void Dispose()
{
//Reset the info.
//Since this is a static class, (to make it simplier to access from anywhere in your code)
@@ -116,7 +116,7 @@ namespace Microsoft.Test.ModuleCore
s_pcommandline = null;
}
- static public string InitString
+ public static string InitString
{
get
{
@@ -127,7 +127,7 @@ namespace Microsoft.Test.ModuleCore
}
}
- static public string CommandLine
+ public static string CommandLine
{
get
{
@@ -142,7 +142,7 @@ namespace Microsoft.Test.ModuleCore
}
}
- static public String Filter
+ public static String Filter
{
get
{
@@ -152,7 +152,7 @@ namespace Microsoft.Test.ModuleCore
}
}
- static public String MaxPriority
+ public static String MaxPriority
{
get
{
diff --git a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/util.cs b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/util.cs
index 4d66312861..05b1611831 100644
--- a/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/util.cs
+++ b/src/System.Private.Xml.Linq/tests/XDocument.Test.ModuleCore/util.cs
@@ -5,8 +5,6 @@
using System;
using System.Collections.Generic;
-[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
-
namespace Microsoft.Test.ModuleCore
{
////////////////////////////////////////////////////////////////
@@ -15,7 +13,7 @@ namespace Microsoft.Test.ModuleCore
////////////////////////////////////////////////////////////////
internal class StringEx
{
- static public string ToString(object value)
+ public static string ToString(object value)
{
if (value == null)
return null;
@@ -23,7 +21,7 @@ namespace Microsoft.Test.ModuleCore
return value.ToString();
}
- static public string Format(object value)
+ public static string Format(object value)
{
if (value == null)
return "(null)";
diff --git a/src/System.Private.Xml.Linq/tests/XPath/XDocument/XDocumentXPathTest.cs b/src/System.Private.Xml.Linq/tests/XPath/XDocument/XDocumentXPathTest.cs
index 41b90a67e7..9fa102fd7c 100644
--- a/src/System.Private.Xml.Linq/tests/XPath/XDocument/XDocumentXPathTest.cs
+++ b/src/System.Private.Xml.Linq/tests/XPath/XDocument/XDocumentXPathTest.cs
@@ -8,7 +8,7 @@ namespace XPathTests.Common
{
public static partial class Utils
{
- private readonly static ICreateNavigator _navigatorCreator = new CreateNavigatorComparer();
- public readonly static string ResourceFilesPath = "System.Xml.XPath.XDocument.Tests.TestData.";
+ private static readonly ICreateNavigator _navigatorCreator = new CreateNavigatorComparer();
+ public static readonly string ResourceFilesPath = "System.Xml.XPath.XDocument.Tests.TestData.";
}
}
diff --git a/src/System.Private.Xml.Linq/tests/misc/LoadSaveAsyncTests.cs b/src/System.Private.Xml.Linq/tests/misc/LoadSaveAsyncTests.cs
new file mode 100644
index 0000000000..0c09af3d86
--- /dev/null
+++ b/src/System.Private.Xml.Linq/tests/misc/LoadSaveAsyncTests.cs
@@ -0,0 +1,206 @@
+// 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 System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Xml;
+using System.Xml.Linq;
+using XmlCoreTest.Common;
+using Xunit;
+
+namespace CoreXml.Test.XLinq
+{
+ public class LoadSaveAsyncTests : BridgeHelpers
+ {
+ [Fact]
+ public static void ArgumentValidation()
+ {
+ // Verify that ArgumentNullExceptions are thrown when passing null to LoadAsync and SaveAsync
+ Assert.Throws<ArgumentNullException>(() => { XDocument.LoadAsync((XmlReader)null, LoadOptions.None, CancellationToken.None); });
+ Assert.Throws<ArgumentNullException>(() => { new XDocument().SaveAsync((XmlWriter)null, CancellationToken.None); });
+ Assert.Throws<ArgumentNullException>(() => { XElement.LoadAsync((XmlReader)null, LoadOptions.None, CancellationToken.None); });
+ Assert.Throws<ArgumentNullException>(() => { new XElement("Name").SaveAsync((XmlWriter)null, CancellationToken.None); });
+ }
+
+ [Fact]
+ public static async Task AlreadyCanceled()
+ {
+ // Verify that providing an already canceled cancellation token will result in a canceled task
+
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => XDocument.LoadAsync(Stream.Null, LoadOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => XDocument.LoadAsync(StreamReader.Null, LoadOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => XDocument.LoadAsync(XmlReader.Create(Stream.Null), LoadOptions.None, new CancellationToken(true)));
+
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => new XDocument().SaveAsync(Stream.Null, SaveOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => new XDocument().SaveAsync(StreamWriter.Null, SaveOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => new XDocument().SaveAsync(XmlWriter.Create(Stream.Null), new CancellationToken(true)));
+
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => XElement.LoadAsync(Stream.Null, LoadOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => XElement.LoadAsync(StreamReader.Null, LoadOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => XElement.LoadAsync(XmlReader.Create(Stream.Null), LoadOptions.None, new CancellationToken(true)));
+
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => new XElement("Name").SaveAsync(Stream.Null, SaveOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => new XElement("Name").SaveAsync(StreamWriter.Null, SaveOptions.None, new CancellationToken(true)));
+ await Assert.ThrowsAnyAsync<OperationCanceledException>(() => new XElement("Name").SaveAsync(XmlWriter.Create(Stream.Null), new CancellationToken(true)));
+ }
+
+ [Theory]
+ [MemberData("RoundtripOptions_MemberData")]
+ public static async Task RoundtripSyncAsyncMatches_XmlReader(bool document, LoadOptions loadOptions, SaveOptions saveOptions)
+ {
+ // Create reader and writer settings
+ var readerSettings = new XmlReaderSettings();
+ var writerSettings = new XmlWriterSettings();
+ if ((saveOptions & SaveOptions.OmitDuplicateNamespaces) != 0)
+ {
+ writerSettings.NamespaceHandling = NamespaceHandling.OmitDuplicates;
+ }
+ if ((saveOptions & SaveOptions.DisableFormatting) != 0)
+ {
+ writerSettings.Indent = false;
+ writerSettings.NewLineHandling = NewLineHandling.None;
+ }
+
+ // Roundtrip XML using synchronous and XmlReader/Writer
+ MemoryStream syncOutput = new MemoryStream();
+ using (XmlReader syncReader = XmlReader.Create(FilePathUtil.getStream(GetTestFileName()), readerSettings))
+ using (XmlWriter syncWriter = XmlWriter.Create(syncOutput, writerSettings))
+ {
+ if (document)
+ {
+ XDocument syncDoc = XDocument.Load(syncReader, loadOptions);
+ syncDoc.Save(syncWriter);
+ }
+ else
+ {
+ XElement syncElement = XElement.Load(syncReader, loadOptions);
+ syncElement.Save(syncWriter);
+ }
+ }
+
+ // Roundtrip XML using asynchronous and XmlReader/Writer
+ readerSettings.Async = true;
+ writerSettings.Async = true;
+ MemoryStream asyncOutput = new MemoryStream();
+ using (XmlReader asyncReader = XmlReader.Create(FilePathUtil.getStream(GetTestFileName()), readerSettings))
+ using (XmlWriter asyncWriter = XmlWriter.Create(asyncOutput, writerSettings))
+ {
+ if (document)
+ {
+ XDocument asyncDoc = await XDocument.LoadAsync(asyncReader, loadOptions, CancellationToken.None);
+ await asyncDoc.SaveAsync(asyncWriter, CancellationToken.None);
+ }
+ else
+ {
+ XElement asyncElement = await XElement.LoadAsync(asyncReader, loadOptions, CancellationToken.None);
+ await asyncElement.SaveAsync(asyncWriter, CancellationToken.None);
+ }
+ }
+
+ // Compare to make sure the synchronous and asynchronous results are the same
+ Assert.Equal(syncOutput.ToArray(), asyncOutput.ToArray());
+ }
+
+ [Theory]
+ [MemberData("RoundtripOptions_MemberData")]
+ public static async Task RoundtripSyncAsyncMatches_StreamReader(bool document, LoadOptions loadOptions, SaveOptions saveOptions)
+ {
+ // Roundtrip XML using synchronous and StreamReader/Writer
+ MemoryStream syncOutput = new MemoryStream();
+ using (StreamReader syncReader = new StreamReader(FilePathUtil.getStream(GetTestFileName())))
+ using (StreamWriter syncWriter = new StreamWriter(syncOutput))
+ {
+ if (document)
+ {
+ XDocument syncDoc = XDocument.Load(syncReader, loadOptions);
+ syncDoc.Save(syncWriter, saveOptions);
+ }
+ else
+ {
+ XElement syncElement = XElement.Load(syncReader, loadOptions);
+ syncElement.Save(syncWriter, saveOptions);
+ }
+ }
+
+ // Roundtrip XML using asynchronous and StreamReader/Writer
+ MemoryStream asyncOutput = new MemoryStream();
+ using (StreamReader asyncReader = new StreamReader(FilePathUtil.getStream(GetTestFileName())))
+ using (StreamWriter asyncWriter = new StreamWriter(asyncOutput))
+ {
+ if (document)
+ {
+ XDocument asyncDoc = await XDocument.LoadAsync(asyncReader, loadOptions, CancellationToken.None);
+ await asyncDoc.SaveAsync(asyncWriter, saveOptions, CancellationToken.None);
+ }
+ else
+ {
+ XElement asyncElement = await XElement.LoadAsync(asyncReader, loadOptions, CancellationToken.None);
+ await asyncElement.SaveAsync(asyncWriter, saveOptions, CancellationToken.None);
+ }
+ }
+
+ // Compare to make sure the synchronous and asynchronous results are the same
+ Assert.Equal(syncOutput.ToArray(), asyncOutput.ToArray());
+ }
+
+ [Theory]
+ [MemberData("RoundtripOptions_MemberData")]
+ public static async Task RoundtripSyncAsyncMatches_Stream(bool document, LoadOptions loadOptions, SaveOptions saveOptions)
+ {
+ // Roundtrip XML using synchronous and Stream
+ MemoryStream syncOutput = new MemoryStream();
+ using (Stream syncStream = FilePathUtil.getStream(GetTestFileName()))
+ {
+ if (document)
+ {
+ XDocument syncDoc = XDocument.Load(syncStream, loadOptions);
+ syncDoc.Save(syncOutput, saveOptions);
+ }
+ else
+ {
+ XElement syncElement = XElement.Load(syncStream, loadOptions);
+ syncElement.Save(syncOutput, saveOptions);
+ }
+ }
+
+ // Roundtrip XML using asynchronous and Stream
+ MemoryStream asyncOutput = new MemoryStream();
+ using (Stream asyncStream = FilePathUtil.getStream(GetTestFileName()))
+ {
+ if (document)
+ {
+ XDocument asyncDoc = await XDocument.LoadAsync(asyncStream, loadOptions, CancellationToken.None);
+ await asyncDoc.SaveAsync(asyncOutput, saveOptions, CancellationToken.None);
+ }
+ else
+ {
+ XElement asyncElement = await XElement.LoadAsync(asyncStream, loadOptions, CancellationToken.None);
+ await asyncElement.SaveAsync(asyncOutput, saveOptions, CancellationToken.None);
+ }
+ }
+
+ // Compare to make sure the synchronous and asynchronous results are the same
+ Assert.Equal(syncOutput.ToArray(), asyncOutput.ToArray());
+ }
+
+ // Inputs to the Roundtrip* tests:
+ // - Boolean for whether to test XDocument (true) or XElement (false)
+ // - LoadOptions value
+ // - SaveOptions value
+ public static IEnumerable<object[]> RoundtripOptions_MemberData
+ {
+ get
+ {
+ foreach (bool doc in new[] { true, false })
+ foreach (LoadOptions loadOptions in Enum.GetValues(typeof(LoadOptions)))
+ foreach (SaveOptions saveOptions in Enum.GetValues(typeof(SaveOptions)))
+ yield return new object[] { doc, loadOptions, saveOptions };
+ }
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj b/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj
index 92b73a6be1..c7a44deef7 100644
--- a/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj
+++ b/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj
@@ -17,8 +17,10 @@
<Compile Include="XHashtable.cs" />
<Compile Include="XLinqErrata4.cs" />
<Compile Include="XNameAPI.cs" />
+ <Compile Include="LoadSaveAsyncTests.cs" Condition="'$(TargetGroup)'==''" />
</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="..\XDocument.Common\XDocument.Common.csproj" />