Ejemplo n.º 1
0
        public static IEnumerable <object[]> CanImport_MemberData()
        {
            // CanImport(XmlSchemaSet)
            yield return(new object[] { true, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.PositiveSchemas) });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(null), typeof(ArgumentNullException), @"Value cannot be null. (Parameter 'schemas')" });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.MixedSchemas) });

            // CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)
            yield return(new object[] { true, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.PositiveSchemas, new XmlQualifiedName[] { SchemaUtils.ValidTypeNames[0] }) });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(null, SchemaUtils.InvalidTypeNames), typeof(ArgumentNullException), @"Value cannot be null. (Parameter 'schemas')" });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.MixedSchemas, (ICollection <XmlQualifiedName>)null), typeof(ArgumentNullException), @"Value cannot be null. (Parameter 'typeNames')" });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.MixedSchemas, new XmlQualifiedName[] { null }), typeof(ArgumentException), @"Cannot import type for null XmlQualifiedName specified via parameter." });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.MixedSchemas, SchemaUtils.InvalidTypeNames) });

            // CanImport(XmlSchemaSet, XmlQualifiedName)
            yield return(new object[] { true, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.PositiveSchemas, SchemaUtils.ValidTypeNames[0]) });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(null, SchemaUtils.InvalidTypeNames[0]), typeof(ArgumentNullException), @"Value cannot be null. (Parameter 'schemas')" });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.MixedSchemas, (XmlQualifiedName)null), typeof(ArgumentNullException), @"Value cannot be null. (Parameter 'typeName')" });

            yield return(new object[] { false, (XsdDataContractImporter imp) => imp.CanImport(SchemaUtils.MixedSchemas, SchemaUtils.InvalidTypeNames[0]) });

            // CanImport(XmlSchemaSet, XmlSchemaElement)
            // TODO

            // CanImportTests.cs
            foreach (var citArgs in SchemaUtils.CanImportTests)
            {
                XmlSchemaSet schemaSet = SchemaUtils.ReadStringsIntoSchemaSet(citArgs.schemaString);
                if (citArgs.qnames == null)
                {
                    yield return new object[] { citArgs.expectedResult, (XsdDataContractImporter imp) => imp.CanImport(schemaSet) }
                }
                ;
                else if (citArgs.qnames.Length == 1 && citArgs.isElement)
                {
                    yield return new object[] { citArgs.expectedResult, (XsdDataContractImporter imp) => imp.CanImport(schemaSet, SchemaUtils.GetSchemaElement(schemaSet, citArgs.qnames[0])) }
                }
                ;
                else if (citArgs.qnames.Length == 1)
                {
                    yield return new object[] { citArgs.expectedResult, (XsdDataContractImporter imp) => imp.CanImport(schemaSet, citArgs.qnames[0]) }
                }
                ;
                else
                {
                    yield return new object[] { citArgs.expectedResult, (XsdDataContractImporter imp) => imp.CanImport(schemaSet, citArgs.qnames) }
                };
            }
        }
Ejemplo n.º 2
0
        public static IEnumerable <object[]> Import_MemberData()
        {
            int newlineSize = Environment.NewLine.Length;

            // Import(XmlSchemaSet)
            yield return(new object[] { (XsdDataContractImporter imp) => imp.Import(SchemaUtils.PositiveSchemas), 5060 + (168 * newlineSize) });   // 168 lines

            // Import(XmlSchemaSet, ICollection<XmlQualifiedName>)
            yield return(new object[] { (XsdDataContractImporter imp) => imp.Import(SchemaUtils.PositiveSchemas, new XmlQualifiedName[] { SchemaUtils.ValidTypeNames[0] }), 1515 + (50 * newlineSize) }); // 50 lines

            // Import(XmlSchemaSet, XmlQualifiedName)
            yield return(new object[] { (XsdDataContractImporter imp) => imp.Import(SchemaUtils.PositiveSchemas, SchemaUtils.ValidTypeNames[0]), 1515 + (50 * newlineSize) }); // 50 lines

            // Import(XmlSchemaSet, XmlSchemaElement)
            // TODO

            // From CanImportTests.cs
            foreach (var citArgs in SchemaUtils.CanImportTests)
            {
                if (citArgs.expectedResult)
                {
                    XmlSchemaSet schemaSet = SchemaUtils.ReadStringsIntoSchemaSet(citArgs.schemaString);

                    if (citArgs.qnames == null)
                    {
                        yield return new object[] { (XsdDataContractImporter imp) => imp.Import(schemaSet) }
                    }
                    ;
                    else if (citArgs.qnames.Length == 1 && citArgs.isElement)
                    {
                        yield return new object[] { (XsdDataContractImporter imp) => { imp.Import(schemaSet, SchemaUtils.GetSchemaElement(schemaSet, citArgs.qnames[0])); } }
                    }
                    ;
                    else if (citArgs.qnames.Length == 1 && !citArgs.isElement)
                    {
                        yield return new object[] { (XsdDataContractImporter imp) => imp.Import(schemaSet, citArgs.qnames[0]) }
                    }
                    ;
                    else
                    {
                        yield return new object[] { (XsdDataContractImporter imp) => imp.Import(schemaSet, citArgs.qnames) }
                    };
                }
            }

            // From FormatVersioning.cs : Positive tests
            (string msg, Type type, string xpath, string xmlFrag)[] formatVersioningArgs = new (string, Type, string, string)[] {