public void NoTextSelected() { document.TextContent = String.Empty; int selectionStartOffset = 0; int selectionEndOffset = 0; BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.IsNull(commentRegion, "Should not be a comment region for an empty document"); }
public void CursorJustOutsideCommentEnd() { document.TextContent = "<!-- -->"; int selectionStartOffset = 8; int selectionEndOffset = 8; BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.IsNull(commentRegion); }
public void FirstCharacterOfCommentStartSelected() { document.TextContent = "<!-- -->"; var selectionStartOffset = 0; var selectionEndOffset = 1; var expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, startOffset: 0, endOffset: 5); var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.AreEqual(expectedCommentRegion, commentRegion); }
public void EntireCommentAndExtraTextSelected() { document.TextContent = "a<!-- -->"; var selectionStartOffset = 0; var selectionEndOffset = 9; var expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, startOffset: 1, endOffset: 6); var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.AreEqual(expectedCommentRegion, commentRegion); }
public void CaretInsideCommentButNoSelectedText() { document.TextContent = "<!---->"; var selectionStartOffset = 4; var selectionEndOffset = 4; var expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, startOffset: 0, endOffset: 4); var commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.AreEqual(expectedCommentRegion, commentRegion); }
public void LastCharacterOfCommentEndSelected() { document.TextContent = "<!-- -->"; int selectionStartOffset = 7; int selectionEndOffset = 8; BlockCommentRegion expectedCommentRegion = new BlockCommentRegion(commentStart, commentEnd, 0, 5); BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.AreEqual(expectedCommentRegion, commentRegion); }
private void button3_Click(object sender, EventArgs e) { //ICSharpCode.TextEditor.Document.TextMarker t = new TextMarker(10, 30, TextMarkerType.SolidBlock); //ICSharpCode.TextEditor.Util.TextUtility.RegionMatches(txtEditor.Document,0,30,"#"); string commentStart = "#region"; string commentEnd = "#endregion"; IDocument document = txtEditor.Document;// new DocumentFactory().CreateDocument(); int selectionStartOffset = 0; int selectionEndOffset = selectionStartOffset + document.TextContent.Length; BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); }
public void TwoExistingBlockComments() { document.TextContent = "<a>\r\n" + "<!--<b></b>-->\r\n" + "\t<c></c>\r\n" + "<!--<d></d>-->\r\n" + "</a>"; string selectedText = "<c></c>"; int selectionStartOffset = document.TextContent.IndexOf(selectedText); int selectionEndOffset = selectionStartOffset + selectedText.Length; BlockCommentRegion commentRegion = ToggleBlockComment.FindSelectedCommentRegion(document, commentStart, commentEnd, selectionStartOffset, selectionEndOffset); Assert.IsNull(commentRegion); }