Exemplo n.º 1
0
        public void TestBasicSnippetsTab(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                foreach (var snippet in BasicSnippets)
                {
                    TestOneTabSnippet(vs, snippet);

                    vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
                }
            }
        }
Exemplo n.º 2
0
        public void TestTestClassSnippetUnitTestImported(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                var snippet = new Snippet(
                    "testc",
                    "import unittest\r\n\r\nclass MyTestClass(unittest.TestCase):\r\n    def test_name(self):\r\n        self.fail(\"Not implemented\")\r\n",
                    new Declaration("mytest", "import unittest\r\n\r\nclass mytest(unittest.TestCase):\r\n    def test_name(self):\r\n        self.fail(\"Not implemented\")\r\n"),
                    new Declaration("quox", "import unittest\r\n\r\nclass mytest(unittest.TestCase):\r\n    def test_quox(self):\r\n        self.fail(\"Not implemented\")\r\n")
                    );

                TestOneInsertSnippetMoveCaret(vs, snippet, "Test", file: "imported.py", line: 2);

                vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
            }
        }
Exemplo n.º 3
0
        public void TestSurroundWithMultiline(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                foreach (var snippet in BasicSnippets)
                {
                    TestOneSurroundWithSnippet(
                        vs,
                        snippet,
                        "1\r\n    2\r\n    3",
                        "multiline.py"
                        );

                    vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
                }
            }
        }
Exemplo n.º 4
0
        public void TestPassSelectedIndented(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                var editor = vs.OpenItem("SnippetsTest", "indented.py");
                editor.MoveCaret(2, 5);
                editor.Invoke(() => editor.TextView.Caret.EnsureVisible());
                editor.SetFocus();

                Keyboard.Type("class\t");
                editor.WaitForText("if True:\r\n    class ClassName(object):\r\n        pass\r\n    pass");
                Keyboard.Type("\r");
                Keyboard.Type("42");
                editor.WaitForText("if True:\r\n    class ClassName(object):\r\n        42\r\n    pass");

                vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
            }
        }
Exemplo n.º 5
0
        public void TestPassSelected(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            var snippet = new Snippet(
                "class",
                "class ClassName(object):\r\n    pass",
                new Declaration("myclass", "class myclass(object):\r\n    pass"),
                new Declaration("(base)", "class myclass(base):\r\n    pass")
                );

            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                var editor = TestOneTabSnippet(vs, snippet);

                Keyboard.Type("42");
                editor.WaitForText("class myclass(base):\r\n    42");

                vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Starting a nested session should dismiss the initial session
        /// </summary>
        public void TestNestedSession(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                var editor = vs.OpenItem("SnippetsTest", "app.py");
                editor.MoveCaret(1, 1);
                editor.Invoke(() => editor.TextView.Caret.EnsureVisible());
                editor.SetFocus();

                // start session
                Keyboard.Type("if\t");
                // select inserted pass
                editor.Select(2, 5, 4);
                // start nested session
                vs.ExecuteCommand("Edit.SurroundWith");
                Keyboard.Type("if\t");
                editor.WaitForText("if True:\r\n    if True:\r\n        pass");

                vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
            }
        }
Exemplo n.º 7
0
        public void TestInsertSnippetEmptySelectionNonEmptyLine(PythonVisualStudioApp app, PythonProjectGenerator pg)
        {
            using (var vs = pg.Generate(BasicProjectDefinition).ToVs(app)) {
                foreach (var snippet in BasicSnippets)
                {
                    Console.WriteLine("Testing: {0}", snippet.Shortcut);
                    var editor = vs.OpenItem("SnippetsTest", "nonempty.py");
                    editor.MoveCaret(1, 1);
                    editor.Invoke(() => editor.TextView.Caret.EnsureVisible());
                    editor.SetFocus();

                    vs.ExecuteCommand("Edit.InsertSnippet");
                    Keyboard.Type("Python\t");

                    Keyboard.Type(snippet.Shortcut + "\t");
                    editor.WaitForText(snippet.Expected.Replace("$body$", "pass") + "\r\n" + "42");

                    vs.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
                }
            }
        }