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:
authorHuangli Wu <huanwu@microsoft.com>2017-11-29 00:58:04 +0300
committerGitHub <noreply@github.com>2017-11-29 00:58:04 +0300
commit5ce8eec31078e088c0fe7501b07cb656aed835a3 (patch)
tree3415531fee71e64693dfd1c89acc8fe9c462d459 /src/System.Private.Xml
parent07e10f3705ea09d4c2fe31641c7a0c2f6138e518 (diff)
Add a test to verify the XmlQualifiedName "duration" of TimeSpan type. (#25277)
* Add a test to verify the XmlQualifiedName "duration" for TimeSpan type. * Skip on netfx. Update test code. * Not use smartcompare. * Update verification * Update the verification. * Pull out the baseline as a variable.
Diffstat (limited to 'src/System.Private.Xml')
-rw-r--r--src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs b/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
index 0eb45820c1..dc004d5b83 100644
--- a/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
+++ b/src/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs
@@ -2922,4 +2922,29 @@ public static partial class XmlSerializerTests
Assert.StrictEqual(value, actual);
}
+
+ [ConditionalFact(nameof(IsTimeSpanSerializationAvailable))]
+ public static void VerifyRestrictionElementForTimeSpanTest()
+ {
+ var schemas = new XmlSchemas();
+ var exporter = new XmlSchemaExporter(schemas);
+ XmlTypeMapping mapping = new XmlReflectionImporter().ImportTypeMapping(typeof(TimeSpan));
+ exporter.ExportTypeMapping(mapping);
+ XmlSchema schema = schemas.Where(s => s.TargetNamespace == "http://microsoft.com/wsdl/types/").FirstOrDefault();
+ Assert.NotNull(schema);
+ var ms = new MemoryStream();
+ schema.Write(ms);
+ ms.Position = 0;
+ string actualOutput = new StreamReader(ms).ReadToEnd();
+ XElement element = XElement.Parse(actualOutput);
+ while (element.Elements().Count() != 0)
+ {
+ element = element.Elements().First();
+ }
+
+ string expectedAttribute = "xs:duration";
+ string baseline = "<?xml version=\"1.0\"?>\r\n<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\r\n <xs:simpleType name=\"TimeSpan\">\r\n <xs:restriction base=\"xs:duration\" />\r\n </xs:simpleType>\r\n</xs:schema>";
+ Assert.True(element.LastAttribute.Value == expectedAttribute, string.Format("{0}Test failed for wrong output from schema: {0}Expected Output: {1}{0}Actual Output: {2}",
+ Environment.NewLine, baseline, actualOutput));
+ }
}