Skip to content

Commit

Permalink
add NUnit3 xml-schemas for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
fflaten committed Jul 11, 2022
1 parent ec89c52 commit c677adc
Show file tree
Hide file tree
Showing 5 changed files with 440 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/schemas/NUnit3/Test.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>This is document is descriptive, rather than a guarantee of future decisions.</xs:documentation>
</xs:annotation>

<xs:include schemaLocation="TestDefinitions.xsd" />

<xs:element name="test-case" type="TestCaseElementType">
<xs:unique name="TestCaseUniqueId">
<xs:selector xpath=". | .//test-case | .//test-suite" />
<xs:field xpath="@id" />
</xs:unique>
</xs:element>

<xs:element name="test-suite" type="TestSuiteElementType">
<xs:unique name="TestSuiteUniqueId">
<xs:selector xpath=". | .//test-case | .//test-suite" />
<xs:field xpath="@id" />
</xs:unique>
</xs:element>

</xs:schema>
141 changes: 141 additions & 0 deletions src/schemas/NUnit3/TestDefinitions.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>This is document is descriptive, rather than a guarantee of future decisions.</xs:documentation>
</xs:annotation>

<!-- NUnit.Framework.Internal.Test.PopulateTestNode -->
<xs:group name="TestBaseElementGroup">
<xs:sequence>
<!-- NUnit.Framework.Internal.PropertyBag.AddToXml -->
<xs:element name="properties" minOccurs="0">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="property">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="value" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="TestBaseAttributeGroup">
<xs:attribute name="id" type="xs:string" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="fullname" type="xs:string" use="required" />
<xs:attribute name="methodname" type="xs:string" />
<xs:attribute name="classname" type="xs:string" />
<xs:attribute name="runstate" use="required" >
<xs:simpleType>
<!-- NUnit.Framework.Interfaces.RunState -->
<xs:restriction base="xs:string">
<xs:enumeration value="NotRunnable" />
<xs:enumeration value="Runnable" />
<xs:enumeration value="Explicit" />
<xs:enumeration value="Skipped" />
<xs:enumeration value="Ignored" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>

<!-- NUnit.Framework.Internal.TestMethod.AddToXml -->
<xs:complexType name="TestCaseElementType">
<xs:group ref="TestBaseElementGroup" />
<xs:attributeGroup ref="TestCaseAttributeGroup" />
</xs:complexType>
<xs:attributeGroup name="TestCaseAttributeGroup">
<xs:attributeGroup ref="TestBaseAttributeGroup" />
<xs:attribute name="seed" type="xs:string" use="required" />
</xs:attributeGroup>

<!-- NUnit.Framework.Internal.TestSuite.AddToXml -->
<xs:complexType name="TestSuiteElementType">
<xs:sequence>
<!-- NUnit.Framework.Api.FrameworkController.InsertEnvironmentElement -->
<xs:element name="environment" minOccurs="0">
<xs:complexType>
<xs:attribute name="framework-version" type="xs:string" use="required" />
<xs:attribute name="clr-version" type="xs:string" use="required" />
<xs:attribute name="os-version" type="xs:string" use="required" />
<xs:attribute name="platform" type="xs:string" />
<xs:attribute name="cwd" type="xs:string" use="required" />
<xs:attribute name="machine-name" type="xs:string" />
<xs:attribute name="user" type="xs:string" />
<xs:attribute name="user-domain" type="xs:string" />
<xs:attribute name="culture" type="xs:string" use="required" />
<xs:attribute name="uiculture" type="xs:string" use="required" />
<xs:attribute name="os-architecture" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<!-- NUnit.Framework.Api.FrameworkController.InsertSettingsElement -->
<xs:element name="settings" minOccurs="0">
<xs:complexType>
<xs:sequence>
<!-- NUnit.Framework.Api.FrameworkController.AddSetting -->
<xs:element name="setting" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<!-- NUnit.Framework.Api.FrameworkController.AddDictionaryEntries -->
<xs:element name="item" minOccurs="0" maxOccurs ="unbounded">
<xs:complexType>
<xs:attribute name="key" type="xs:string" use="required" />
<xs:attribute name="value" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="value" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group ref="TestBaseElementGroup" />
<xs:group ref="ContainedTestGroup" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attributeGroup ref="TestSuiteAttributeGroup" />
</xs:complexType>
<xs:attributeGroup name="TestSuiteAttributeGroup">
<xs:attributeGroup ref="TestBaseAttributeGroup" />
<xs:attribute name="type" use="required">
<xs:simpleType>
<!-- Implementations of NUnit.Framework.Internal.Test.TestType -->
<xs:restriction base="xs:string">
<!-- NUnit.Framework.Internal.ParameterizedFixtureSuite.TestType -->
<xs:enumeration value="GenericFixture" />
<xs:enumeration value="ParameterizedFixture" />
<!-- NUnit.Framework.Internal.ParameterizedMethodSuite.TestType -->
<xs:enumeration value="Theory" />
<xs:enumeration value="GenericMethod" />
<xs:enumeration value="ParameterizedMethod" />
<!-- NUnit.Framework.Internal.TestAssembly.TestType -->
<xs:enumeration value="Assembly" />
<!-- NUnit.Framework.Internal.Test.TestType -->
<xs:enumeration value="SetUpFixture" />
<xs:enumeration value="TestFixture" />
<xs:enumeration value="TestMethod" />
<xs:enumeration value="TestSuite" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="testcasecount" type="NonnegativeInt32" use="required" />
</xs:attributeGroup>

<xs:group name="ContainedTestGroup">
<xs:choice>
<xs:element name="test-suite" type="TestSuiteElementType" />
<xs:element name="test-case" type="TestCaseElementType" />
</xs:choice>
</xs:group>

<xs:simpleType name="NonnegativeInt32">
<xs:restriction base="xs:int">
<xs:minInclusive value="0" />
</xs:restriction>
</xs:simpleType>

</xs:schema>
11 changes: 11 additions & 0 deletions src/schemas/NUnit3/TestFilter.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>This is document is descriptive, rather than a guarantee of future decisions.</xs:documentation>
</xs:annotation>

<xs:include schemaLocation="TestFilterDefinitions.xsd" />

<xs:element name="filter" type="TestFilterType" />

</xs:schema>
78 changes: 78 additions & 0 deletions src/schemas/NUnit3/TestFilterDefinitions.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>This is document is descriptive, rather than a guarantee of future decisions.</xs:documentation>
</xs:annotation>

<!-- NUnit.Framework.Internal.TestFilter.EmptyFilter.AddToXml -->
<!-- NUnit.Framework.Internal.TestFilter.FromXML -->
<xs:complexType name="TestFilterType">
<xs:group ref="TestFilterElementGroup" minOccurs="0" maxOccurs="unbounded" />
</xs:complexType>

<xs:group name="TestFilterElementGroup">
<xs:choice>

<!-- NUnit.Framework.Internal.Filters.NotFilter.AddToXml -->
<xs:element name="not">
<xs:complexType>
<xs:group ref="TestFilterElementGroup" />
</xs:complexType>
</xs:element>

<!-- NUnit.Framework.Internal.Filters.AndFilter.ElementName -->
<xs:element name="and" type="CompositeFilterType" />

<!-- NUnit.Framework.Internal.Filters.OrFilter.ElementName -->
<xs:element name="or" type="CompositeFilterType" />

<!-- NUnit.Framework.Internal.Filters.CategoryFilter.ElementName -->
<xs:element name="cat" type="ValueMatchFilterType" />

<!-- NUnit.Framework.Internal.Filters.ClassNameFilter.ElementName -->
<xs:element name="class" type="ValueMatchFilterType" />

<!-- NUnit.Framework.Internal.Filters.FullNameFilter.ElementName -->
<xs:element name="test" type="ValueMatchFilterType" />

<!-- NUnit.Framework.Internal.Filters.IdFilter.ElementName -->
<xs:element name="id" type="ValueMatchFilterType" />

<!-- NUnit.Framework.Internal.Filters.MethodNameFilter.ElementName -->
<xs:element name="method" type="ValueMatchFilterType" />

<!-- NUnit.Framework.Internal.Filters.NamespaceFilter.ElementName -->
<xs:element name="namespace" type="ValueMatchFilterType" />

<!-- NUnit.Framework.Internal.Filters.TestNameFilter.AddToXml -->
<xs:element name="prop">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ValueMatchFilterType">
<xs:attribute name="name" type="xs:string" use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

<!-- NUnit.Framework.Internal.Filters.TestNameFilter.ElementName -->
<xs:element name="name" type="ValueMatchFilterType" />

</xs:choice>
</xs:group>

<!-- NUnit.Framework.Internal.Filters.CompositeFilter.AddToXml -->
<xs:complexType name="CompositeFilterType">
<xs:group ref="TestFilterElementGroup" minOccurs="0" maxOccurs="unbounded" />
</xs:complexType>

<!-- NUnit.Framework.Internal.Filters.ValueMatchFilter.AddToXml -->
<xs:complexType name="ValueMatchFilterType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="re" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>

</xs:schema>

0 comments on commit c677adc

Please sign in to comment.