コード例 #1
0
        public void TextEditorSetCanBeRetrieved()
        {
            MockTextEditor editor = new MockTextEditor();

            view.TextEditor = editor;
            Assert.AreSame(editor, view.TextEditor);
        }
        public void Init()
        {
            originalXml =
                "<root>\r\n" +
                "\t<child>\r\n" +
                "\t</child>\r\n" +
                "</root>";

            textEditor = new MockTextEditor();
            textEditor.OptionsConvertTabsToSpaces = false;
            textEditor.OptionsIndentationSize     = 4;
            textEditor.OptionsIndentationString   = "\t";

            textEditor.Document.Text = originalXml;

            // Insert new xml as child element of <child>.
            // Insert position is just before the start of </root> end element.
            WixDocumentEditor editor = new WixDocumentEditor(textEditor);

            string xmlToInsert =
                "<new-child>\r\n" +
                "</new-child>\r\n";

            int line   = 3;
            int column = 2;

            editor.InsertIndented(line, column, xmlToInsert);

            document = textEditor.Document;
        }
コード例 #3
0
 void CreateXmlFoldingManager()
 {
     fakeTextEditor     = new MockTextEditor();
     fakeXmlFoldParser  = new FakeXmlFoldParser();
     fakeFoldingManager = new FakeFoldingManager();
     xmlFoldingManager  = new XmlFoldingManager(fakeTextEditor, fakeFoldingManager, fakeXmlFoldParser);
 }
コード例 #4
0
 public void CreateFakeWorkbench()
 {
     workbench             = MockWorkbench.CreateWorkbenchWithOneViewContent("test.py");
     fakeConsoleTextEditor = workbench.FakeScriptingConsolePad.FakeConsoleTextEditor;
     fakeConsole           = workbench.FakeScriptingConsolePad.FakeScriptingConsole;
     fakeTextEditor        = workbench.ActiveMockEditableViewContent.MockTextEditor;
 }
コード例 #5
0
        public void Init()
        {
            SD.InitializeForUnitTests();
            textEditor = new MockTextEditor();
            MockTextEditorViewContent viewContent = new MockTextEditorViewContent();

            viewContent.TextEditor = textEditor;
            viewContent.SetFileName(@"d:\projects\test\file.wxs");

            workbench = new MockWorkbench();
            workbench.ViewContentCollection.Add(viewContent);

            MockTextEditorOptions textEditorOptions = new MockTextEditorOptions();
            MockXmlTextWriter     xmlTextWriter     = new MockXmlTextWriter(textEditorOptions);
            WixProject            project           = WixBindingTestsHelper.CreateEmptyWixProject();

            document = new WixDocument(project, new DefaultFileLoader());
            document.LoadXml(GetWixXml());
            document.FileName        = @"d:\projects\test\File.wxs";
            textEditor.Document.Text = GetWixXml();

            MockWixPackageFilesControl packageFilesControl = new MockWixPackageFilesControl();

            packageFilesView = new PackageFilesView(project, workbench, packageFilesControl, xmlTextWriter);

            packageFilesControl.IsDirty = true;
            AddNewChildElementsToDirectory();
            packageFilesView.Write(document);
        }
コード例 #6
0
        public void Init()
        {
            textEditor = new MockTextEditor();
            textEditor.Document.Text = GetWixXml();

            string replacementXml =
                "<NewElement>\r\n" +
                "</NewElement>";

            wixDocumentEditor = new WixDocumentEditor(textEditor);
            replacementRegion = wixDocumentEditor.ReplaceElement("TARGETDIR", "Directory", replacementXml);
        }
コード例 #7
0
        public void Init()
        {
            string xml   = "<root attribute1=''></root>";
            int    index = 10;

            MockTextEditor textEditor = new MockTextEditor();

            textEditor.Document.Text = xml;
            textEditor.Caret.Offset  = index;

            selectedElement = new SelectedXmlElement(textEditor);
        }
        public void Init()
        {
            formattingStrategy = new XmlFormattingStrategy();

            options            = new MockTextEditorOptions();
            textEditor         = new MockTextEditor();
            textEditor.Options = options;

            textDocument = new TextDocument();
            document     = textDocument;
            textEditor.SetDocument(document);
        }
        public void Init()
        {
            string xml   = "<parent a='attributeValue'></parent>";
            int    index = 15;

            MockTextEditor textEditor = new MockTextEditor();

            textEditor.Document.Text = xml;
            textEditor.Caret.Offset  = index;

            selectedElement = new SelectedXmlElement(textEditor);
        }
コード例 #10
0
        public void Init()
        {
            formattingStrategy = new XmlFormattingStrategy();

            options            = new MockTextEditorOptions();
            textEditor         = new MockTextEditor();
            textEditor.Options = options;

            textDocument = new TextDocument();
            document     = new AvalonEditDocumentAdapter(textDocument, null);
            textEditor.SetDocument(document);
        }
        public void Init()
        {
            string xml   = "<abc></abc>";
            int    index = 2;

            MockTextEditor textEditor = new MockTextEditor();

            textEditor.Document.Text = xml;
            textEditor.Caret.Offset  = index;

            selectedElement = new SelectedXmlElement(textEditor);
        }
        public void Init()
        {
            schemas = new XmlSchemaCompletionCollection();

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

            textEditor               = new MockTextEditor();
            textEditor.FileName      = new FileName(@"c:\projects\test.xsd");
            textEditor.Document.Text = "";
            textEditor.Caret.Offset  = 0;

            completionBinding = new XmlCodeCompletionBinding(associations);
        }
コード例 #13
0
        protected void InitBase()
        {
            schemas = new XmlSchemaCompletionCollection();
            AddSchemas();

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

            textEditor = new MockTextEditor();
            textEditor.Document.Text = "<a xmlns></a>";
            textEditor.FileName      = new FileName(@"c:\projects\test.xml");

            // Put caret just after "xmlns".
            textEditor.Caret.Offset = 8;
        }
コード例 #14
0
        public void Init()
        {
            XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();

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

            textEditor               = new MockTextEditor();
            textEditor.FileName      = new FileName(@"c:\projects\test.xsd");
            textEditor.Document.Text = "<xs:schema elementFormDefault=\"\"></xs:schema>";

            // Put cursor inside the double quotes following the elementFormDefault attribute
            textEditor.Caret.Offset = 31;

            completionBinding = new XmlCodeCompletionBinding(associations);
            result            = completionBinding.CtrlSpace(textEditor);
        }
        protected override void AfterInit()
        {
            document.LoadXml(GetWixXml());

            textEditor = new MockTextEditor();
            textEditor.Document.Text           = GetWixXml();
            viewWithOpenWixDocument.TextEditor = textEditor;

            AddNewChildElementsToDirectory();
            packageFilesControl.IsDirty = true;

            // User switches to text editor with WiX document that we are currently showing
            // in the PackageFilesView.
            workbench.ActiveViewContent = viewWithOpenWixDocument;
            workbench.RaiseActiveViewContentChangedEvent();
        }
コード例 #16
0
        public void Init()
        {
            existingTextEditor = new MockTextEditor();
            MockTextEditorViewContent viewContent = new MockTextEditorViewContent();

            viewContent.TextEditor = existingTextEditor;
            viewContent.SetFileName(@"d:\projects\test\file.wxs");

            workbench = new MockWorkbench();
            workbench.ViewContentCollection.Add(new MockViewContent());
            workbench.ViewContentCollection.Add(viewContent);

            document          = new WixDocument();
            document.FileName = @"d:\Projects\Test\File.wxs";

            openEditors = new OpenTextEditors(workbench);
        }
コード例 #17
0
        public void Init()
        {
            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema()));

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

            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xml", "http://www.w3.org/1999/xhtml"));

            textEditor = new MockTextEditor();
            textEditor.Document.Text = String.Empty;
            textEditor.FileName      = new FileName(@"c:\projects\test.xml");

            textEditor.Caret.Offset = 0;

            completionBinding = new XmlCodeCompletionBinding(associations);
        }
コード例 #18
0
        public void Init()
        {
            schemas = new XmlSchemaCompletionCollection();
            schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXsdSchema()));

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

            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs"));

            textEditor               = new MockTextEditor();
            textEditor.FileName      = new FileName(@"c:\projects\test.xsd");
            textEditor.Document.Text = "<xs:schema></xs:schema>";

            // Put cursor after the first 'a' in "<xs:schema>"
            textEditor.Caret.Offset = 10;

            XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(associations);

            keyPressResult = completionBinding.HandleKeyPress(textEditor, ' ');
        }
        public void Init()
        {
            XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();

            xsdSchema = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
            schemas.Add(xsdSchema);

            associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas);
            associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs"));

            textEditor               = new MockTextEditor();
            textEditor.FileName      = new FileName(@"c:\projects\test.xsd");
            textEditor.Document.Text = "<xs:schema elementFormDefault=\"\"></xs:schema>";

            // Put cursor inside the double quotes following the elementFormDefault attribute
            textEditor.Caret.Offset = 31;

            completionBinding = new XmlCodeCompletionBinding(associations);
            result            = completionBinding.CtrlSpace(textEditor);
        }
        public void Init()
        {
            formattingStrategy = new XmlFormattingStrategy();

            options            = new MockTextEditorOptions();
            textEditor         = new MockTextEditor();
            textEditor.Options = options;

            textDocument = new TextDocument();
            document     = textDocument;
            textEditor.SetDocument(document);

            document.Text =
                "<root>\r\n" +
                "\t<child>\r\n" +
                "</root>\r\n";

            // Just typed the '>' character of the <child> element
            textEditor.Caret.Offset = 16;
            formattingStrategy.FormatLine(textEditor, '>');
        }
        public void Init()
        {
            originalXml =
                "<root>\r\n" +
                "\t<child>\r\n" +
                "\t</child>\r\n" +
                "</root>";

            textEditor = new MockTextEditor();
            textEditor.OptionsConvertTabsToSpaces = false;
            textEditor.OptionsIndentationSize     = 4;
            textEditor.OptionsIndentationString   = "\t";

            document = textEditor.Document;

            textEditor.Document.Text = originalXml;

            // Replace the <child> element
            WixDocumentEditor editor = new WixDocumentEditor(textEditor);

            string xmlToInsert =
                "<new-child>\r\n" +
                "</new-child>";

            int line    = 2;
            int column  = 2;
            int endLine = 3;

            // End column is the column containing the '>' of the </child> element.
            int endColumn = 9;

            var region = new DomRegion(line, column, endLine, endColumn);

            WixDocumentLineSegment lineSegment = WixDocumentLineSegment.ConvertRegionToSegment(textEditor.Document, region);

            initialDocumentRegionText = textEditor.Document.GetText(lineSegment.Offset, lineSegment.Length);

            editor.Replace(region, xmlToInsert);
        }
        public void Init()
        {
            formattingStrategy = new XmlFormattingStrategy();

            options            = new MockTextEditorOptions();
            textEditor         = new MockTextEditor();
            textEditor.Options = options;

            textDocument = new TextDocument();
            document     = textDocument;
            textEditor.SetDocument(document);

            document.Text =
                "<root>\r\n" +
                "\t<child>\r\n" +
                "</child>\r\n" +
                "</root>\r\n";

            docLine = MockRepository.GenerateStub <IDocumentLine>();
            docLine.Stub(l => l.LineNumber).Return(3);
            formattingStrategy.IndentLine(textEditor, docLine);
        }
コード例 #23
0
        public void Init()
        {
            formattingStrategy = new XmlFormattingStrategy();

            options            = new MockTextEditorOptions();
            textEditor         = new MockTextEditor();
            textEditor.Options = options;

            textDocument = new TextDocument();
            document     = new AvalonEditDocumentAdapter(textDocument, null);
            textEditor.SetDocument(document);

            document.Text =
                "<root>\r\n" +
                "\t<child>\r\n" +
                "</child>\r\n" +
                "</root>\r\n";

            docLine            = new MockDocumentLine();
            docLine.LineNumber = 3;
            formattingStrategy.IndentLine(textEditor, docLine);
        }
コード例 #24
0
        public void Init()
        {
            formattingStrategy = new XmlFormattingStrategy();

            options            = new MockTextEditorOptions();
            textEditor         = new MockTextEditor();
            textEditor.Options = options;

            textDocument = new TextDocument();
            document     = new AvalonEditDocumentAdapter(textDocument, null);
            textEditor.SetDocument(document);

            textDocument.Text =
                "<root>\r\n" +
                "\t<child></child>\r\n" +
                "</root>";

            int selectionStart  = 9;
            int selectionLength = 15;

            textEditor.Select(selectionStart, selectionLength);

            formattingStrategy.SurroundSelectionWithComment(textEditor);
        }
コード例 #25
0
 void CreatePythonCodeCompletionBinding()
 {
     fakeTextEditor        = new MockTextEditor();
     codeCompletionBinding = new TestablePythonCodeCompletionBinding();
 }
コード例 #26
0
 void CreatePythonInsightWindowHandler()
 {
     fakeTextEditor    = new MockTextEditor();
     fakeInsightWindow = new FakeInsightWindow();
     handler           = new PythonInsightWindowHandler();
 }
コード例 #27
0
 public void Init()
 {
     textEditor = new MockTextEditor();
 }