コード例 #1
0
        public void CanReplaceTextEditorOptions()
        {
            MockTextEditorOptions options = new MockTextEditorOptions();

            view.MockTextEditorOptions = options;
            Assert.AreSame(options, view.TextEditor.Options);
        }
        public void SetUpFixture()
        {
            AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
            document        = textEditor.Document;
            textEditor.Text = GetTextEditorCode();

            PythonParser     parser          = new PythonParser();
            ICompilationUnit compilationUnit = parser.Parse(new DefaultProjectContent(), @"test.py", document.Text);

            using (DesignSurface designSurface = new DesignSurface(typeof(UserControl))) {
                IDesignerHost host        = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                UserControl   userControl = (UserControl)host.RootComponent;
                userControl.ClientSize = new Size(489, 389);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(userControl);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(userControl, "userControl1");

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    AvalonEditDocumentAdapter adapter   = new AvalonEditDocumentAdapter(document, null);
                    MockTextEditorOptions     options   = new MockTextEditorOptions();
                    PythonDesignerGenerator   generator = new PythonDesignerGenerator(options);
                    generator.Merge(host, adapter, compilationUnit, serializationManager);
                }
            }
        }
コード例 #3
0
		public void Init()
		{
			options = new MockTextEditorOptions();
			options.ConvertTabsToSpaces = false;
			options.IndentationSize = 4;
			mockXmlTextWriter = new MockXmlTextWriter(options);
		}
コード例 #4
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);
        }
コード例 #5
0
 public void Init()
 {
     options = new MockTextEditorOptions();
     options.ConvertTabsToSpaces = false;
     options.IndentationSize     = 4;
     mockXmlTextWriter           = new MockXmlTextWriter(options);
 }
コード例 #6
0
        public void CanSetAndGetTextEditorOptions()
        {
            MockTextEditorOptions options = new MockTextEditorOptions();

            editor.Options = options;
            Assert.AreSame(options, editor.Options);
        }
コード例 #7
0
 void CreateDesignerGenerator()
 {
     textEditorViewContent             = new MockTextEditorViewContent();
     formsDesignerOpenedFile           = new MockOpenedFile("test.py");
     textEditorViewContent.PrimaryFile = formsDesignerOpenedFile;
     formsDesignerView = new FormsDesignerViewContent(textEditorViewContent, formsDesignerOpenedFile);
     textEditorOptions = new MockTextEditorOptions();
     generator         = new TestableScriptingDesignerGenerator(textEditorOptions);
     generator.Attach(formsDesignerView);
     generator.ParseInfoToReturnFromParseFile = generator.CreateParseInfoWithOneClass();
 }
コード例 #8
0
        void CreatePythonFormattingStrategy()
        {
            MockTextEditorOptions textEditorOptions = new MockTextEditorOptions();

            textEditorOptions.IndentationSize = 4;
            textEditor         = new TextEditor();
            textEditor.Options = textEditorOptions;

            textEditorAdapter  = new AvalonEditTextEditorAdapter(textEditor);
            formattingStrategy = new PythonFormattingStrategy();
        }
コード例 #9
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()
        {
            formattingStrategy = new XmlFormattingStrategy();

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

            textDocument = new TextDocument();
            document     = textDocument;
            textEditor.SetDocument(document);
        }
コード例 #11
0
        public void SetUpFixture()
        {
            MockWorkbench workbench = MockWorkbench.CreateWorkbenchWithOneViewContent("test.cs");

            workbench.ActiveMockEditableViewContent.Text = "class Foo { }";

            MockTextEditorOptions options = workbench.ActiveMockEditableViewContent.MockTextEditorOptions;

            options.IndentationSize     = 4;
            options.ConvertTabsToSpaces = true;

            Run(workbench);
        }
        public void Init()
        {
            MockWorkbench workbench = MockWorkbench.CreateWorkbenchWithOneViewContent("test.vb");

            workbench.ActiveMockEditableViewContent.Text =
                "class Foo\r\n" +
                "end class";

            MockTextEditorOptions options = workbench.ActiveMockEditableViewContent.MockTextEditorOptions;

            options.ConvertTabsToSpaces = false;
            options.IndentationSize     = 2;

            Run(workbench);
        }
コード例 #13
0
        public void Init()
        {
            project                 = WixBindingTestsHelper.CreateEmptyWixProject();
            mockWorkbench           = new MockWorkbench();
            mockPackageFilesControl = new MockWixPackageFilesControl();
            textEditorOptions       = new MockTextEditorOptions();
            textEditorOptions.ConvertTabsToSpaces = false;

            xmlTextWriter    = new MockXmlTextWriter(textEditorOptions);
            packageFilesView = new PackageFilesView(project, mockWorkbench, mockPackageFilesControl, xmlTextWriter);

            mockWorkbench.ActiveContent = packageFilesView;

            document = new WixDocument(project, new DefaultFileLoader());
        }
コード例 #14
0
        public void XmlWriterSettingsIndentCharsIsTabTakenFromSaveMethod()
        {
            int    indentLength = 3;
            string indent       = " ".PadRight(indentLength);

            MockTextEditorOptions options = new MockTextEditorOptions();

            options.ConvertTabsToSpaces = true;
            options.IndentationSize     = indentLength;

            WixTextWriter wixWriter = new WixTextWriter(options);

            xmlWriter = wixWriter.Create(new StringWriter(new StringBuilder()));

            Assert.AreEqual(indent, xmlWriter.Settings.IndentChars);
        }
コード例 #15
0
        public void SetUpFixture()
        {
            textEditorOptions = new MockTextEditorOptions();
            generator         = new DerivedPythonDesignerGenerator(textEditorOptions);
            mockViewContent   = new MockTextEditorViewContent();
            viewContent       = new DerivedFormDesignerViewContent(mockViewContent, new MockOpenedFile(fileName));
            generator.Attach(viewContent);
            viewContent.DesignerCodeFileContent = GetTextEditorCode();

            PythonParser     parser = new PythonParser();
            ICompilationUnit parserCompilationUnit = parser.Parse(new DefaultProjectContent(), fileName, GetTextEditorCode());
            ParseInformation parseInfo             = new ParseInformation(parserCompilationUnit);

            generator.ParseInfoToReturnFromParseFileMethod = parseInfo;

            AfterSetUpFixture();
        }
コード例 #16
0
        public void WixDocumentGetXmlWithSpaces()
        {
            MockTextEditorOptions options = new MockTextEditorOptions();

            options.ConvertTabsToSpaces = true;
            options.IndentationSize     = 4;

            WixTextWriter wixWriter = new WixTextWriter(options);

            string outputXml   = dialogElement.GetXml(wixWriter);
            string expectedXml =
                "<Dialog Id=\"id\" Height=\"270\" Width=\"370\" Title=\"title\">\r\n" +
                "    <Control />\r\n" +
                "</Dialog>";

            Assert.AreEqual(expectedXml, outputXml);
        }
        public void SetUpFixture()
        {
            AvalonEdit.TextEditor textEditor = new AvalonEdit.TextEditor();
            document        = textEditor.Document;
            textEditor.Text = GetTextEditorCode();

            RubyParser         parser         = new RubyParser();
            MockProjectContent projectContent = new MockProjectContent();
            MockProject        project        = new MockProject();

            project.RootNamespace  = "RootNamespace";
            projectContent.Project = project;
            ICompilationUnit compilationUnit = parser.Parse(projectContent, @"test.py", document.Text);

            using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                IEventBindingService eventBindingService = new MockEventBindingService(host);
                Form form = (Form)host.RootComponent;
                form.ClientSize = new Size(200, 300);

                PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                namePropertyDescriptor.SetValue(form, "MainForm");

                // Add picture box
                PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
                pictureBox.Location = new Point(0, 0);
                pictureBox.Image    = new Bitmap(10, 10);
                pictureBox.Size     = new Size(100, 120);
                pictureBox.TabIndex = 0;
                form.Controls.Add(pictureBox);

                MockTextEditorOptions options = new MockTextEditorOptions();
                options.ConvertTabsToSpaces = true;
                options.IndentationSize     = 4;

                DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                using (serializationManager.CreateSession()) {
                    AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
                    RubyDesignerGenerator     generator  = new RubyDesignerGenerator(options);
                    generator.Merge(host, docAdapter, compilationUnit, serializationManager);
                }
            }
        }
コード例 #18
0
        public void Init()
        {
            WixProject project = WixBindingTestsHelper.CreateEmptyWixProject();

            document = new WixDocument(project, new DefaultFileLoader());
            string xml = "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'><Product Name='MySetup'></Product></Wix>";

            document.LoadXml(xml);

            MockTextEditorOptions options = new MockTextEditorOptions();

            options.ConvertTabsToSpaces = false;
            options.IndentationSize     = 1;

            WixTextWriter wixWriter = new WixTextWriter(options);

            xmlBuilder = new StringBuilder();
            xmlWriter  = wixWriter.Create(new StringWriter(xmlBuilder));
            document.Save(xmlWriter);
        }
        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()
        {
            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);
        }
コード例 #21
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);
        }
コード例 #22
0
        public void IndentLinesIndentsChildElementUsingTextEditorIndentationString()
        {
            document.Text =
                "<root>\r\n" +
                "<child>\r\n" +
                "</child>\r\n" +
                "</root>";

            string expectedText =
                "<root>\r\n" +
                "    <child>\r\n" +
                "    </child>\r\n" +
                "</root>";

            MockTextEditorOptions options = new MockTextEditorOptions();

            options.IndentationString = "    ";
            textEditor.Options        = options;

            formattingStrategy.IndentLines(textEditor, 1, 4);

            Assert.AreEqual(expectedText, document.Text);
        }
コード例 #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);

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

            int selectionStart  = 9;
            int selectionLength = 15;

            textEditor.Select(selectionStart, selectionLength);

            formattingStrategy.SurroundSelectionWithComment(textEditor);
        }
コード例 #24
0
        public void Init()
        {
            MockTextEditorOptions options = new MockTextEditorOptions();

            generator = new PythonDesignerGenerator(options);
        }
コード例 #25
0
		void CreateTestableScriptingDesignerGenerator()
		{
			MockTextEditorOptions options = new MockTextEditorOptions();
			generator = new TestableScriptingDesignerGenerator(options);
		}
コード例 #26
0
 public void Init()
 {
     options = new MockTextEditorOptions();
 }
コード例 #27
0
        void CreateTestableScriptingDesignerGenerator()
        {
            MockTextEditorOptions options = new MockTextEditorOptions();

            generator = new TestableScriptingDesignerGenerator(options);
        }