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()); }
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()); }
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()); }
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()); }
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()); }