Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{D6C51F53-33E2-41DF-981A-33FCFA81CDA7}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "Microsoft.Test"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
RootNamespace = "Test"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
/>
<Reference
Name = "NUnitCore"
AssemblyName = "NUnitCore"
HintPath = "..\..\..\nunit\NUnitCore.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AllTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ChangeLog"
BuildAction = "None"
/>
<File
RelPath = "NameTableTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlAttributeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlCDataSectionTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlCommentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlDeclarationTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlDocumentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlDocumentTypeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlElementTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlNamespaceManagerTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlNodeListTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlSignificantWhitespaceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlTextReaderTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlTextWriterTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlWhiteSpaceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,167 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{D6C51F53-33E2-41DF-981A-33FCFA81CDA7}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "Mono.Test"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
RootNamespace = "Test"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "Mono.System.XML"
Project = "{0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
Name = "NUnitCore"
AssemblyName = "NUnitCore"
HintPath = "..\..\..\nunit\NUnitCore.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AllTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ChangeLog"
BuildAction = "None"
/>
<File
RelPath = "NameTableTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlAttributeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlCDataSectionTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlCommentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlDeclarationTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlDocumentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlDocumentTypeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlElementTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlNamespaceManagerTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlNodeListTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlSignificantWhitespaceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlTextReaderTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlTextWriterTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "XmlWhiteSpaceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,428 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{F7734143-3845-4288-B1CA-FE614FFA70F0}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "MonoMicro.Test"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "MonoMicro.Test"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "nunit.framework"
AssemblyName = "nunit.framework"
HintPath = "..\..\..\..\..\Program Files\NUnit V2.0\bin\nunit.framework.dll"
/>
<Reference
Name = "Mono.System.XML"
Project = "{0CB7FB41-3C0F-40E8-ACD3-8C5B8BC35B2C}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "ChangeLog"
BuildAction = "None"
/>
<File
RelPath = "System.Xml\NameTableTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlAttributeCollectionTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlAttributeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlCDataSectionTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlCharacterDataTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlCharTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlCommentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlConvertTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlDeclarationTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlDocumentEventTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlDocumentFragmentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlDocumentTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlDocumentTypeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlElementTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlEntityReferenceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlEntityTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlNamespaceManagerTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlNodeListTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlNodeReaderTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlNodeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlProcessingInstructionTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlReaderCommonTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlSecureResolverTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlSignificantWhitespaceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlTextReaderTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlTextTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlTextWriterTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlUrlResolverTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlValidatingReaderTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlWhiteSpaceTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XmlWriterTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XsdParticleValidationTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\XsdValidatingReaderTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\ITest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\util.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\Attr\Attr.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\CharacterData\CharacterData.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\Comment\Comment.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\Document\Document.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\DOMImplementation\DOMImplementation.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\Element\Element.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\NamedNodeMap\NamedNodeMap.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\Node\Node.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\NodeList\NodeList.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml\nist_dom\fundamental\Text\Text.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaAssertion.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaBuiltInDatatypeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaCollectionTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaComplexTypeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaDatatypeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaGroupRefTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaLengthFacetTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Schema\XmlSchemaTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Serialization\DeserializeTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Serialization\XmlAttributesTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Serialization\XmlReflectionImporterTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Serialization\XmlSerializationWriterTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Serialization\XmlSerializerTestClasses.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Serialization\XmlSerializerTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.XPath\SelectNodesTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.XPath\XPathNavigatorCommonTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.XPath\XPathNavigatorEvaluateTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.XPath\XPathNavigatorMatchesTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.XPath\XPathNavigatorTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Xsl\MsxslScriptTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Xsl\XsltArgumentListTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "System.Xml.Xsl\XslTransformTests.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,285 @@
2010-03-15 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #584664.
2010-01-27 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #557452, by
Luke Ravitch.
2010-01-26 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #502251, by
Jonas Larsson.
2010-01-26 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added test for bug #571650.
2009-07-09 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaTests.cs: Fixed tests for bug #502115.
2009-07-09 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : disabled wrong tests. I will revert them
unless it gets better shape.
2009-06-23 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaAssertion.cs, XmlSchemaTests.cs : migrate from Assertion
to Assert (it still uses XmlSchemaAssertion as the base class,
but XmlSchemaAssertion is not based on Assertion anymore).
2009-05-21 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaTests.cs: added tests for bug #502115.
2009-05-07 Jonas Larsson <jonas.larsson@manodo.se>
* XmlSchemaValidatorTests.cs : added test for bug #501666.
2009-04-22 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #496192 and #496205.
2009-01-30 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #469713.
2008-12-15 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added test for Compile() after "duplicating"
call to Add() for such schemas that also have xs:import of the
same schema that causes errors on processing substitutionGroup.
2008-10-28 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #435206.
2008-10-28 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #433774.
2008-09-09 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : added test for bug #422581.
2008-06-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : fix file path.
2008-06-06 James Fitzsimons <james.fitzsimons@gmail.com>
* XmlSchemaTests.cs: added test for bug #397612.
* XmlSchemaAssertion.cs : make sure to close schema XmlReader.
2008-06-06 James Fitzsimons <james.fitzsimons@gmail.com>
* XmlSchemaTests.cs: added test to support change to
GetResolvedUri to return Uri in correct case
to make compatible with the Microsoft.NET framework.
2008-02-19 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs: added test for bug #361818.
2008-02-04 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaValidatorTests.cs : new. Test for bug #358408.
2006-08-04 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTest.cs : added bug #78985 case.
2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTest.cs : added bug #77489 case.
* XmlSchemaCollectionTests.cs : removed NotWorking from #77820 case.
2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added AddWrongTargetNamespace().
2006-07-25 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : added TestSimpleMutualImport().
2006-04-27 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaCollectionTests.cs: added test for bug #78220.
2006-03-02 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : added test for bug #77687.
2006-03-01 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : added test for bug #77685.
2006-02-28 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaAssertion.cs: Set eol-style to native.
* XmlSchemaBuiltInDatatypeTests.cs: Set eol-style to CRLF.
* XmlSchemaCollectionTests.cs: Set eol-style to native. Fixed line
endings.
* XmlSchemaDatatypeTests.cs: Set eol-style to native.
* XmlSchemaExceptionCas.cs: Set eol-style to native.
* XmlSchemaLengthFacetTests.cs: Set eol-style to CRLF.
* XmlSchemaSetTests.cs: Set eol-style to native.
* XmlSchemaTests.cs: Set eol-style to native.
* XmlSchemaTypeTests.cs: Set eol-style to native.>
2006-02-28 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaTests.cs: Added test for writing XmlSchema with
zero-length TargetNamespace. Added test for compiling XmlSchema
with zero-length TargetNamespace. Replaced Console.WriteLine with
AssertEquals.
2006-02-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaDatatypeTests.cs: (TestAnyType) NotDotNet -> Ignore.
2006-02-06 Gert Driesen <drieseng@users.sourceforge.net>
* XmlSchemaDatatypeTests.cs: Marked TestAnyType NotDotNet on 2.0
profile instead of marking it NotWorking. No longer derive from
Assertion.
2006-02-01 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaDatatypeTests.cs : added two more anyURI tests.
2006-01-10 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTypeTests.cs : new file. Test for TypeCode.
* XmlSchemaSetTests.cs : added more tests for Add() and marked one as
NotWorking (we need info on how consistent this method is).
2006-01-10 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaDatatypeTests.cs : oops sys.col.generic is NET_2_0.
2006-01-10 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaDatatypeTests.cs : added test for 2.0 IsDerivedFrom().
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added AddRollbackIsCompiled(); Add() changes
IsCompiled to false.
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : reverted the patch, thus restore [Ignore].
2006-01-06 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : re-enabled test for Add() which was
inconsistent in beta versions.
2005-12-08 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added set_CompilationSettings tests.
2005-12-08 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added CompilationSettings tests.
2005-12-01 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs :
Additional schema component to finish #76865 test.
2005-12-01 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : added testcase for #76865.
2005-10-23 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : some namespace output strategy seems changed
in .NET 2.0 and they still make sense, so just mark them as
NotDotNet and NotWorking under 2.0.
2005-09-30 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : test for reader position after Read().
2005-08-31 Sebastien Pouliot <sebastien@ximian.com>
* XmlSchemaExceptionCas.cs: New. CAS unit tests for exception
serialization.
2005-06-11 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaCollectionTests.cs : added test for #75126.
2005-02-28 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : just set NotWorking for trivial comparison tests.
2005-01-30 Nick Drochak <ndrochak@ieee.org>
* XmlSchemaTests.cs: Use less strict test. Probably the order of the
namespaces is not required to be in any particular order.
2004-01-11 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : added TestWriteNamespaces2 ().
2004-09-13 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added.
2004-05-24 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaBuiltInDataypeTests.cs : 'Z' is not allowed here (maybe it
is 'T' that was wanted). More kind error message in Fail().
2004-05-05 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : Added TestWriteNamespaces().
2004-03-31 Atsushi Enomoto <atsushi@ximian.com>
* Added XmlSchemaAssertion.cs.
* XmlSchemaTests.cs : now uses XmlSchemaAssertion.
2004-01-03 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaTests.cs : fixed file path. Added more tests.
* added XmlSchemaCollectionTests.cs and XmlSchemaDatatypeTests.cs (the
latter one's purpose overlaps with XmlSchemaBuiltInDatatypeTests ;)
2003-12-17 David Sheldon <dave-mono@earth.li>
* Added XmlSchemaBuiltInDatatypeTests.cs : Currently fails due to
bug 52274.
2003-12-14 David Sheldon <dave-mono@earth.li>
* XmlSchemaLengthFacetTests.cs : Tests for non-integers failing
as length facets, and changed the assert for the correct type.
2003-12-08 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Added XmlSchemaLengthFacetTests.cs. (patch by David Sheldon.)
2003-07-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlSchemaTests.cs : added sequence and particle tests to TestCompile()
2003-07-20 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlSchemaTests.cs : added AssertComplexTypeContentExtension() and
added related tests in TestCompile().
2003-07-19 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlSchemaTests.cs : rewrote TestRead() and added TestCompile().
2003-04-12 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* added this file as a new entry.
See ../ChangeLog to find former ChangeLog entries.

View File

@@ -0,0 +1,102 @@
//
// System.Xml.XmlSchemaAssertion.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2004 Atsushi Enomoto
//
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
public class XmlSchemaAssertion
{
public static XmlSchema GetSchema (string path)
{
XmlTextReader reader = new XmlTextReader (path);
XmlSchema schema = XmlSchema.Read (reader, null);
reader.Close ();
return schema;
}
public static XmlQualifiedName QName (string name, string ns)
{
return new XmlQualifiedName (name, ns);
}
public static void AssertElement (XmlSchemaElement element,
string name, XmlQualifiedName refName, string id,
XmlQualifiedName schemaTypeName, XmlSchemaType schemaType)
{
Assert.IsNotNull (element);
Assert.AreEqual (name, element.Name);
Assert.AreEqual (refName, element.RefName);
Assert.AreEqual (id, element.Id);
Assert.AreEqual (schemaTypeName, element.SchemaTypeName);
Assert.AreEqual (schemaType, element.SchemaType);
}
public static void AssertElementEx (XmlSchemaElement element,
XmlSchemaDerivationMethod block, XmlSchemaDerivationMethod final,
string defaultValue, string fixedValue,
XmlSchemaForm form, bool isAbstract, bool isNillable,
XmlQualifiedName substGroup)
{
Assert.IsNotNull (element);
Assert.AreEqual (block, element.Block);
Assert.AreEqual (final, element.Final);
Assert.AreEqual (defaultValue, element.DefaultValue);
Assert.AreEqual (fixedValue, element.FixedValue);
Assert.AreEqual (form, element.Form);
Assert.AreEqual (isAbstract, element.IsAbstract);
Assert.AreEqual (isNillable, element.IsNillable);
Assert.AreEqual (substGroup, element.SubstitutionGroup);
}
public static void AssertCompiledComplexType (XmlSchemaComplexType cType,
XmlQualifiedName name,
int attributesCount, int attributeUsesCount,
bool existsAny, Type contentModelType,
bool hasContentTypeParticle,
XmlSchemaContentType contentType)
{
Assert.IsNotNull (cType);
Assert.AreEqual (name.Name, cType.Name);
Assert.AreEqual (name, cType.QualifiedName);
Assert.AreEqual (attributesCount, cType.Attributes.Count);
Assert.AreEqual (attributeUsesCount, cType.AttributeUses.Count);
Assert.IsTrue (existsAny == (cType.AttributeWildcard != null));
if (contentModelType == null)
Assert.IsNull (cType.ContentModel);
else
Assert.AreEqual (contentModelType, cType.ContentModel.GetType ());
Assert.AreEqual (hasContentTypeParticle, cType.ContentTypeParticle != null);
Assert.AreEqual (contentType, cType.ContentType);
}
public static void AssertCompiledComplexContentExtension (XmlSchemaComplexContentExtension xccx,
int attributeCount, bool hasAnyAttribute, XmlQualifiedName baseTypeName)
{
Assert.IsNotNull (xccx);
Assert.AreEqual (attributeCount, xccx.Attributes.Count);
Assert.AreEqual (hasAnyAttribute, xccx.AnyAttribute != null);
Assert.AreEqual (baseTypeName, xccx.BaseTypeName);
Assert.IsNotNull (xccx.Particle);
}
public static void AssertCompiledElement (XmlSchemaElement element,
XmlQualifiedName name, object elementType)
{
Assert.IsNotNull (element);
Assert.AreEqual (name, element.QualifiedName);
Assert.AreEqual (elementType, element.ElementType);
}
}
}

View File

@@ -0,0 +1,82 @@
//
// Tests for the properties of the builtin types.
//
// Author:
// David Sheldon <dave-mono@earth.li>
//
//
using System;
using System.Xml;
using System.Xml.Schema;
using System.IO;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaBuiltInDatatypeTests
{
[Test]
public void TestWhiteSpaceCollapse () {
WhiteSpaceTest("date", "2003-10-10");
WhiteSpaceTest("decimal", "2003.10");
WhiteSpaceTest("integer", "0004");
WhiteSpaceTest("float", "1.3");
WhiteSpaceTest("boolean", "true");
WhiteSpaceTest("double", "2.3");
WhiteSpaceTest("time", "12:34:56");
WhiteSpaceTest("duration", "P1347Y");
WhiteSpaceTest("dateTime", "2003-10-10T12:34:56.78");
WhiteSpaceTest("gYearMonth", "2003-10");
WhiteSpaceTest("gYear", "2003");
WhiteSpaceTest("gMonthDay", "--12-12"); //
WhiteSpaceTest("gMonth", "--12--"); // These three will fail, due to
WhiteSpaceTest("gDay", "---12"); // bug 52274
WhiteSpaceTest("hexBinary", "0fB7");
}
/* Takes a type name, and a valid example of that type,
Creates a schema consisting of a single element of that
type, and validates a bit of xml containing the valid
value, with whitespace against that schema.
FIXME: Really we want to test the value of whitespace more
directly that by creating a schema then parsing a string.
*/
public void WhiteSpaceTest(string type, string valid) {
passed = true;
XmlSchema schema = new XmlSchema();
schema.TargetNamespace= "http://example.com/testCase";
XmlSchemaElement element = new XmlSchemaElement();
element.Name = "a";
element.SchemaTypeName = new XmlQualifiedName(type, "http://www.w3.org/2001/XMLSchema");
schema.Items.Add(element);
schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
XmlValidatingReader vr = new XmlValidatingReader(new XmlTextReader(new StringReader("<a xmlns='http://example.com/testCase'>\n\n"+valid+"\n\n</a>" )));
vr.Schemas.Add(schema);
vr.ValidationType = ValidationType.Schema;
// vr.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
while(vr.Read()) { };
vr.Close();
Assert.IsTrue (passed, type + " doesn't collapse whitespace: " + (errorInfo != null ? errorInfo.Message : null));
}
bool passed = true;
ValidationEventArgs errorInfo;
public void ValidationCallbackOne(object sender, ValidationEventArgs args) {
passed = false;
errorInfo = args;
}
}
}

View File

@@ -0,0 +1,122 @@
//
// System.Xml.XmlSchemaCollectionTests.cs
//
// Author:
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
//
// (C) 2002 Atsushi Enomoto
//
using System;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaCollectionTests
{
private XmlSchema GetSchema (string path)
{
return XmlSchema.Read (new XmlTextReader (path), null);
}
private XmlQualifiedName QName (string name, string ns)
{
return new XmlQualifiedName (name, ns);
}
[Test]
public void TestAdd ()
{
XmlSchemaCollection col = new XmlSchemaCollection ();
XmlSchema schema = new XmlSchema ();
XmlSchemaElement elem = new XmlSchemaElement ();
elem.Name = "foo";
schema.Items.Add (elem);
schema.TargetNamespace = "urn:foo";
col.Add (schema);
col.Add (schema); // No problem !?
XmlSchema schema2 = new XmlSchema ();
schema2.Items.Add (elem);
schema2.TargetNamespace = "urn:foo";
col.Add (schema2); // No problem !!
schema.Compile (null);
col.Add (schema);
col.Add (schema); // Still no problem !!!
schema2.Compile (null);
col.Add (schema2);
schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
schema.Compile (null);
col.Add (schema);
schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
schema2.Compile (null);
col.Add (schema2);
}
[Test]
public void TestAddDoesCompilation ()
{
XmlSchema schema = new XmlSchema ();
Assert.IsFalse (schema.IsCompiled);
XmlSchemaCollection col = new XmlSchemaCollection ();
col.Add (schema);
Assert.IsTrue (schema.IsCompiled);
}
[Test] // bug #75126
public void TestGetEnumerator ()
{
new XmlSchemaCollection().GetEnumerator();
}
[Test] // bug #78220
public void TestCompile ()
{
string schemaFragment1 = string.Format (CultureInfo.InvariantCulture,
"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
"<xs:schema xmlns:tns=\"NSDate\" elementFormDefault=\"qualified\" targetNamespace=\"NSDate\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
" <xs:import namespace=\"NSStatus\" />{0}" +
" <xs:element name=\"trans\" type=\"tns:TranslationStatus\" />{0}" +
" <xs:complexType name=\"TranslationStatus\">{0}" +
" <xs:simpleContent>{0}" +
" <xs:extension xmlns:q1=\"NSStatus\" base=\"q1:StatusType\">{0}" +
" <xs:attribute name=\"Language\" type=\"xs:int\" use=\"required\" />{0}" +
" </xs:extension>{0}" +
" </xs:simpleContent>{0}" +
" </xs:complexType>{0}" +
"</xs:schema>", Environment.NewLine);
string schemaFragment2 = string.Format (CultureInfo.InvariantCulture,
"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
"<xs:schema xmlns:tns=\"NSStatus\" elementFormDefault=\"qualified\" targetNamespace=\"NSStatus\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
" <xs:simpleType name=\"StatusType\">{0}" +
" <xs:restriction base=\"xs:string\">{0}" +
" <xs:enumeration value=\"Untouched\" />{0}" +
" <xs:enumeration value=\"Touched\" />{0}" +
" <xs:enumeration value=\"Complete\" />{0}" +
" <xs:enumeration value=\"None\" />{0}" +
" </xs:restriction>{0}" +
" </xs:simpleType>{0}" +
"</xs:schema>", Environment.NewLine);
XmlSchema schema1 = XmlSchema.Read (new StringReader (schemaFragment1), null);
XmlSchema schema2 = XmlSchema.Read (new StringReader (schemaFragment2), null);
XmlSchemaCollection schemas = new XmlSchemaCollection ();
schemas.Add (schema2);
schemas.Add (schema1);
Assert.IsTrue (schema1.IsCompiled, "#1");
Assert.IsTrue (schema2.IsCompiled, "#2");
}
}
}

View File

@@ -0,0 +1,464 @@
//
// System.Xml.XmlSchemaDatatypeTests.cs
//
// Author:
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
// Wojciech Kotlarski <wojciech.kotlarski@7digital.com>
// Andres G. Aragoneses <andres.aragoneses@7digital.com>
//
// (C) 2002 Atsushi Enomoto
// (C) 2012 7digital Media Ltd.
//
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Collections.Generic;
using NUnit.Framework;
using QName = System.Xml.XmlQualifiedName;
using SimpleType = System.Xml.Schema.XmlSchemaSimpleType;
using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction;
using AssertType = NUnit.Framework.Assert;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaDatatypeTests
{
private XmlSchema GetSchema (string path)
{
return XmlSchema.Read (new XmlTextReader (path), null);
}
private XmlQualifiedName QName (string name, string ns)
{
return new XmlQualifiedName (name, ns);
}
private void AssertDatatype (XmlSchema schema, int index,
XmlTokenizedType tokenizedType, Type type, string rawValue, object parsedValue)
{
XmlSchemaElement element = schema.Items [index] as XmlSchemaElement;
XmlSchemaDatatype dataType = element.ElementType as XmlSchemaDatatype;
Assert.AreEqual (tokenizedType, dataType.TokenizedType, "#1");
Assert.AreEqual (type, dataType.ValueType, "#2");
Assert.AreEqual (parsedValue, dataType.ParseValue (rawValue, null, null), "#3");
}
[Test]
[Ignore ("The behavior has been inconsistent between versions, so it is not worthy of testing.")]
// Note that it could also apply to BaseTypeName (since if
// it is xs:anyType and BaseType is empty, BaseTypeName
// should be xs:anyType).
public void TestAnyType ()
{
XmlSchema schema = GetSchema ("Test/XmlFiles/xsd/datatypesTest.xsd");
schema.Compile (null);
XmlSchemaElement any = schema.Elements [QName ("e00", "urn:bar")] as XmlSchemaElement;
XmlSchemaComplexType cType = any.ElementType as XmlSchemaComplexType;
Assert.AreEqual (typeof (XmlSchemaComplexType), cType.GetType (), "#1");
Assert.IsNotNull (cType, "#2");
Assert.AreEqual (XmlQualifiedName.Empty, cType.QualifiedName, "#3");
Assert.IsNull (cType.BaseSchemaType, "#4"); // In MS.NET 2.0 its null. In 1.1 it is not null.
Assert.IsNotNull (cType.ContentTypeParticle, "#5");
}
[Test]
public void TestAll ()
{
XmlSchema schema = GetSchema ("Test/XmlFiles/xsd/datatypesTest.xsd");
schema.Compile (null);
AssertDatatype (schema, 1, XmlTokenizedType.CDATA, typeof (string), " f o o ", " f o o ");
AssertDatatype (schema, 2, XmlTokenizedType.CDATA, typeof (string), " f o o ", " f o o ");
// token shouldn't allow " f o o "
AssertDatatype (schema, 3, XmlTokenizedType.CDATA, typeof (string), "f o o", "f o o");
// language seems to be checked strictly
AssertDatatype (schema, 4, XmlTokenizedType.CDATA, typeof (string), "x-foo", "x-foo");
// NMTOKEN shouldn't allow " f o o "
// AssertDatatype (schema, 5, XmlTokenizedType.NMTOKEN, typeof (string), "foo", "foo");
// AssertDatatype (schema, 6, XmlTokenizedType.NMTOKEN, typeof (string []), "f o o", new string [] {"f", "o", "o"});
}
[Test]
public void AnyUriRelativePath ()
{
XmlValidatingReader vr = new XmlValidatingReader (
new XmlTextReader (
// relative path value that contains ':' should be still valid.
"<root>../copy/myserver/</root>",
XmlNodeType.Document, null));
vr.Schemas.Add (XmlSchema.Read (
new XmlTextReader ("<xs:schema xmlns:xs='"
+ XmlSchema.Namespace +
"'><xs:element name='root' type='xs:anyURI' /></xs:schema>",
XmlNodeType.Document, null), null));
vr.Read ();
vr.Read ();
vr.Read ();
}
[Test]
#if !NET_2_0
[Category ("NotDotNet")]
#endif
public void AnyUriRelativePathContainsColon ()
{
XmlValidatingReader vr = new XmlValidatingReader (
new XmlTextReader (
// relative path value that contains ':' should be still valid.
"<root>../copy/myserver/c:/foo</root>",
XmlNodeType.Document, null));
vr.Schemas.Add (XmlSchema.Read (
new XmlTextReader ("<xs:schema xmlns:xs='"
+ XmlSchema.Namespace +
"'><xs:element name='root' type='xs:anyURI' /></xs:schema>",
XmlNodeType.Document, null), null));
vr.Read ();
vr.Read ();
vr.Read ();
}
string [] allTypes = new string [] {
"string", "boolean", "float", "double", "decimal",
"duration", "dateTime", "time", "date", "gYearMonth",
"gYear", "gMonthDay", "gDay", "gMonth", "hexBinary",
"base64Binary", "anyURI", "QName", "NOTATION",
"normalizedString", "token", "language", "IDREFS",
"ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName",
"ID", "IDREF", "ENTITY", "integer",
"nonPositiveInteger", "negativeInteger", "long",
"int", "short", "byte", "nonNegativeInteger",
"unsignedLong", "unsignedInt", "unsignedShort",
"unsignedByte", "positiveInteger"
};
XmlSchemaSet allWrappers;
void SetupSimpleTypeWrappers ()
{
XmlSchema schema = new XmlSchema ();
List<QName> qnames = new List<QName> ();
foreach (string name in allTypes) {
SimpleType st = new SimpleType ();
st.Name = "x-" + name;
SimpleRest r = new SimpleRest ();
st.Content = r;
QName qname = new QName (name, XmlSchema.Namespace);
r.BaseTypeName = qname;
qnames.Add (qname);
schema.Items.Add (st);
}
XmlSchemaSet sset = new XmlSchemaSet ();
sset.Add (schema);
sset.Compile ();
allWrappers = sset;
}
XmlSchemaDatatype GetDatatype (string name)
{
return (allWrappers.GlobalTypes [new QName ("x-" + name,
String.Empty)] as SimpleType).Datatype;
}
string [] GetDerived (string target)
{
XmlSchemaDatatype strType = GetDatatype (target);
List<string> results = new List<string> ();
foreach (string name in allTypes) {
if (name == target)
continue;
XmlSchemaDatatype deriv = GetDatatype (name);
if (deriv.IsDerivedFrom (strType))
results.Add (name);
else Console.Error.WriteLine (deriv.GetType () + " is not derived from " + strType.GetType ());
}
return results.ToArray ();
}
[Test]
public void IsDerivedFrom ()
{
SetupSimpleTypeWrappers ();
// Funky, but XmlSchemaDatatype.IsDerivedFrom() is
// documented to always return false, but actually
// matches the same type - which could be guessed that
// this method is used only to detect user-defined
// simpleType derivation.
foreach (string b in allTypes)
foreach (string d in allTypes)
AssertType.AreEqual (b == d, GetDatatype (d).IsDerivedFrom (GetDatatype (b)), b);
AssertType.IsFalse (GetDatatype ("string").IsDerivedFrom (null), "null arg");
}
[Test]
public void ChangeType_StringTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.String, datatype.TypeCode);
Assert.AreEqual (typeof(string), datatype.ValueType);
Assert.AreEqual ("test", datatype.ChangeType("test", typeof(string)));
}
[Test]
public void ChangeType_StringToObjectTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.String, datatype.TypeCode);
Assert.AreEqual (typeof(string), datatype.ValueType);
Assert.AreEqual ("test", datatype.ChangeType("test", typeof(object)));
}
[Test]
public void ChangeType_IntegerTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Integer).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.Integer, datatype.TypeCode);
Assert.AreEqual (typeof(decimal), datatype.ValueType);
Assert.AreEqual (300, datatype.ChangeType("300", typeof(int)));
}
[Test]
public void ChangeType_FromDateTimeTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.DateTime, datatype.TypeCode);
Assert.AreEqual (typeof(DateTime), datatype.ValueType);
DateTime date = new DateTime (2012, 06, 27, 0, 0, 0, DateTimeKind.Utc);
Assert.AreEqual ("2012-06-27T00:00:00Z", datatype.ChangeType(date, typeof(string)));
}
[Test]
public void ChangeType_FromTimeSpanTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DayTimeDuration).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.DayTimeDuration, datatype.TypeCode);
Assert.AreEqual (typeof(TimeSpan), datatype.ValueType);
TimeSpan span = new TimeSpan(1, 2, 3);
Assert.AreEqual ("PT1H2M3S", datatype.ChangeType(span, typeof(string)));
}
[Test]
public void ChangeType_ToDateTimeTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.DateTime, datatype.TypeCode);
Assert.AreEqual (typeof(DateTime), datatype.ValueType);
DateTime date = new DateTime (2012, 06, 27, 0, 0, 0, DateTimeKind.Utc);
Assert.AreEqual (date, datatype.ChangeType("2012-06-27T00:00:00Z", typeof(DateTime)));
}
[Test]
public void ChangeType_ToTimeSpanTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DayTimeDuration).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.DayTimeDuration, datatype.TypeCode);
Assert.AreEqual (typeof(TimeSpan), datatype.ValueType);
TimeSpan span = new TimeSpan(1, 2, 3);
Assert.AreEqual (span, datatype.ChangeType("PT1H2M3S", typeof(TimeSpan)));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ChangeType_NullValueArgumentInFromStringTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Integer).Datatype;
datatype.ChangeType(null, typeof(string));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ChangeType_NullValueArgumentInToStringTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Integer).Datatype;
datatype.ChangeType(null, typeof(int));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ChangeType_NullTargetArgumentInFromStringTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Integer).Datatype;
datatype.ChangeType("100", null);
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ChangeType_NullNamespaceResolverArgumentInFromStringTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Integer).Datatype;
datatype.ChangeType("100", typeof(string), null);
}
[Test]
[Category("NotWorking")]
[ExpectedException (typeof(InvalidCastException))]
public void InvalidCastExceptionTest()
{
XmlSchemaDatatype datatype = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.DateTime).Datatype;
Assert.IsTrue (datatype != null);
Assert.AreEqual (XmlTypeCode.DateTime, datatype.TypeCode);
Assert.AreEqual (typeof(DateTime), datatype.ValueType);
datatype.ChangeType(300, typeof (int));
}
[Test]
public void Bug12469 ()
{
Dictionary<string, string> validValues = new Dictionary<string, string> {
{"string", "abc"},
{"normalizedString", "abc"},
{"token", "abc"},
{"language", "en"},
{"Name", "abc"},
{"NCName", "abc"},
{"ID", "abc"},
{"ENTITY", "abc"},
{"NMTOKEN", "abc"},
{"boolean", "true"},
{"decimal", "1"},
{"integer", "1"},
{"nonPositiveInteger", "0"},
{"negativeInteger", "-1"},
{"long", "9223372036854775807"},
{"int", "2147483647"},
{"short", "32767"},
{"byte", "127"},
{"nonNegativeInteger", "0"},
{"unsignedLong", "18446744073709551615"},
{"unsignedInt", "4294967295"},
{"unsignedShort", "65535"},
{"unsignedByte", "255"},
{"positiveInteger", "1"},
{"float", "1.1"},
{"double", "1.1"},
{"time", "00:00:00"},
{"date", "1999-12-31"},
{"dateTime", "1999-12-31T00:00:00.000"},
{"duration", "P1Y2M3DT10H30M"},
{"gYearMonth", "1999-01"},
{"gYear", "1999"},
{"gMonthDay", "--12-31"},
{"gMonth", "--12"},
{"gDay", "---31"},
{"base64Binary", "AbCd eFgH IjKl 019+"},
{"hexBinary", "0123456789ABCDEF"},
{"anyURI", "https://www.server.com"},
{"QName", "xml:abc"},
};
// FIXME: implement validation
Dictionary<string, string> invalidValues = new Dictionary<string, string> {
{"Name", "***"},
{"NCName", "a::"},
{"ID", "123"},
{"ENTITY", "***"},
{"NMTOKEN", "***"},
{"boolean", "ABC"},
{"decimal", "1A"},
{"integer", "1.5"},
{"nonPositiveInteger", "5"},
{"negativeInteger", "10"},
{"long", "999999999999999999999999999999999999999"},
{"int", "999999999999999999999999999999999999999"},
{"short", "32768"},
{"byte", "128"},
{"nonNegativeInteger", "-1"},
{"unsignedLong", "-1"},
{"unsignedInt", "-1"},
{"unsignedShort", "-1"},
{"unsignedByte", "-1"},
{"positiveInteger", "0"},
{"float", "1.1x"},
{"double", "1.1x"},
{"time", "0"},
{"date", "1"},
{"dateTime", "2"},
{"duration", "P1"},
{"gYearMonth", "1999"},
{"gYear", "-1"},
{"gMonthDay", "-12-31"},
{"gMonth", "-12"},
{"gDay", "--31"},
{"base64Binary", "####"},
{"hexBinary", "G"},
// anyURI passes everything (as long as I observed)
{"QName", "::"},
};
const string schemaTemplate = @"
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified'>
<xs:element name='EL'>
<xs:complexType>
<xs:attribute name='attr' type='xs:{0}' use='required' />
</xs:complexType>
</xs:element>
</xs:schema>";
const string documentTemplate = @"<EL attr='{0}' />";
foreach (var type in validValues.Keys) {
try {
var schema = string.Format (schemaTemplate, type);
var document = string.Format (documentTemplate, validValues[type]);
var schemaSet = new XmlSchemaSet ();
using (var reader = new StringReader (schema))
schemaSet.Add (XmlSchema.Read (reader, null));
schemaSet.Compile ();
var doc = new XmlDocument ();
using (var reader = new StringReader (document))
doc.Load (reader);
doc.Schemas = schemaSet;
doc.Validate (null);
// FIXME: implement validation
/*
if (!invalidValues.ContainsKey (type))
continue;
try {
doc = new XmlDocument ();
document = string.Format (documentTemplate, invalidValues [type]);
using (var reader = new StringReader (document))
doc.Load (reader);
doc.Schemas = schemaSet;
doc.Validate (null);
Assert.Fail (string.Format ("Failed to invalidate {0} for {1}", document, type));
} catch (XmlSchemaException) {
}
*/
} catch (Exception) {
Console.Error.WriteLine (type);
throw;
}
}
}
}
}

View File

@@ -0,0 +1,85 @@
//
// XmlSchemaExceptionCas.cs
// - CAS unit tests for System.Xml.Schema.XmlSchemaException
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Xml.Schema;
namespace MonoCasTests.System.Xml.Schema {
[TestFixture]
[Category ("CAS")]
public class XmlSchemaExceptionCas {
[SetUp]
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[ExpectedException (typeof (SecurityException))]
[SecurityPermission (SecurityAction.Deny, SerializationFormatter = true)]
public void DenySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XmlSchemaException xe = new XmlSchemaException (String.Empty, null);
xe.GetObjectData (null, sc);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
[SecurityPermission (SecurityAction.PermitOnly, SerializationFormatter = true)]
public void PermitOnlySerializationFormatter_GetObjectData ()
{
StreamingContext sc = new StreamingContext (StreamingContextStates.All);
XmlSchemaException xe = new XmlSchemaException (String.Empty, null);
xe.GetObjectData (null, sc);
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void DenyUnrestricted ()
{
// can we call everything without a SecurityException ?
XmlSchemaException xe = new XmlSchemaException (String.Empty, null);
Assert.AreEqual (0, xe.LineNumber, "LineNumber");
Assert.AreEqual (0, xe.LinePosition, "LinePosition");
Assert.IsNotNull (xe.Message, "Message");
Assert.IsNull (xe.SourceSchemaObject, "SourceSchemaObject");
Assert.IsNull (xe.SourceUri, "SourceUri");
}
}
}

View File

@@ -0,0 +1,27 @@
// Copyright (c) 2014 SIL International
// This software is licensed under the MIT License (http://opensource.org/licenses/MIT)
//
// Unit tests for XmlSchemaException
//
// Author:
// Eberhard Beilharz <eb1@sil.org>
//
using System;
using System.Xml.Schema;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaExceptionTests
{
[Test]
public void Bug599689_ToStringMatchesDotNet ()
{
Assert.AreEqual ("System.Xml.Schema.XmlSchemaException: Test",
new XmlSchemaException ("Test").ToString (),
"Novell bug #599689 (https://bugzilla.novell.com/show_bug.cgi?id=599689) not fixed.");
}
}
}

View File

@@ -0,0 +1,85 @@
//
// Tests for the length facets.
//
// Author:
// David Sheldon <dave-mono@earth.li>
//
//
using System;
using System.Xml;
using System.Xml.Schema;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaLengthFacetTests
{
[Test]
public void TestValidCombinations () {
CreateSimpletypeLength("5","-","-", true);
CreateSimpletypeLength("5","1","-", false);
CreateSimpletypeLength("5","-","1", false);
CreateSimpletypeLength("-","1","10", true);
CreateSimpletypeLength("-","10","1", false);
CreateSimpletypeLength("-","1","-", true);
CreateSimpletypeLength("-","-","1", true);
CreateSimpletypeLength("-5","-","-", false);
CreateSimpletypeLength("-","-1","-", false);
CreateSimpletypeLength("-","-","-1", false);
CreateSimpletypeLength("5.4","-","-", false);
CreateSimpletypeLength("-","1.0","-", false);
CreateSimpletypeLength("-","-","1.3", false);
CreateSimpletypeLength("+5","-","-", true);
CreateSimpletypeLength("-","+1","-", true);
CreateSimpletypeLength("-","-","+1", true);
}
private void CreateSimpletypeLength(string length, string minLength, string maxLength, bool expected) {
passed = true;
XmlSchema schema = new XmlSchema();
XmlSchemaSimpleType testType = new XmlSchemaSimpleType();
testType.Name = "TestType";
XmlSchemaSimpleTypeRestriction testTypeRestriction = new XmlSchemaSimpleTypeRestriction();
testTypeRestriction.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
if (length != "-") {
XmlSchemaLengthFacet _length = new XmlSchemaLengthFacet();
_length.Value = length;
testTypeRestriction.Facets.Add(_length);
}
if (minLength != "-") {
XmlSchemaMinLengthFacet _minLength = new XmlSchemaMinLengthFacet();
_minLength.Value = minLength;
testTypeRestriction.Facets.Add(_minLength);
}
if (maxLength != "-") {
XmlSchemaMaxLengthFacet _maxLength = new XmlSchemaMaxLengthFacet();
_maxLength.Value = maxLength;
testTypeRestriction.Facets.Add(_maxLength);
}
testType.Content = testTypeRestriction;
schema.Items.Add(testType);
schema.Compile(new ValidationEventHandler(ValidationCallbackOne));
Assert.IsTrue (expected == passed, (passed ? "Test passed, should have failed" : "Test failed, should have passed") + ": " + length + " " + minLength + " " + maxLength);
}
bool passed = true;
private void ValidationCallbackOne(object sender, ValidationEventArgs args) {
passed = false;
}
}
}

View File

@@ -0,0 +1,319 @@
//
// System.Xml.XmlSchemaSetTests.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2004 Novell Inc.
//
#if NET_2_0
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaSetTests
{
[Test]
public void Add ()
{
XmlSchemaSet ss = new XmlSchemaSet ();
XmlDocument doc = new XmlDocument ();
doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
ss.Add (null, new XmlNodeReader (doc)); // null targetNamespace
ss.Compile ();
// same document, different targetNamespace
ss.Add ("ab", new XmlNodeReader (doc));
// Add(null, xmlReader) -> targetNamespace in the schema
doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo' />");
ss.Add (null, new XmlNodeReader (doc));
Assert.AreEqual (3, ss.Count);
bool chameleon = false;
bool ab = false;
bool urnfoo = false;
foreach (XmlSchema schema in ss.Schemas ()) {
if (schema.TargetNamespace == null)
chameleon = true;
else if (schema.TargetNamespace == "ab")
ab = true;
else if (schema.TargetNamespace == "urn:foo")
urnfoo = true;
}
Assert.IsTrue (chameleon, "chameleon schema missing");
Assert.IsTrue (ab, "target-remapped schema missing");
Assert.IsTrue (urnfoo, "target specified in the schema ignored");
}
[Test]
[ExpectedException (typeof (XmlSchemaException))]
public void AddWrongTargetNamespace ()
{
string xsd = @"<xs:schema targetNamespace='urn:foo' xmlns:xs='http://www.w3.org/2001/XMLSchema'><xs:element name='el' type='xs:int' /></xs:schema>";
string xml = "<el xmlns='urn:foo'>a</el>";
XmlSchemaSet xss = new XmlSchemaSet ();
// unlike null, "" is regarded as an explicit
// empty namespace indication.
xss.Add ("", new XmlTextReader (new StringReader (xsd)));
}
[Test]
public void AddSchemaThenReader ()
{
XmlSchemaSet ss = new XmlSchemaSet ();
XmlDocument doc = new XmlDocument ();
doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
XmlSchema xs = new XmlSchema ();
xs.TargetNamespace = "ab";
ss.Add (xs);
ss.Add ("ab", new XmlNodeReader (doc));
}
[Test]
[Category ("NotWorking")] // How can we differentiate this
// case and the testcase above?
[ExpectedException (typeof (ArgumentException))]
public void AddReaderTwice ()
{
XmlSchemaSet ss = new XmlSchemaSet ();
XmlDocument doc = new XmlDocument ();
doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' />");
ss.Add ("ab", new XmlNodeReader (doc));
ss.Add ("ab", new XmlNodeReader (doc));
}
[Test]
public void AddSchemaTwice ()
{
XmlSchemaSet ss = new XmlSchemaSet ();
XmlDocument doc = new XmlDocument ();
doc.LoadXml ("<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:ab' />");
ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null));
ss.Add (XmlSchema.Read (new XmlNodeReader (doc), null));
}
[Test]
public void CompilationSettings ()
{
Assert.IsNotNull (new XmlSchemaSet ().CompilationSettings);
new XmlSchemaSet ().CompilationSettings = null;
}
[Test]
public void DisableUpaCheck ()
{
string schema = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:complexType name='Foo'>
<xs:sequence>
<xs:choice minOccurs='0'>
<xs:element name='el'/>
</xs:choice>
<xs:element name='el' />
</xs:sequence>
</xs:complexType>
</xs:schema>";
XmlSchema xs = XmlSchema.Read (new XmlTextReader (
schema, XmlNodeType.Document, null), null);
XmlSchemaSet xss = new XmlSchemaSet ();
xss.Add (xs);
xss.CompilationSettings.EnableUpaCheck = false;
xss.Compile ();
}
[Test]
public void AddRollbackIsCompiled ()
{
XmlSchemaSet ss = new XmlSchemaSet ();
ss.Add (new XmlSchema ());
ss.Compile ();
Assert.IsTrue (ss.IsCompiled, "#1");
XmlSchema sc = new XmlSchema (); // compiled one
sc.Compile (null);
ss.Add (sc);
Assert.IsFalse (ss.IsCompiled, "#2");
ss.Add (new XmlSchema ()); // not-compiled one
Assert.IsFalse (ss.IsCompiled, "#3");
XmlSchema s;
s = new XmlSchema ();
s.TargetNamespace = "urn:foo";
XmlSchemaElement el;
el = new XmlSchemaElement ();
el.Name = "root";
s.Items.Add (el);
ss.Add (s);
s = new XmlSchema ();
s.TargetNamespace = "urn:foo";
el = new XmlSchemaElement ();
el.Name = "foo";
s.Items.Add (el);
ss.Add (s);
ss.Compile ();
Assert.IsTrue (ss.IsCompiled, "#4");
ss.RemoveRecursive (s);
Assert.IsTrue (ss.IsCompiled, "#5");
}
[Test] // bug #77489
public void CrossSchemaReferences ()
{
string schema1 = @"<xsd:schema id=""Base.Schema"" elementFormDefault=""qualified"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<xsd:complexType name=""itemBase"" abstract=""true"">
<xsd:attribute name=""id"" type=""xsd:string""
use=""required""/>
<xsd:attribute name=""type"" type=""xsd:string""
use=""required""/>
</xsd:complexType>
</xsd:schema>";
string schema2 = @"<xsd:schema id=""Sub.Schema"" elementFormDefault=""qualified"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<xsd:complexType name=""item"">
<xsd:complexContent>
<xsd:extension base=""itemBase"">
<xsd:attribute name=""itemName""
type=""xsd:string"" use=""required""/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>";
XmlSchemaSet schemas = new XmlSchemaSet ();
schemas.Add (XmlSchema.Read (new StringReader (schema1), null));
schemas.Add (XmlSchema.Read (new StringReader (schema2), null));
schemas.Compile ();
}
[Test]
public void ImportSubstitutionGroupDBR ()
{
// This bug happened when
// 1) a schema imports another schema,
// 2) there is a substitutionGroup which is involved in
// complexContent schema conformance check, and
// 3) the included schema is already added to XmlSchemaSet.
XmlSchemaSet xss = new XmlSchemaSet ();
xss.Add (null, "Test/XmlFiles/xsd/import-subst-dbr-base.xsd");
xss.Add (null, "Test/XmlFiles/xsd/import-subst-dbr-ext.xsd");
// should not result in lack of substitutionGroup
// (and conformance error as its result)
xss.Compile ();
}
[Test]
public void AddWithNullTargetNS () // bug #571650
{
var xsdraw = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'><xs:element name='foo' /></xs:schema>";
var schemas = new XmlSchemaSet ();
var xsd = schemas.Add ("", XmlReader.Create (new StringReader (xsdraw)));
Assert.IsNull (xsd.TargetNamespace, "#1");
}
[Test] // part of bug #670945
public void TwoSchemasInSameDocumentUri ()
{
string xsd1 = @"
<xs:schema
targetNamespace='http://www.onvif.org/ver10/schema'
elementFormDefault='qualified'
xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:tt='http://www.onvif.org/ver10/schema'>
<xs:complexType name='SystemDateTime'>
<xs:sequence>
<xs:element name='foobar' type='xs:string' minOccurs='0' />
<xs:element name='Extension' type='tt:SystemDateTimeExtension' minOccurs='0'/>
</xs:sequence>
<!-- xs:anyAttribute processContents='lax'/ -->
</xs:complexType>
<xs:complexType name='SystemDateTimeExtension'>
<xs:sequence>
<xs:any namespace='##any' processContents='lax' minOccurs='0' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:schema>";
string xsd2 = @"
<xs:schema
targetNamespace='http://www.onvif.org/ver10/device/wsdl'
xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:tt='http://www.onvif.org/ver10/schema'
xmlns:tds='http://www.onvif.org/ver10/device/wsdl'
elementFormDefault='qualified'>
<xs:element name='GetSystemDateAndTime'>
<xs:complexType>
<xs:sequence/>
</xs:complexType>
</xs:element>
<xs:element name='GetSystemDateAndTimeResponse'>
<xs:complexType>
<xs:sequence>
<xs:element name='SystemDateAndTime' type='tt:SystemDateTime' />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>";
var xss = new XmlSchemaSet ();
var xs1 = XmlSchema.Read (new StringReader (xsd1), null);
xs1.SourceUri = "http://localhost:8080/dummy.wsdl";
xs1.LineNumber = 5;
xss.Add (xs1);
var xs2 = XmlSchema.Read (new StringReader (xsd2), null);
xs2.SourceUri = "http://localhost:8080/dummy.wsdl";
xs2.LineNumber = 50;
xss.Add (xs2);
xss.Compile ();
Assert.IsNotNull (xss.GlobalElements [new XmlQualifiedName ("GetSystemDateAndTimeResponse", "http://www.onvif.org/ver10/device/wsdl")], "#1");
}
[Test] // bug #13716
public void ResolveSchemaUriUsingXmlResolver ()
{
var resolver = new Bug13716XmlResolver ();
string xml = "<people xmlns='testschema'><person name='Ian'><books><book>Clean Code</book></books></person></people>";
string ns = "testschema";
string xsdPath = "my.xsd";
var readerSettings = new XmlReaderSettings ();
//readerSettings.XmlResolver = resolver;
readerSettings.Schemas.XmlResolver = resolver;
readerSettings.Schemas.Add (ns, xsdPath);
readerSettings.ValidationType = ValidationType.Schema;
using (var xr = XmlReader.Create (new StringReader (xml), readerSettings))
{
while (!xr.EOF)
xr.Read ();
}
}
public class Bug13716XmlResolver : XmlUrlResolver
{
public override object GetEntity(Uri absoluteUri, string role, Type typeOfObjectToReturn)
{
string xsd = @"
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='testschema'>
<xs:element name='people' />
</xs:schema>";
return new MemoryStream (Encoding.UTF8.GetBytes (xsd));
}
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
//
// System.Xml.XmlSchemaSetTests.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2004 Novell Inc.
//
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using NUnit.Framework;
using QName = System.Xml.XmlQualifiedName;
using SimpleType = System.Xml.Schema.XmlSchemaSimpleType;
using SimpleRest = System.Xml.Schema.XmlSchemaSimpleTypeRestriction;
using AssertType = NUnit.Framework.Assert;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaTypeTests
{
#if NET_2_0
string [] all_types = new string [] {
"string", "boolean", "float", "double", "decimal",
"duration", "dateTime", "time", "date", "gYearMonth",
"gYear", "gMonthDay", "gDay", "gMonth", "hexBinary",
"base64Binary", "anyURI", "QName", "NOTATION",
"normalizedString", "token", "language", "IDREFS",
"ENTITIES", "NMTOKEN", "NMTOKENS", "Name", "NCName",
"ID", "IDREF", "ENTITY", "integer",
"nonPositiveInteger", "negativeInteger", "long",
"int", "short", "byte", "nonNegativeInteger",
"unsignedLong", "unsignedInt", "unsignedShort",
"unsignedByte", "positiveInteger"
};
XmlTypeCode [] type_codes = new XmlTypeCode [] {
XmlTypeCode.String,
XmlTypeCode.Boolean,
XmlTypeCode.Float,
XmlTypeCode.Double,
XmlTypeCode.Decimal,
XmlTypeCode.Duration,
XmlTypeCode.DateTime,
XmlTypeCode.Time,
XmlTypeCode.Date,
XmlTypeCode.GYearMonth,
XmlTypeCode.GYear,
XmlTypeCode.GMonthDay,
XmlTypeCode.GDay,
XmlTypeCode.GMonth,
XmlTypeCode.HexBinary,
XmlTypeCode.Base64Binary,
XmlTypeCode.AnyUri,
XmlTypeCode.QName,
XmlTypeCode.Notation,
XmlTypeCode.NormalizedString,
XmlTypeCode.Token,
XmlTypeCode.Language,
XmlTypeCode.Idref, // IDREFS (LAMESPEC)
XmlTypeCode.Entity, // ENTITIES (LAMESPEC)
XmlTypeCode.NmToken,
XmlTypeCode.NmToken, // NMTOKENS (LAMESPEC)
XmlTypeCode.Name,
XmlTypeCode.NCName,
XmlTypeCode.Id,
XmlTypeCode.Idref,
XmlTypeCode.Entity,
XmlTypeCode.Integer,
XmlTypeCode.NonPositiveInteger,
XmlTypeCode.NegativeInteger,
XmlTypeCode.Long,
XmlTypeCode.Int,
XmlTypeCode.Short,
XmlTypeCode.Byte,
XmlTypeCode.NonNegativeInteger,
XmlTypeCode.UnsignedLong,
XmlTypeCode.UnsignedInt,
XmlTypeCode.UnsignedShort,
XmlTypeCode.UnsignedByte,
XmlTypeCode.PositiveInteger};
[Test]
public void TypeCode ()
{
for (int i = 0; i < all_types.Length; i++) {
string name = all_types [i];
QName qname = new QName (name, XmlSchema.Namespace);
Assert.AreEqual (type_codes [i],
XmlSchemaType.GetBuiltInSimpleType (qname).TypeCode, name);
}
}
#endif
}
}

View File

@@ -0,0 +1,457 @@
//
// XmlSchemaValidatorTests.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2008 Novell Inc.
//
#if NET_2_0
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlSchemaValidatorTests
{
void Validate (string xml, string xsd)
{
XmlSchema schema = XmlSchema.Read (new StringReader (xsd), null);
XmlReaderSettings settings = new XmlReaderSettings ();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add (schema);
XmlReader reader = XmlReader.Create (new StringReader (xml), settings);
while (reader.Read ())
;
}
[Test]
public void XsdAnyToSkipAttributeValidation ()
{
// bug #358408
XmlSchemaSet schemas = new XmlSchemaSet ();
schemas.Add (null, "Test/XmlFiles/xsd/358408.xsd");
XmlSchemaValidator v = new XmlSchemaValidator (
new NameTable (),
schemas,
new XmlNamespaceManager (new NameTable ()),
XmlSchemaValidationFlags.ProcessIdentityConstraints);
v.Initialize ();
v.ValidateWhitespace (" ");
XmlSchemaInfo info = new XmlSchemaInfo ();
ArrayList list = new ArrayList ();
v.ValidateElement ("configuration", "", info, null, null, null, null);
v.GetUnspecifiedDefaultAttributes (list);
v.ValidateEndOfAttributes (info);
v.ValidateWhitespace (" ");
v.ValidateElement ("host", "", info, null, null, null, null);
v.ValidateAttribute ("auto-start", "", "true", info);
list.Clear ();
v.GetUnspecifiedDefaultAttributes (list);
v.ValidateEndOfAttributes (info);
v.ValidateEndElement (null);//info);
v.ValidateWhitespace (" ");
v.ValidateElement ("service-managers", "", info, null, null, null, null);
list.Clear ();
v.GetUnspecifiedDefaultAttributes (list);
v.ValidateEndOfAttributes (info);
v.ValidateWhitespace (" ");
v.ValidateElement ("service-manager", "", info, null, null, null, null);
list.Clear ();
v.GetUnspecifiedDefaultAttributes (list);
v.ValidateEndOfAttributes (info);
v.ValidateWhitespace (" ");
v.ValidateElement ("foo", "", info, null, null, null, null);
v.ValidateAttribute ("bar", "", "", info);
}
[Test]
public void SkipInvolved () // bug #422581
{
XmlReader schemaReader = XmlReader.Create ("Test/XmlFiles/xsd/422581.xsd");
XmlSchema schema = XmlSchema.Read (schemaReader, null);
XmlReaderSettings settings = new XmlReaderSettings ();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add (schema);
XmlReader reader = XmlReader.Create ("Test/XmlFiles/xsd/422581.xml", settings);
while (reader.Read ());
}
[Test]
public void Bug433774 ()
{
string xsd = @"<xs:schema targetNamespace='urn:foo' xmlns='urn:foo' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Root'>
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name='version' type='xs:string' fixed='3' />
</xs:complexType>
</xs:element>
</xs:schema>";
XmlDocument doc = new XmlDocument ();
doc.LoadXml ("<Root version='3' xmlns='urn:foo'/>");
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add (XmlSchema.Read (XmlReader.Create (new StringReader (xsd)), null));
doc.Schemas = schemaSet;
XmlNode root = doc.DocumentElement;
doc.Validate (null, root);
}
[Test]
[ExpectedException (typeof (XmlSchemaValidationException))]
public void Bug435206 ()
{
string xsd = @"<xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='myDoc'>
<xs:complexType>
<xs:attribute name='foo' type='xs:unsignedLong' use='required' />
<xs:attribute name='bar' type='xs:dateTime' use='required' />
</xs:complexType>
</xs:element>
</xs:schema>";
string xml = @"<myDoc foo='12' bar='January 1st 1900'/>";
Validate (xml, xsd);
}
[Test]
public void Bug469713 ()
{
string xsd = @"<xs:schema elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Message'>
<xs:complexType>
<xs:all>
<xs:element name='MyDateTime' nillable='true' type='xs:dateTime' />
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>";
string xml = @"<Message xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='test.xsd'>
<MyDateTime xsi:nil='true'></MyDateTime>
</Message>";
Validate (xml, xsd);
}
[Test]
public void Bug496192_496205 ()
{
using (var xmlr = new StreamReader ("Test/XmlFiles/496192.xml"))
using (var xsdr = new StreamReader ("Test/XmlFiles/496192.xsd"))
Validate (xmlr.ReadToEnd (), xsdr.ReadToEnd ());
}
[Test]
public void Bug501666 ()
{
string xsd = @"
<xs:schema id='Settings'
targetNamespace='foo'
xmlns='foo'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Settings' type='Settings'/>
<xs:complexType name='Settings'>
<xs:attribute name='port' type='PortNumber' use='required'/>
</xs:complexType>
<xs:simpleType name='PortNumber'>
<xs:restriction base='xs:positiveInteger'>
<xs:minInclusive value='1'/>
<xs:maxInclusive value='65535'/>
</xs:restriction>
</xs:simpleType>
</xs:schema>";
string xml = @"<Settings port='1337' xmlns='foo'/>";
XmlDocument doc = new XmlDocument ();
doc.LoadXml (xml);
doc.Schemas.Add (XmlSchema.Read (XmlReader.Create (new StringReader (xsd)), null));
doc.Validate (null);
}
public void Bug502251 ()
{
string xsd = @"
<xs:schema id='foo' targetNamespace='foo'
elementFormDefault='qualified'
xmlns='foo'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:group name='LayoutElementTypes'>
<xs:choice>
<xs:element name='Rows' type='Rows' />
<xs:element name='Conditional' type='Conditional' />
</xs:choice>
</xs:group>
<xs:complexType name='Element' abstract='true'>
<xs:attribute name='id' type='xs:ID' use='optional'/>
</xs:complexType>
<xs:complexType name='SingleChildElement' abstract='true'>
<xs:complexContent>
<xs:extension base='Element'>
<xs:group ref='LayoutElementTypes' minOccurs='1' maxOccurs='1' />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name='Rows'>
<xs:complexContent>
<xs:extension base='Element'>
<xs:sequence minOccurs='1' maxOccurs='unbounded'>
<xs:element name='Row' type='Row' />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name='Row'>
<xs:complexContent>
<xs:extension base='SingleChildElement'>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name='Conditional'>
<xs:complexContent>
<xs:extension base='Element'>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name='Layout'>
<xs:complexContent>
<xs:extension base='SingleChildElement'>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name='Layout' type='Layout' />
</xs:schema>";
XmlDocument doc = new XmlDocument ();
doc.LoadXml (@"<Layout xmlns='foo'>
<Rows>
<Row><Conditional/></Row>
</Rows>
</Layout>");
XmlSchema schema = XmlSchema.Read (XmlReader.Create (new StringReader (xsd)), null);
doc.Schemas.Add (schema);
doc.Validate (null);
}
[Test]
public void Bug557452 ()
{
string xsd = @"
<xs:schema id='Settings'
targetNamespace='foo'
xmlns='foo'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='Settings' type='Settings'/>
<xs:complexType name='Settings'>
<xs:attribute name='port' type='PortNumber' use='required'/>
</xs:complexType>
<xs:simpleType name='PortNumber'>
<xs:restriction base='xs:decimal'>
<xs:minInclusive value='1'/>
<xs:maxInclusive value='65535'/>
</xs:restriction>
</xs:simpleType>
</xs:schema>";
string xml = @"<Settings port='1337' xmlns='foo'/>";
XmlDocument doc = new XmlDocument ();
doc.LoadXml (xml);
doc.Schemas.Add (XmlSchema.Read (XmlReader.Create (new StringReader (xsd)), null));
doc.Validate (null);
}
[Test]
public void Bug584664 ()
{
Validate (File.ReadAllText ("Test/XmlFiles/xsd/584664a.xml"), File.ReadAllText ("Test/XmlFiles/xsd/584664a.xsd"));
Validate (File.ReadAllText ("Test/XmlFiles/xsd/584664b.xml"), File.ReadAllText ("Test/XmlFiles/xsd/584664b.xsd"));
}
[Test]
public void MultipleMissingIds ()
{
var schema = XmlSchema.Read (new StringReader (@"<?xml version=""1.0"" encoding=""utf-8""?>
<xs:schema targetNamespace=""urn:multiple-ids"" elementFormDefault=""qualified"" xmlns=""urn:multiple-ids"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
<xs:element name=""root"">
<xs:complexType>
<xs:sequence minOccurs=""0"" maxOccurs=""unbounded"">
<xs:element name=""item"">
<xs:complexType>
<xs:attribute name=""id"" type=""xs:ID"" />
<xs:attribute name=""parent"" type=""xs:IDREF"" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>"), null);
var xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<root xmlns=""urn:multiple-ids"">
<item id=""id2"" parent=""id1"" />
<item id=""id3"" parent=""id1"" />
<item id=""id1"" parent=""id1"" />
</root>";
var document = new XmlDocument ();
document.LoadXml (xml);
document.Schemas = new XmlSchemaSet ();
document.Schemas.Add (schema);
document.Validate (null);
}
[Test]
public void FacetsOnBaseSimpleContentRestriction ()
{
XmlReaderSettings settings = new XmlReaderSettings ();
settings.Schemas.Add (null, "Test/XmlFiles/595947.xsd");
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Compile ();
Validate ("TEST 1.1", 1, "0123456789", "0123456789", settings, false);
Validate ("TEST 1.2", 1, "0123456789***", "0123456789", settings, true);
Validate ("TEST 1.3", 1, "0123456789", "0123456789***", settings, true);
Validate ("TEST 2.1", 2, "0123456789", "0123456789", settings, false);
Validate ("TEST 2.2", 2, "0123456789***", "0123456789", settings, true);
Validate ("TEST 2.3", 2, "0123456789", "0123456789***", settings, true);
Validate ("TEST 3.1", 3, "0123456789", "0123456789", settings, false);
Validate ("TEST 3.2", 3, "0123456789***", "0123456789", settings, true);
Validate ("TEST 3.3", 3, "0123456789", "0123456789***", settings, true);
}
void Validate (string testName, int testNumber, string idValue, string elementValue, XmlReaderSettings settings, bool shouldFail)
{
string content = string.Format ("<MyTest{0} Id=\"{1}\">{2}</MyTest{0}>", testNumber, idValue, elementValue);
try
{
XmlReader reader = XmlReader.Create (new StringReader (content), settings);
XmlDocument document = new XmlDocument ();
document.Load (reader);
document.Validate (null);
} catch (Exception e) {
if (!shouldFail)
throw;
return;
}
if (shouldFail)
Assert.Fail (testName + " should fail");
}
[Test]
public void Bug676993 ()
{
Validate (File.ReadAllText ("Test/XmlFiles/676993.xml"), File.ReadAllText ("Test/XmlFiles/676993.xsd"));
}
[Test]
public void Bug10245 ()
{
string xsd = @"
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo'>
<xs:element name='root'>
<xs:complexType>
<xs:attribute name='d' default='v' use='optional' />
</xs:complexType>
</xs:element>
</xs:schema>";
string xml = "<root xmlns='urn:foo' />";
var xrs = new XmlReaderSettings () { ValidationType = ValidationType.Schema };
xrs.Schemas.Add (XmlSchema.Read (new StringReader (xsd), null));
var xr = XmlReader.Create (new StringReader (xml), xrs);
xr.Read ();
bool more;
Assert.AreEqual (2, xr.AttributeCount, "#1");
int i = 0;
for (more = xr.MoveToFirstAttribute (); more; more = xr.MoveToNextAttribute ())
i++;
Assert.AreEqual (2, i, "#2");
}
[Test]
public void Bug12035 ()
{
string xml = @"<UserSettings
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns='http://schema/test'><Enabled>false</Enabled><Time xsi:nil='true' /></UserSettings>";
string xsd = @"<?xml version='1.0' encoding='utf-8'?>
<xs:schema
targetNamespace='http://schema/test'
xmlns='http://schema/test'
xmlns:xs='http://www.w3.org/2001/XMLSchema'
elementFormDefault='qualified'>
<xs:element name='UserSettings'>
<xs:complexType>
<xs:sequence>
<xs:element name='Enabled' type='xs:boolean' />
<xs:element name='Time' type='CoarseTime' nillable='true' />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name='CoarseTime'>
<xs:sequence>
<xs:element name='Hours' type='xs:int' />
</xs:sequence>
</xs:complexType>
</xs:schema>";
var schema = XmlSchema.Read (new StringReader (xsd), null);
var schemaSet = new XmlSchemaSet ();
schemaSet.Add (schema);
var xmlReaderSettings = new XmlReaderSettings { ValidationType = ValidationType.Schema };
xmlReaderSettings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
xmlReaderSettings.Schemas.Add (schemaSet);
using (var configStream = new StringReader (xml)) {
using (var validatingReader = XmlReader.Create (configStream, xmlReaderSettings)) {
// Read the XML, throwing an exception if a validation error occurs
while (validatingReader.Read()) {
}
}
}
}
[Test]
public void IgnoresInvalidBaseUri ()
{
var source = new StringReader (@"<?xml version='1.0' encoding='utf-8'?><Test></Test>");
var readerSettings = new XmlReaderSettings { ValidationType = ValidationType.Schema };
var reader = XmlReader.Create (source, readerSettings, "invalidBaseUri");
Assert.IsNotNull (reader);
}
}
}
#endif

View File

@@ -0,0 +1,4 @@
2006-11-01 Atsushi Enomoto <atsushi@ximian.com>
* SchemaImporterExtensionCollectionTests.cs,
SchemaImporterExtensionTests.cs : new testfixtures.

View File

@@ -0,0 +1,136 @@
//
// SchemaImporterExtensionCollectionTests.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !MOBILE
using System;
using System.CodeDom;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.Serialization.Advanced;
using NUnit.Framework;
namespace MonoTests.System.Xml.Serialization.Advanced
{
[TestFixture]
public class SchemaImporterExtensionCollectionTests
{
class MyExtension : SchemaImporterExtension
{
}
class MyExtension2 : SchemaImporterExtension
{
}
abstract class MyAbstractExtension : SchemaImporterExtension
{
}
[Test]
public void Add ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
Assert.AreEqual (0, c.Add ("foo", typeof (MyExtension)), "#1");
Assert.IsTrue (c [0] is MyExtension, "#2");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void AddNameNull ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Add (null, typeof (MyExtension));
}
[Test]
[Category ("NotDotNet")] // NRE happens there.
[ExpectedException (typeof (ArgumentNullException))]
public void AddTypeNull ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Add ("foo", null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void AddTypeNonExtension ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Add ("foo", typeof (int));
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void AddTypeAbstract ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Add ("foo", typeof (SchemaImporterExtension));
}
[Test]
public void AddTypeAbstract2 ()
{
try {
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Add ("foo", typeof (MyAbstractExtension));
Assert.Fail ("Abstract type should not be accepted.");
} catch (Exception) {
}
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void DuplicateNames ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Add ("foo", typeof (MyExtension));
c.Add ("foo", typeof (MyExtension2));
}
[Test]
public void RemoveNonExistent ()
{
SchemaImporterExtensionCollection c =
new SchemaImporterExtensionCollection ();
c.Remove ("foo");
}
}
}
#endif

View File

@@ -0,0 +1,75 @@
//
// SchemaImporterExtensionTests.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !MOBILE
using System;
using System.CodeDom;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.Serialization.Advanced;
using NUnit.Framework;
namespace MonoTests.System.Xml.Serialization.Advanced
{
[TestFixture]
public class SchemaImporterExtensionTests
{
class MyExtension : SchemaImporterExtension
{
}
[Test]
public void ImportAnyElement ()
{
Assert.IsNull(new MyExtension ().ImportAnyElement (
null, false, null, null, null, null, CodeGenerationOptions.None, null));
}
[Test]
public void ImportDefaultValue ()
{
Assert.IsNull (new MyExtension ().ImportDefaultValue (null, null), "#1");
Assert.IsNull (new MyExtension ().ImportDefaultValue ("test", "string"), "#2");
}
[Test]
public void ImportSchemaType ()
{
Assert.IsNull (new MyExtension ().ImportSchemaType (
null, null, null, null, null, null, CodeGenerationOptions.None, null), "#1");
Assert.IsNull (new MyExtension ().ImportSchemaType (
null, null, null, null, null, null, null, CodeGenerationOptions.None, null), "#2");
}
}
}
#endif

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More