示例#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);
                CommentHelper.CommentOrUncommentBlock(view, true);
            });

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

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

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

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

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

            Assert.AreEqual(expected, view.GetText());
        }
示例#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'"));
                CommentHelper.CommentOrUncommentBlock(view, 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());
        }
示例#4
0
        public void TestCommentWhiteSpaceLine()
        {
            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());
        }
示例#5
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'");
                CommentHelper.CommentOrUncommentBlock(view, false);
            });

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