Example #1
0
        public void TestCommentCurrentLine()
        {
            var editorTestToolset = new EditorTestToolset();
            var view = editorTestToolset.CreatePythonTextView(@"print 'hello'
print 'goodbye'
");


            editorTestToolset.UIThread.Invoke(() => {
                view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(0).Start);
                view.CommentOrUncommentBlock(true);
            });

            Assert.AreEqual(@"#print 'hello'
print 'goodbye'
",
                            view.GetText());

            editorTestToolset.UIThread.Invoke(() => {
                view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);
                view.CommentOrUncommentBlock(true);
            });

            Assert.AreEqual(@"#print 'hello'
#print 'goodbye'
",
                            view.GetText());
        }
Example #2
0
        public void TestUnComment()
        {
            var editorTestToolset = new EditorTestToolset();
            var view = editorTestToolset.CreatePythonTextView(@"#print 'hello'
#print 'goodbye'");

            editorTestToolset.UIThread.Invoke(() => {
                view.SelectAll();
                view.CommentOrUncommentBlock(false);
            });

            var expected = @"print 'hello'
print 'goodbye'";

            Assert.AreEqual(expected, view.GetText());
        }
Example #3
0
        public void TestCommentAfterCodeIsNotUncommented()
        {
            var editorTestToolset = new EditorTestToolset();
            var view = editorTestToolset.CreatePythonTextView(@"print 'hello' #comment that should stay a comment
#print 'still here' # another comment that should stay a comment
print 'goodbye'");

            editorTestToolset.UIThread.Invoke(() => {
                view.Select(0, view.GetText().IndexOf("print 'goodbye'"));
                view.CommentOrUncommentBlock(false);
            });

            Assert.AreEqual(@"print 'hello' #comment that should stay a comment
print 'still here' # another comment that should stay a comment
print 'goodbye'",
                            view.GetText());
        }
Example #4
0
        public void TestComment()
        {
            var editorTestToolset = new EditorTestToolset();
            var view = editorTestToolset.CreatePythonTextView(@"print 'hello'
print 'goodbye'
");

            editorTestToolset.UIThread.Invoke(() => {
                view.SelectAll();
                CommentHelper.CommentOrUncommentBlock(view, true);
            });

            Assert.AreEqual(@"#print 'hello'
#print 'goodbye'
",
                            view.GetText());
        }
Example #5
0
        public void TestCommentBlankLine()
        {
            var editorTestToolset = new EditorTestToolset();
            var view = editorTestToolset.CreatePythonTextView(@"print('hi')

print('bye')");

            editorTestToolset.UIThread.Invoke(() => {
                view.Caret.MoveTo(view.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);
                CommentHelper.CommentOrUncommentBlock(view, true);
            });

            Assert.AreEqual(@"print('hi')

print('bye')",
                            view.GetText());
        }
Example #6
0
        public void TestUnCommentIndented()
        {
            var editorTestToolset = new EditorTestToolset();
            var view = editorTestToolset.CreatePythonTextView(@"def f():
    #print 'hello'
    #print 'still here'
    print 'goodbye'");

            editorTestToolset.UIThread.Invoke(() => {
                view.Select(@"    #print 'hello'
    #print 'still here'");
                view.CommentOrUncommentBlock(false);
            });

            Assert.AreEqual(@"def f():
    print 'hello'
    print 'still here'
    print 'goodbye'",
                            view.GetText());
        }