예제 #1
0
        public void ReferenceTypes() // From IsReferenceTypes.cs
        {
            List <Type> types = new List <Type>()
            {
                typeof(ExporterTypesTests.Order_ContainsRef),
                typeof(ExporterTypesTests.Customers_ContainsDuplicateRefs),
                typeof(ExporterTypesTests.Student_ContainsDuplicateCollectionRefs),
                typeof(ExporterTypesTests.CircularLinkedList_ContainsBackpointingRef),
                typeof(ExporterTypesTests.RefCircularLinks_ContainsBackpointer),
                typeof(ExporterTypesTests.RefCircularNodeA_ContainsRefWithBackpointer),
                typeof(ExporterTypesTests.RefNestedNode_ContainsBackpointer),
                typeof(ExporterTypesTests.RefSimpleDataContractCycle_ContainsRefWithBackpointer),
                typeof(ExporterTypesTests.Fruit),
                typeof(ExporterTypesTests.RefApple),
                typeof(ExporterTypesTests.EdibleContainer_ContainsPolymorphicRefs),
            };

            XsdDataContractExporter exporter = new XsdDataContractExporter();
            ExportOptions           options  = new ExportOptions();

            options.KnownTypes.Add(typeof(ArrayList));
            options.KnownTypes.Add(typeof(Guid));

            exporter.Export(types);
            exporter.Export(types); // Run twice, to ensure that types are not re-exported

            string schemas = SchemaUtils.DumpSchema(exporter.Schemas);

            _output.WriteLine(schemas);
            _output.WriteLine($"----------------- {exporter.Schemas.Count}, {exporter.Schemas.GlobalElements.Count}, {exporter.Schemas.GlobalTypes.Count}");

            Assert.Equal(3, exporter.Schemas.Count);
            Assert.Equal(39, exporter.Schemas.GlobalElements.Count);
            Assert.Equal(21, exporter.Schemas.GlobalTypes.Count);

            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:ser=""http://schemas.microsoft.com/2003/10/Serialization/"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:import namespace=""http://schemas.microsoft.com/2003/10/Serialization/"" />", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Order_ContainsRef"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefCustomer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Customers_ContainsDuplicateRefs"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Student_ContainsDuplicateCollectionRefs"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefGrades"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.CircularLinkedList_ContainsBackpointingRef"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefNode"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefCircularLinks_ContainsBackpointer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefCircularNodeA_ContainsRefWithBackpointer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefCircularNodeB_ContainsRefWithBackpointer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefNestedNode_ContainsBackpointer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefSimpleDataContractCycle_ContainsRefWithBackpointer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefSimpleDataContractCycleNextLink"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Fruit"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefEdibleItem"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.RefApple"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.EdibleContainer_ContainsPolymorphicRefs"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref schemas);
        }
예제 #2
0
        public void TypesTest()
        {
            var types = new List <Type>()
            {
                typeof(DataContractTypes.Person1),
                typeof(DataContractTypes.Person2),
                typeof(ExporterTypesTests.Group),
                typeof(ExporterTypesTests.NoDataContract),
                typeof(ExporterTypesTests.DataContractWithValidMember),
                typeof(ExporterTypesTests.DataContractWithValidMember),
                typeof(ExporterTypesTests.PersonInfo),
            };

            XsdDataContractExporter exporter = new XsdDataContractExporter();
            ExportOptions           options  = new ExportOptions();

            options.KnownTypes.Add(typeof(ArrayList));
            options.KnownTypes.Add(typeof(Guid));
            exporter.Options = options;

            exporter.Export(types);
            exporter.Export(types); // Run twice, to ensure that types are not re-exported

            string schemas = SchemaUtils.DumpSchema(exporter.Schemas);

            _output.WriteLine(schemas);
            _output.WriteLine($"----------------- {exporter.Schemas.Count}, {exporter.Schemas.GlobalElements.Count}, {exporter.Schemas.GlobalTypes.Count}");

            Assert.Equal(5, exporter.Schemas.Count);
            Assert.Equal(36, exporter.Schemas.GlobalElements.Count);
            Assert.Equal(18, exporter.Schemas.GlobalTypes.Count);

            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/SerializableTypes.XsdDataContractExporterTests"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/SerializableTypes.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""DataContractTypes.Person1"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""DataContractTypes.Person1"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:import namespace=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"" />", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Group"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ArrayOfExporterTypesTests.Person"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Person"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Employee"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Admin"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Architect"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.Engineer"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.NoDataContract"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.DataContractWithValidMember"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.PersonInfo"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExporterTypesTests.InnerPersonCollection"">", ref schemas);
            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref schemas);
        }
예제 #3
0
        public void Export(string testname, Action <XsdDataContractExporter> export, Action <string, XmlSchemaSet> schemaCheck = null)
        {
            _output.WriteLine($"=============== {testname} ===============");
            XsdDataContractExporter exporter = new XsdDataContractExporter();

            export(exporter);

            string schemas = SchemaUtils.DumpSchema(exporter.Schemas);

            _output.WriteLine("Count = " + exporter.Schemas.Count);
            _output.WriteLine(schemas);

            // When checking schema count, be sure to include the "Serialization" schema - which is omitted from 'DumpSchema' - as
            // well as the XmlSchema, both of which are the base from which all further schemas build.
            if (schemaCheck != null)
            {
                schemaCheck(schemas, exporter.Schemas);
            }

            Assert.True(schemas.Length > 0);
        }
예제 #4
0
        public void SurrogateProvider(Type type, ISerializationSurrogateProvider surrogate, Action <string, XmlSchemaSet> schemaCheck = null)
        {
            ExportOptions options = new ExportOptions()
            {
                DataContractSurrogate = surrogate
            };
            XsdDataContractExporter exporter = new XsdDataContractExporter()
            {
                Options = options
            };

            exporter.Export(type);
            string schema = SchemaUtils.DumpSchema(exporter.Schemas);

            _output.WriteLine(schema);

            if (schemaCheck != null)
            {
                schemaCheck(schema, exporter.Schemas);
            }
        }
예제 #5
0
        public static IEnumerable <object[]> Export_MemberData()
        {
            // Export(Type)
            yield return(new object[] { "Exp1", (XsdDataContractExporter exp) => exp.Export(typeof(Types.Point)), (string s, XmlSchemaSet ss) => {
                                            Assert.Equal(3, ss.Count);
                                            // *basic*
                                            // Point
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://basic"" elementFormDefault=""qualified"" targetNamespace=""http://basic"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""Point"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""X"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Y"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""Point"" nillable=""true"" type=""tns:Point"" />", ref s);
                                        } });

            // Export(ICollection<Assembly>)
            // AppContext SetSwitch seems to be unreliable in the unit test case. So let's not rely on it
            // for test coverage. But let's do look at the app switch to get our verification correct.
            AppContext.TryGetSwitch("Switch.System.Runtime.Serialization.DataContracts.Auto_Import_KVP", out bool autoImportKVP);
            yield return(new object[] { "Exp2", (XsdDataContractExporter exp) => exp.Export(new Assembly[] { typeof(DataContractTypes).Assembly }), (string s, XmlSchemaSet ss) => {
                                            Assert.Equal(autoImportKVP ? 21 : 20, ss.Count);
                                            Assert.Equal(autoImportKVP ? 171 : 163, ss.GlobalTypes.Count);
                                            Assert.Equal(autoImportKVP ? 204 : 196, ss.GlobalElements.Count);
                                        } });

            // Export(ICollection<Type>)
            yield return(new object[] { "Exp3", (XsdDataContractExporter exp) => exp.Export(new Type[] { typeof(Types.Point), typeof(Types.Circle) }), (string s, XmlSchemaSet ss) => {
                                            Assert.Equal(4, ss.Count);
                                            // *basic*
                                            // Point
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://basic"" elementFormDefault=""qualified"" targetNamespace=""http://basic"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""Point"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""X"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Y"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""Point"" nillable=""true"" type=""tns:Point"" />", ref s);
                                            // *shapes*
                                            // Circle
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://shapes"" elementFormDefault=""qualified"" targetNamespace=""http://shapes"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:import namespace=""http://basic"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""Circle"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Center"" nillable=""true"" xmlns:q1=""http://basic"" type=""q1:Point"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Radius"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""Circle"" nillable=""true"" type=""tns:Circle"" />", ref s);
                                        } });

            yield return(new object[] { "Exp4", (XsdDataContractExporter exp) => exp.Export(new Type[] { typeof(Types.NonAttributedPersonStruct), typeof(Types.NonAttributedPersonClass), typeof(Types.ExtendedSquare) }), (string s, XmlSchemaSet ss) => {
                                            Assert.Equal(5, ss.Count);
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests.Types"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests.Types"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:import namespace=""http://schemas.microsoft.com/2003/10/Serialization/"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:import namespace=""http://shapes"" />", ref s);
                                            // *Types*
                                            // NonAttributedPersonStruct
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""NonAttributedPersonStruct"">", ref s);
                                            Assert.Matches(@"<xs:appinfo>\s*<IsValueType xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">true</IsValueType>", s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""firstName"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""lastName"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""NonAttributedPersonStruct"" nillable=""true"" type=""tns:NonAttributedPersonStruct"" />", ref s);
                                            // NonAttributedPersonClass
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""NonAttributedPersonClass"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""firstName"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""lastName"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""NonAttributedPersonClass"" nillable=""true"" type=""tns:NonAttributedPersonClass"" />", ref s);
                                            // ExtendedSquare
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""ExtendedSquare"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexContent mixed=""false"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:extension xmlns:q1=""http://shapes"" base=""q1:Square"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""lineColor"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""ExtendedSquare"" nillable=""true"" type=""tns:ExtendedSquare"" />", ref s);
                                            // *shapes*
                                            // Square
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://shapes"" elementFormDefault=""qualified"" targetNamespace=""http://shapes"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""Square"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""BottomLeft"" nillable=""true"" xmlns:q1=""http://basic"" type=""q1:Point"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Side"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""Square"" nillable=""true"" type=""tns:Square"" />", ref s);
                                            // *basic*
                                            // Point
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://basic"" elementFormDefault=""qualified"" targetNamespace=""http://basic"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""Point"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""X"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Y"" type=""xs:int"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""Point"" nillable=""true"" type=""tns:Point"" />", ref s);
                                        } });

            // EnumsTest - from Enums.cs
            yield return(new object[] { "ExpEnum", (XsdDataContractExporter exp) => exp.Export(new Type[] { typeof(System.Reflection.TypeAttributes) }), (string s, XmlSchemaSet ss) => {
                                            Assert.Equal(3, ss.Count);
                                            //Assert.Equal(3, ss.GlobalAttributes.Count);
                                            Assert.Equal(5, ss.GlobalTypes.Count);
                                            Assert.Equal(23, ss.GlobalElements.Count);
                                        } });
        }
예제 #6
0
        public static IEnumerable <object[]> SurrogateProvider_MemberData()
        {
            yield return(new object[] { typeof(SurrogateTests.CircleContainer), new NodeToSerializableNode(new CircleToSquare(new XmlSerializerToXmlFormatter(null))), (string s, XmlSchemaSet ss) => {
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.CircleContainer"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Circles"" nillable=""true"" type=""tns:ArrayOfSurrogateTests.Circle"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:d1p1=""http://www.w3.org/2001/XMLSchema"" i:type=""d1p1:string"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">Property</Surrogate>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""circle"" nillable=""true"" type=""tns:SurrogateTests.Square"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:d1p1=""http://www.w3.org/2001/XMLSchema"" i:type=""d1p1:string"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">Field</Surrogate>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.CircleContainer"" nillable=""true"" type=""tns:SurrogateTests.CircleContainer"" />", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""ArrayOfSurrogateTests.Circle"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" maxOccurs=""unbounded"" name=""SurrogateTests.Circle"" nillable=""true"" type=""tns:SurrogateTests.Square"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""ArrayOfSurrogateTests.Circle"" nillable=""true"" type=""tns:ArrayOfSurrogateTests.Circle"" />", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.Square"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" z:Id=""1"" xmlns:d1p1=""http://schemas.datacontract.org/2004/07/System"" i:type=""d1p1:Version"" xmlns:z=""http://schemas.microsoft.com/2003/10/Serialization/"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Build>0</d1p1:_Build>", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Major>7</d1p1:_Major>", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Minor>0</d1p1:_Minor>", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Revision>0</d1p1:_Revision>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""Side"" type=""xs:int"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:d1p1=""http://www.w3.org/2001/XMLSchema"" i:type=""d1p1:string"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">Field</Surrogate>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.Square"" nillable=""true"" type=""tns:SurrogateTests.Square"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                        } });

            yield return(new object[] { typeof(SurrogateTests.Node), new NodeToSerializableNode(new CircleToSquare(new XmlSerializerToXmlFormatter(null))), (string s, XmlSchemaSet ss) => {
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.SerializableNode"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" z:Id=""1"" xmlns:d1p1=""http://schemas.datacontract.org/2004/07/System"" i:type=""d1p1:Version"" xmlns:z=""http://schemas.microsoft.com/2003/10/Serialization/"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Build>0</d1p1:_Build>", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Major>7</d1p1:_Major>", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Minor>0</d1p1:_Minor>", ref s);
                                            SchemaUtils.OrderedContains(@"<d1p1:_Revision>0</d1p1:_Revision>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""next"" nillable=""true"" type=""tns:SurrogateTests.SerializableNode"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:d1p1=""http://www.w3.org/2001/XMLSchema"" i:type=""d1p1:string"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">Field</Surrogate>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.SerializableNode"" nillable=""true"" type=""tns:SurrogateTests.SerializableNode"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                        } });

            yield return(new object[] { typeof(SurrogateTests.XmlSerializerPerson), new NodeToSerializableNode(new CircleToSquare(new XmlSerializerToXmlFormatter(null))), (string s, XmlSchemaSet ss) => {
                                            SchemaUtils.OrderedContains(@"<xs:schema elementFormDefault=""qualified"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""XmlSerializerPersonElement"" nillable=""true"" type=""XmlSerializerPerson"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""XmlSerializerPerson"">", ref s);
                                            SchemaUtils.OrderedContains(@"<Surrogate xmlns:d1p1=""http://www.w3.org/2001/XMLSchema"" i:type=""d1p1:string"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">XmlSerializable</Surrogate>", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:attribute name=""Name"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:attribute name=""Age"" type=""xs:int"" use=""required"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""XmlSerializerPerson"" nillable=""true"" type=""XmlSerializerPerson"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                        } });

            yield return(new object[] { typeof(SurrogateTests.ValidSurrogateTest), new PersonSurrogate(), (string s, XmlSchemaSet ss) => {
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.ValidSurrogateTest"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Friends"" nillable=""true"" type=""tns:ArrayOfSurrogateTests.NonSerializablePerson"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.ValidSurrogateTest"" nillable=""true"" type=""tns:SurrogateTests.ValidSurrogateTest"" />", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""ArrayOfSurrogateTests.NonSerializablePerson"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" maxOccurs=""unbounded"" name=""SurrogateTests.NonSerializablePerson"" nillable=""true"" type=""tns:SurrogateTests.Person"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""ArrayOfSurrogateTests.NonSerializablePerson"" nillable=""true"" type=""tns:ArrayOfSurrogateTests.NonSerializablePerson"" />", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.Person"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""name"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.Person"" nillable=""true"" type=""tns:SurrogateTests.Person"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                        } });

            yield return(new object[] { typeof(SurrogateTests.ValidSurrogateTestDC), new PersonSurrogate(), (string s, XmlSchemaSet ss) => {
                                            SchemaUtils.OrderedContains(@"<xs:schema xmlns:tns=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.datacontract.org/2004/07/System.Runtime.Serialization.Xml.XsdDataContractExporterTests"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.ValidSurrogateTestDC"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""Friends"" nillable=""true"" type=""tns:ArrayOfSurrogateTests.NonSerializablePersonDC"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.ValidSurrogateTestDC"" nillable=""true"" type=""tns:SurrogateTests.ValidSurrogateTestDC"" />", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""ArrayOfSurrogateTests.NonSerializablePersonDC"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" maxOccurs=""unbounded"" name=""SurrogateTests.NonSerializablePersonDC"" nillable=""true"" type=""tns:SurrogateTests.PersonDC"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""ArrayOfSurrogateTests.NonSerializablePersonDC"" nillable=""true"" type=""tns:ArrayOfSurrogateTests.NonSerializablePersonDC"" />", ref s);

                                            SchemaUtils.OrderedContains(@"<xs:complexType name=""SurrogateTests.PersonDC"">", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element minOccurs=""0"" name=""name"" nillable=""true"" type=""xs:string"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:element name=""SurrogateTests.PersonDC"" nillable=""true"" type=""tns:SurrogateTests.PersonDC"" />", ref s);
                                            SchemaUtils.OrderedContains(@"<xs:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">", ref s);
                                        } });
        }