public void Init()
        {
            string sharpDevelopSchemaFolder = @"c:\sharpdevelop\schemas";

            string[] schemaFolders           = new string[] { @"c:\sharpdevelop\schemas" };
            string   userDefinedSchemaFolder = @"c:\users\user\schemas";

            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(schemaFolders, userDefinedSchemaFolder, fileSystem, factory);

            fileSystem.AddExistingFolders(schemaFolders);
            fileSystem.AddExistingFolder(userDefinedSchemaFolder);

            addinSchemaFileName = Path.Combine(sharpDevelopSchemaFolder, "addin.xsd");
            string[] sharpDevelopSchemaFiles = new string[] { addinSchemaFileName };
            fileSystem.AddDirectoryFiles(sharpDevelopSchemaFolder, sharpDevelopSchemaFiles);

            testSchemaFileName = Path.Combine(userDefinedSchemaFolder, "test.xsd");
            string[] userDefinedSchemaFiles = new string[] { testSchemaFileName };
            fileSystem.AddDirectoryFiles(userDefinedSchemaFolder, userDefinedSchemaFiles);

            factory.AddSchemaXml(addinSchemaFileName,
                                 "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://addin' />");
            factory.AddSchemaXml(testSchemaFileName,
                                 "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />");

            fileSystem.AddExistingFile(addinSchemaFileName, true);
            fileSystem.AddExistingFile(testSchemaFileName, false);

            registeredXmlSchemas.ReadSchemas();

            userSchemaRemovedEventFiredCount = 0;
            registeredXmlSchemas.UserDefinedSchemaRemoved += UserSchemaRemoved;
        }
        public void Init()
        {
            testSchemaXml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />";
            XmlSchemaCompletion testSchema = new XmlSchemaCompletion(new StringReader(testSchemaXml));

            testSchema.IsReadOnly = false;

            string xml = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://xml' />";
            XmlSchemaCompletion xmlSchema = new XmlSchemaCompletion(new StringReader(xml));

            xmlSchema.IsReadOnly = false;

            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(testSchema);
            schemas.Add(xmlSchema);

            string userDirectory = @"c:\users\user\schemas";

            factory = new MockXmlSchemaCompletionDataFactory();
            MockFileSystem fileSystem = new MockFileSystem();

            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], userDirectory, fileSystem, factory);
            registeredXmlSchemas.Schemas.AddRange(schemas);

            properties   = new Properties();
            associations = new XmlSchemaFileAssociations(properties, new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);

            panel         = new MockXmlSchemasPanel();
            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, new string[0], associations, panel, factory);
            schemasEditor.LoadOptions();

            panel.SelectedXmlSchemaListItemIndex = 0;
            schemasEditor.RemoveSelectedSchema();
        }
        public void Init()
        {
            string userDefinedSchemaFolder = @"c:\users\user\schemas";

            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], userDefinedSchemaFolder, fileSystem, factory);

            fileSystem.AddExistingFolder(userDefinedSchemaFolder);

            string testSchemaFileName = Path.Combine(userDefinedSchemaFolder, "test.xsd");

            duplicateTestSchemaFileName = Path.Combine(userDefinedSchemaFolder, "test2.xsd");
            string[] userDefinedSchemaFiles = new string[] { testSchemaFileName, duplicateTestSchemaFileName };
            fileSystem.AddDirectoryFiles(userDefinedSchemaFolder, userDefinedSchemaFiles);

            factory.AddSchemaXml(testSchemaFileName,
                                 "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />");

            factory.AddSchemaXml(duplicateTestSchemaFileName,
                                 "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />");

            fileSystem.AddExistingFile(testSchemaFileName, false);
            fileSystem.AddExistingFile(duplicateTestSchemaFileName, false);

            registeredXmlSchemas.ReadSchemas();
        }
        public void Init()
        {
            LoadBarSchema();
            LoadFooSchema();
            fooSchemaData.IsReadOnly = true;
            LoadXmlSchema();

            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(fooSchemaData);
            schemas.Add(barSchemaData);
            schemas.Add(xmlSchemaData);

            factory = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], String.Empty, new MockFileSystem(), factory);
            registeredXmlSchemas.Schemas.AddRange(schemas);

            string[] xmlFileExtensions = new string[] { ".foo", ".bar", ".xml" };

            DefaultXmlSchemaFileAssociations defaultSchemaFileAssociations = new DefaultXmlSchemaFileAssociations();

            defaultSchemaFileAssociations.Add(new XmlSchemaFileAssociation(".foo", "http://foo"));
            defaultSchemaFileAssociations.Add(new XmlSchemaFileAssociation(".bar", "http://bar", "b"));

            properties   = new Properties();
            associations = new XmlSchemaFileAssociations(properties, defaultSchemaFileAssociations, new XmlSchemaCompletionCollection());
            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xml", "http://xml"));

            panel         = new MockXmlSchemasPanel();
            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, xmlFileExtensions, associations, panel, factory);
            schemasEditor.LoadOptions();
        }
Beispiel #5
0
        public void Init()
        {
            RegisteredXmlSchemas      registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], String.Empty, null, null);
            XmlSchemaFileAssociations associations         = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(null), registeredXmlSchemas.Schemas);

            panel         = new MockXmlSchemasPanel();
            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, new string[0], associations, panel, null);
            schemasEditor.LoadOptions();
        }
        public void Init()
        {
            userDefinedSchemaFolder = @"c:\users\user\sharpdevelop\schemas";

            schema = LoadTestSchema();

            userSchemaAddedEventFiredCount = 0;
            fileSystem        = new MockFileSystem();
            factory           = new MockXmlSchemaCompletionDataFactory();
            registeredSchemas = new RegisteredXmlSchemas(new string[0], userDefinedSchemaFolder, fileSystem, factory);
            registeredSchemas.UserDefinedSchemaAdded += UserSchemaAdded;
            registeredSchemas.AddUserSchema(schema);
        }
        public void Init()
        {
            expectedSearchedFolders = new string[] { @"c:\sharpdevelop\data-dir\schemas",
                                                     @"c:\users\user\sharpdevelop\schemas" };

            string[] readOnlySchemaFolders = new String[] { @"c:\folder-does-not-exist",
                                                            @"c:\sharpdevelop\data-dir\schemas" };

            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(readOnlySchemaFolders, @"c:\users\user\sharpdevelop\schemas", fileSystem, factory);
            fileSystem.AddExistingFolders(expectedSearchedFolders);
            registeredXmlSchemas.ReadSchemas();
        }
Beispiel #8
0
        public void Init()
        {
            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], @"c:\users\user\sharpdevelop\schemas", fileSystem, factory);
            XmlSchemaCompletionCollection schemas      = new XmlSchemaCompletionCollection();
            XmlSchemaFileAssociations     associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(null), schemas);

            panel = new MockXmlSchemasPanel();

            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, new string[0], associations, panel, factory);
            schemasEditor.LoadOptions();

            panel.OpenFileDialogFileNameToReturn = @"c:\temp\schema.xsd";
            panel.OpenFileDialogResultToReturn   = true;
        }
        public void Init()
        {
            string[] schemaFolders = new string[] { @"d:\projects\schemas" };

            exceptionThrownWhenReadingSchema = new ApplicationException("Read schema failed.");

            factory = new MockXmlSchemaCompletionDataFactory();
            factory.ExceptionToThrowWhenCreateXmlSchemaCalled = exceptionThrownWhenReadingSchema;

            fileSystem = new MockFileSystem();
            fileSystem.AddExistingFolders(schemaFolders);

            string[] sharpDevelopSchemaFiles = new string[] { @"d:\projects\schemas\addin.xsd" };
            fileSystem.AddDirectoryFiles(@"d:\projects\schemas", sharpDevelopSchemaFiles);

            registeredXmlSchemas = new RegisteredXmlSchemas(schemaFolders, String.Empty, fileSystem, factory);
            registeredXmlSchemas.ReadSchemas();
        }
        public void Init()
        {
            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], @"c:\users\user\sharpdevelop\schemas", fileSystem, factory);

            string testSchemaXml       = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />";
            XmlSchemaCompletion schema = new XmlSchemaCompletion(new StringReader(testSchemaXml));

            schema.IsReadOnly = false;
            registeredXmlSchemas.Schemas.Add(schema);

            XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(null), registeredXmlSchemas.Schemas);

            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".test", "http://test"));
            panel = new MockXmlSchemasPanel();

            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, new string[] { ".test" }, associations, panel, factory);
            schemasEditor.LoadOptions();

            string newXmlSchemaFileName = @"c:\projects\new.xsd";
            string newSchemaXml         = "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://new' />";

            factory.AddSchemaXml(newXmlSchemaFileName, newSchemaXml);

            panel.OpenFileDialogFileNameToReturn = newXmlSchemaFileName;
            panel.OpenFileDialogResultToReturn   = true;

            // Add schema from file system to ensure that the list of schemas shown to the
            // user is from the list of schemas in the list box when changing the association
            // to a file extension
            schemasEditor.AddSchemaFromFileSystem();

            panel.SelectedXmlSchemaFileAssociationListItemIndex = 0;
            schemasEditor.XmlSchemaFileAssociationFileExtensionSelectionChanged();

            panel.SelectXmlSchemaWindowDialogResultToReturn = true;
            panel.SelectXmlSchemaWindowNamespaceToReturn    = "http://new";
            schemasEditor.ChangeSchemaAssociation();
        }
Beispiel #11
0
        public void Init()
        {
            factory = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], String.Empty, null, factory);
            properties           = new Properties();
            DefaultXmlSchemaFileAssociations defaultAssociations = new DefaultXmlSchemaFileAssociations(new AddInTreeNode());

            associations = new XmlSchemaFileAssociations(properties, defaultAssociations, new XmlSchemaCompletionCollection());
            schemasPanel = new XmlSchemasPanel(registeredXmlSchemas, new string[0], associations, factory);

            schemaListBox          = schemasPanel.FindName("schemaListBox") as ListBox;
            fileExtensionComboBox  = schemasPanel.FindName("fileExtensionComboBox") as ComboBox;
            removeSchemaButton     = schemasPanel.FindName("removeSchemaButton") as Button;
            namespacePrefixTextBox = schemasPanel.FindName("namespacePrefixTextBox") as TextBox;
            schemaNamespaceTextBox = schemasPanel.FindName("schemaNamespaceTextBox") as TextBox;

            schemaListItem = new XmlSchemaListItem("a");
            schemaListBox.Items.Add(schemaListItem);

            fileAssociationItem = new XmlSchemaFileAssociationListItem(".xsd", "ns", "a");
            schemasPanel.AddXmlSchemaFileAssociationListItem(fileAssociationItem);
        }
Beispiel #12
0
        public void Init()
        {
            fileSystem           = new MockFileSystem();
            factory              = new MockXmlSchemaCompletionDataFactory();
            registeredXmlSchemas = new RegisteredXmlSchemas(new string[0], @"c:\users\user\sharpdevelop\schemas", fileSystem, factory);
            XmlSchemaCompletionCollection schemas      = new XmlSchemaCompletionCollection();
            XmlSchemaFileAssociations     associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(null), schemas);

            panel = new MockXmlSchemasPanel();

            schemasEditor = new RegisteredXmlSchemasEditor(registeredXmlSchemas, new string[0], associations, panel, factory);
            schemasEditor.LoadOptions();

            newXmlSchemaFileName = @"c:\projects\a.xsd";
            factory.AddSchemaXml(newXmlSchemaFileName,
                                 "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://test' />");

            panel.OpenFileDialogFileNameToReturn = newXmlSchemaFileName;
            panel.OpenFileDialogResultToReturn   = true;

            schemasEditor.AddSchemaFromFileSystem();
        }