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

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/libraries/System.Private.Xml/tests')
-rw-r--r--src/libraries/System.Private.Xml/tests/ExceptionVerifier.cs (renamed from src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ExceptionVerifier.cs)17
-rw-r--r--src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj3
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_EndElement.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_String.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateWhitespace_String.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs4
-rw-r--r--src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs21
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/Errata4.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/OutputSettings.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/TempFiles.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs15
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompilerTests.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslTransformMultith.cs2
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentListMultith.cs3
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs1
-rw-r--r--src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs397
23 files changed, 60 insertions, 417 deletions
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ExceptionVerifier.cs b/src/libraries/System.Private.Xml/tests/ExceptionVerifier.cs
index 7d8fe958f7a..12897b355ef 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ExceptionVerifier.cs
+++ b/src/libraries/System.Private.Xml/tests/ExceptionVerifier.cs
@@ -10,7 +10,7 @@ using System.Resources;
using System.Text.RegularExpressions;
using Xunit.Abstractions;
-namespace System.Xml.XmlSchemaValidatorApiTests
+namespace System.Xml.Tests
{
public class LineInfo
{
@@ -134,13 +134,18 @@ namespace System.Xml.XmlSchemaValidatorApiTests
{
_output.WriteLine(e2.ToString());
}
+ catch (PlatformNotSupportedException e3)
+ {
+ // NativeAOT doesn't support assembly loading
+ _output.WriteLine(e3.ToString());
+ }
}
}
catch (Exception e)
{
_output.WriteLine("Exception: " + e.Message);
_output.WriteLine("Stack: " + e.StackTrace);
- throw new VerifyException("Error while loading assembly");
+ throw new VerifyException("Error while loading assembly", e);
}
string[] resArray;
@@ -175,7 +180,6 @@ namespace System.Xml.XmlSchemaValidatorApiTests
}
resReader.Dispose();
}
- //break;
}
}
@@ -209,8 +213,7 @@ namespace System.Xml.XmlSchemaValidatorApiTests
"\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"*/);
+ "\n===== Source =====\n" + _ex.Source);
_output.WriteLine(
"\n===== InnerException =====\n" + _ex.InnerException +
@@ -395,5 +398,9 @@ namespace System.Xml.XmlSchemaValidatorApiTests
public VerifyException(string msg)
: base(msg)
{ }
+
+ public VerifyException(string msg, Exception innerException)
+ : base(msg, innerException)
+ { }
}
}
diff --git a/src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj b/src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj
index 46b3cf44153..bce17d6636d 100644
--- a/src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj
+++ b/src/libraries/System.Private.Xml/tests/System.Private.Xml.Tests.csproj
@@ -17,6 +17,7 @@
<ItemGroup>
<Compile Include="AllowDefaultResolverContext.cs" />
+ <Compile Include="ExceptionVerifier.cs" />
<Compile Include="$(CommonTestPath)\TestUtilities\System\DisableParallelizationPerAssembly.cs" Link="Common\TestUtilities\System\DisableParallelizationPerAssembly.cs" />
</ItemGroup>
@@ -401,7 +402,6 @@
<ItemGroup>
<Compile Include="XmlSchema\XmlSchemaValidatorApi\Constructor_AddSchema.cs" />
<Compile Include="XmlSchema\XmlSchemaValidatorApi\CustomImplementations.cs" />
- <Compile Include="XmlSchema\XmlSchemaValidatorApi\ExceptionVerifier.cs" />
<Compile Include="XmlSchema\XmlSchemaValidatorApi\GetExpectedAttributes.cs" />
<Compile Include="XmlSchema\XmlSchemaValidatorApi\GetExpectedParticles.cs" />
<Compile Include="XmlSchema\XmlSchemaValidatorApi\Initialize_EndValidation.cs" />
@@ -641,7 +641,6 @@
<Compile Include="Xslt\XslTransformApi\CThreads.cs" />
<Compile Include="Xslt\XslTransformApi\CXmlCache.cs" />
<Compile Include="Xslt\XslTransformApi\DataHelper.cs" />
- <Compile Include="Xslt\XslTransformApi\ExceptionVerifier.cs" />
<Compile Include="Xslt\XslTransformApi\MyNavigator.cs" />
<Compile Include="Xslt\XslTransformApi\ReaderType.cs" />
<Compile Include="Xslt\XslTransformApi\ThreadFunc.cs" />
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs
index 9deba7048c8..6841f97695e 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/Initialize_EndValidation.cs
@@ -3,6 +3,7 @@
using System.IO;
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs
index 9193f315b89..03387e85c08 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/PropertiesTests.cs
@@ -4,6 +4,7 @@
using System.Collections;
using System.IO;
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs
index 12c1dc848e0..906a1116b7b 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute.cs
@@ -4,6 +4,7 @@
using System.Collections;
using System.IO;
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs
index b2943e64d09..6138514462d 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateAttribute_String.cs
@@ -4,6 +4,7 @@
using System.Collections;
using System.IO;
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs
index 7fcafeb2ea7..8731e36ca76 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateElement.cs
@@ -3,6 +3,7 @@
using System.IO;
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_EndElement.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_EndElement.cs
index 94de287d334..be3d020366d 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_EndElement.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_EndElement.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_String.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_String.cs
index fe9affd1e32..dcbd300d94f 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_String.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateText_String.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateWhitespace_String.cs b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateWhitespace_String.cs
index c4afb2ece7f..9ae71cdff65 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateWhitespace_String.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/ValidateWhitespace_String.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Xml.Schema;
+using System.Xml.Tests;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
index f3e9a8f958c..29a7880968a 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
@@ -1059,7 +1059,7 @@ public static partial class XmlSerializerTests
});
}
- [ConditionalFact(nameof(IsTimeSpanSerializationAvailable))]
+ [Fact]
public static void Xml_TimeSpanAsRoot()
{
Assert.StrictEqual(new TimeSpan(1, 2, 3), SerializeAndDeserialize<TimeSpan>(new TimeSpan(1, 2, 3),
@@ -3013,7 +3013,7 @@ public static partial class XmlSerializerTests
Assert.StrictEqual(value, actual);
}
- [ConditionalFact(nameof(IsTimeSpanSerializationAvailable))]
+ [Fact]
public static void VerifyRestrictionElementForTimeSpanTest()
{
var schemas = new XmlSchemas();
diff --git a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
index b834792eebf..4a4235bb617 100644
--- a/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
+++ b/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs
@@ -21,9 +21,13 @@ using System.Xml.Serialization;
using SerializationTypes;
using Xunit;
+#if !ReflectionOnly && !XMLSERIALIZERGENERATORTESTS
+// Many test failures due to trimming and MakeGeneric. XmlSerializer is not currently supported with NativeAOT.
+[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))]
+#endif
public static partial class XmlSerializerTests
{
-#if ReflectionOnly|| XMLSERIALIZERGENERATORTESTS
+#if ReflectionOnly || XMLSERIALIZERGENERATORTESTS
private static readonly string SerializationModeSetterName = "set_Mode";
static XmlSerializerTests()
@@ -39,8 +43,6 @@ public static partial class XmlSerializerTests
}
#endif
- private static bool IsTimeSpanSerializationAvailable => true;
-
[Fact]
public static void Xml_TypeWithDateTimePropertyAsXmlTime()
{
@@ -64,14 +66,11 @@ string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
Value = new DateTime(549269870000L, DateTimeKind.Utc)
};
- if (IsTimeSpanSerializationAvailable)
- {
- TypeWithDateTimePropertyAsXmlTime utcTimeRoundTrip = SerializeAndDeserialize(utcTimeObject,
- @"<?xml version=""1.0"" encoding=""utf-8""?>
+ TypeWithDateTimePropertyAsXmlTime utcTimeRoundTrip = SerializeAndDeserialize(utcTimeObject,
+@"<?xml version=""1.0"" encoding=""utf-8""?>
<TypeWithDateTimePropertyAsXmlTime xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">15:15:26.9870000Z</TypeWithDateTimePropertyAsXmlTime>");
- Assert.StrictEqual(utcTimeObject.Value, utcTimeRoundTrip.Value);
- }
+ Assert.StrictEqual(utcTimeObject.Value, utcTimeRoundTrip.Value);
}
[Fact]
@@ -812,7 +811,7 @@ string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
}
}
- [ConditionalFact(nameof(IsTimeSpanSerializationAvailable))]
+ [Fact]
public static void Xml_TypeWithTimeSpanProperty()
{
var obj = new TypeWithTimeSpanProperty { TimeSpanProperty = TimeSpan.FromMilliseconds(1) };
@@ -824,7 +823,7 @@ string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
Assert.StrictEqual(obj.TimeSpanProperty, deserializedObj.TimeSpanProperty);
}
- [ConditionalFact(nameof(IsTimeSpanSerializationAvailable))]
+ [Fact]
public static void Xml_TypeWithDefaultTimeSpanProperty()
{
var obj = new TypeWithDefaultTimeSpanProperty { TimeSpanProperty2 = new TimeSpan(0, 1, 0) };
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/Errata4.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/Errata4.cs
index 6846c462c17..68e0964199f 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/Errata4.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/Errata4.cs
@@ -13,6 +13,7 @@ using Xunit.Abstractions;
namespace System.Xml.XslCompiledTransformApiTests
{
//[TestCase(Name = "Xml 4th Errata tests for XslCompiledTransform", Params = new object[] { 300 })]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class Errata4 : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/OutputSettings.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/OutputSettings.cs
index 4c0b3500f46..5bf09df20ed 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/OutputSettings.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/OutputSettings.cs
@@ -10,6 +10,7 @@ using Xunit.Abstractions;
namespace System.Xml.XslCompiledTransformApiTests
{
//[TestCase(Name = "OutputSettings", Desc = "This testcase tests the OutputSettings on XslCompiledTransform", Param = "Debug")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class COutputSettings : XsltApiTestCaseBase2
{
private XslCompiledTransform _xsl = null;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/TempFiles.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/TempFiles.cs
index f9532bb061e..373314df7bb 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/TempFiles.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/TempFiles.cs
@@ -9,6 +9,7 @@ using Xunit.Abstractions;
namespace System.Xml.XslCompiledTransformApiTests
{
//[TestCase(Name = "TemporaryFiles", Desc = "This testcase tests the Temporary Files property on XslCompiledTransform")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class TempFiles : XsltApiTestCaseBase2
{
private XslCompiledTransform _xsl = null;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs
index 20bdea92a91..3739812954e 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompiledTransform.cs
@@ -81,6 +81,7 @@ namespace System.Xml.XslCompiledTransformApiTests
}
//[TestCase(Name = "Load(MethodInfo, ByteArray, TypeArray) tests", Desc = "This testcase tests private Load method via Reflection. This method is used by sharepoint")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadMethInfoTest : ReflectionTestCaseBase
{
private ITestOutputHelper _output;
@@ -476,6 +477,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.XmlResolver : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
//[TestCase(Name = "XslCompiledTransform.XmlResolver : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
//[TestCase(Name = "XslCompiledTransform.XmlResolver : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CXmlResolverTest : XsltApiTestCaseBase2, IDisposable
{
private ITestOutputHelper _output;
@@ -666,6 +668,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Load() - Integrity : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Load() - Integrity : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
//[TestCase(Name = "XslCompiledTransform.Load() - Integrity : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -1004,6 +1007,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Load(XmlResolver) - Integrity : URI, Stream", Desc = "URI,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Load(XmlResolver) - Integrity : URI, Writer", Desc = "URI,WRITER")]
//[TestCase(Name = "XslCompiledTransform.Load(XmlResolver) - Integrity : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadXmlResolverTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -1435,6 +1439,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Load(Url, Resolver) : URI, Stream", Desc = "URI,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Load(Url, Resolver) : URI, Writer", Desc = "URI,WRITER")]
//[TestCase(Name = "XslCompiledTransform.Load(Url, Resolver) : URI, TextWriter", Desc = "URI,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadUrlResolverTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -1534,6 +1539,7 @@ namespace System.Xml.XslCompiledTransformApiTests
/***********************************************************/
//[TestCase(Name = "XslCompiledTransform.Load(Url) Integrity : URI, Stream", Desc = "URI,STREAM")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadStringTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -1652,6 +1658,7 @@ namespace System.Xml.XslCompiledTransformApiTests
/***********************************************************/
//[TestCase(Name = "XslCompiledTransform .Load(IXPathNavigable) : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadXPathNavigableTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -1760,6 +1767,7 @@ namespace System.Xml.XslCompiledTransformApiTests
/***********************************************************/
//[TestCase(Name = "XslCompiledTransform.Load(Reader) : Reader, Stream", Desc = "READER,STREAM")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CLoadReaderTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -2149,6 +2157,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Transform() Integrity : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Transform() Integrity : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
//[TestCase(Name = "XslCompiledTransform.Transform() Integrity : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CTransformTestGeneric : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -2404,6 +2413,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Transform(XmlResolver) : Navigator, Stream", Desc = "NAVIGATOR,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Transform(XmlResolver) : Navigator, Writer", Desc = "NAVIGATOR,WRITER")]
//[TestCase(Name = "XslCompiledTransform.Transform(XmlResolver) : Navigator, TextWriter", Desc = "NAVIGATOR,TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CTransformResolverTest : XsltApiTestCaseBase2, IDisposable
{
private ITestOutputHelper _output;
@@ -2615,6 +2625,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Transform(String, String) : Reader , String", Desc = "READER,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Transform(String, String) : URI, String", Desc = "URI,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Transform(String, String) : Navigator, String", Desc = "NAVIGATOR,STREAM")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CTransformStrStrTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -2987,6 +2998,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Transform(String, String, Resolver) : Reader , String", Desc = "READER,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Transform(String, String, Resolver) : URI, String", Desc = "URI,STREAM")]
//[TestCase(Name = "XslCompiledTransform.Transform(String, String, Resolver) : Navigator, String", Desc = "NAVIGATOR,STREAM")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CTransformStrStrResolverTest : XsltApiTestCaseBase2, IDisposable
{
private ITestOutputHelper _output;
@@ -3091,6 +3103,7 @@ namespace System.Xml.XslCompiledTransformApiTests
//[TestCase(Name = "XslCompiledTransform.Transform(IXPathNavigable, XsltArgumentList, XmlWriter, XmlResolver)", Desc = "Constructor Tests", Param = "IXPathNavigable")]
//[TestCase(Name = "XslCompiledTransform.Transform(XmlReader, XsltArgumentList, XmlWriter, XmlResolver)", Desc = "Constructor Tests", Param = "XmlReader")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CTransformConstructorWithFourParametersTest : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -3295,6 +3308,7 @@ namespace System.Xml.XslCompiledTransformApiTests
// 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")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CNDP1_1SP1Test : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
@@ -3386,6 +3400,7 @@ param2 (correct answer is 'local-param2-arg'): local-param2-arg
}
//[TestCase(Name = "XslCompiledTransform Regression Tests for API", Desc = "XslCompiledTransform Regression Tests")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CTransformRegressionTest : XsltApiTestCaseBase2, IDisposable
{
private ITestOutputHelper _output;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompilerTests.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompilerTests.cs
index b788db89bfd..77230c4d625 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompilerTests.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslCompilerTests.cs
@@ -7,6 +7,7 @@ using Xunit;
namespace System.Xml.XslCompiledTransformApiTests
{
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class XslCompilerTests
{
[Fact]
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslTransformMultith.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslTransformMultith.cs
index 0532519a87e..5699868c280 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslTransformMultith.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XslTransformMultith.cs
@@ -35,6 +35,7 @@ namespace System.Xml.XslCompiledTransformApiTests
}
//[TestCase(Name = "Same instance testing: Transform() - READER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class SameInstanceXslTransformReader : SameInstanceXslTransformTestCase
{
private XPathDocument _xd; // Loads XML file
@@ -318,6 +319,7 @@ namespace System.Xml.XslCompiledTransformApiTests
}
//[TestCase(Name = "Same instance testing: Transform() - TEXTWRITER")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class SameInstanceXslTransformWriter : SameInstanceXslTransformTestCase
{
private XPathDocument _xd; // Loads XML file
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs
index 6184bfc0e31..0e7dd962fce 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltApiV2.cs
@@ -37,6 +37,7 @@ namespace System.Xml.XslCompiledTransformApiTests
// Base class for test cases
//
////////////////////////////////////////////////////////////////
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class XsltApiTestCaseBase2
{
// Generic data for all derived test cases
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs
index 5e9d7a877cc..6bf0e435b2e 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentList.cs
@@ -17,6 +17,7 @@ namespace System.Xml.XslCompiledTransformApiTests
/***********************************************************/
//[TestCase(Name = "XsltArgumentList - GetParam", Desc = "Get Param Test Cases")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CArgIntegrity : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentListMultith.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentListMultith.cs
index 39a6646ecaf..bfa3788d0c9 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentListMultith.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltArgumentListMultith.cs
@@ -55,6 +55,7 @@ namespace System.Xml.XslCompiledTransformApiTests
}
//[TestCase(Name = "Same instance testing: XsltArgList - GetParam", Desc = "GetParam test cases")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CSameInstanceXsltArgumentListGetParam : CSameInstanceXsltArgTestCase2
{
private ITestOutputHelper _output;
@@ -140,6 +141,7 @@ namespace System.Xml.XslCompiledTransformApiTests
}
//[TestCase(Name = "Same instance testing: XsltArgList - GetExtensionObject", Desc = "GetExtensionObject test cases")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CSameInstanceXsltArgumentListGetExtnObject : CSameInstanceXsltArgTestCase2
{
private ITestOutputHelper _output;
@@ -224,6 +226,7 @@ namespace System.Xml.XslCompiledTransformApiTests
}
//[TestCase(Name = "Same instance testing: XsltArgList - Transform", Desc = "Multiple transforms")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CSameInstanceXsltArgumentListTransform : CSameInstanceXsltArgTestCase2
{
private ITestOutputHelper _output;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs
index 0ef104833f8..e780f556cfd 100644
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs
+++ b/src/libraries/System.Private.Xml/tests/Xslt/XslCompiledTransformApi/XsltSettings.cs
@@ -13,6 +13,7 @@ namespace System.Xml.XslCompiledTransformApiTests
{
//[TestCase(Name = "XsltSettings-Retail", Desc = "This testcase tests the different settings on XsltSettings and the corresponding behavior in retail mode", Param = "Retail")]
//[TestCase(Name = "XsltSettings-Debug", Desc = "This testcase tests the different settings on XsltSettings and the corresponding behavior in debug mode", Param = "Debug")]
+ [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public class CXsltSettings : XsltApiTestCaseBase2
{
private ITestOutputHelper _output;
diff --git a/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs b/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs
deleted file mode 100644
index 3cd3490ef9c..00000000000
--- a/src/libraries/System.Private.Xml/tests/Xslt/XslTransformApi/ExceptionVerifier.cs
+++ /dev/null
@@ -1,397 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Collections;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Resources;
-using System.Text.RegularExpressions;
-using Xunit.Abstractions;
-
-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().Assembly;
- }
- break;
- default:
- _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
- {
- // 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();
- }
- }
- }
-
- if (!bFound || resStream == null)
- throw new VerifyException("GetManifestResourceStream() failed");
- }
-
- private static string GetRuntimeInstallDir()
- {
- // Get mscorlib path
- var s = typeof(object).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.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);
-
- _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)
- { }
- }
-}