5
// Mike Krüger <mkrueger@xamarin.com>
7
// Copyright (c) 2011 Xamarin Inc. (http://xamarin.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using NUnit.Framework;
31
namespace Mono.TextEditor.Tests.Actions
34
public class BookmarkActionsTests : TextEditorTestBase
36
internal static TextEditorData Create (string text)
38
TextEditorData result = new TextEditorData ();
39
if (text.IndexOf ('$') >= 0) {
40
int caretOffset = text.IndexOf ('$');
41
result.Document.Text = text.Remove (caretOffset, 1);
42
result.Caret.Offset = caretOffset;
44
result.Document.Text = text;
46
for (int i = 1; i <= result.Document.LineCount; i++) {
47
if (result.Document.GetLineText (i).StartsWith ("@"))
48
result.GetLine (i).IsBookmarked = true;
55
public void TestPrevBookmark ()
57
TextEditorData data = Create (@"1
66
BookmarkActions.GotoPrevious (data);
67
Assert.AreEqual (6, data.Caret.Line);
68
BookmarkActions.GotoPrevious (data);
69
Assert.AreEqual (4, data.Caret.Line);
70
BookmarkActions.GotoPrevious (data);
71
Assert.AreEqual (2, data.Caret.Line);
72
BookmarkActions.GotoPrevious (data);
73
Assert.AreEqual (6, data.Caret.Line);
77
public void TestNextBookmark ()
79
TextEditorData data = Create (@"1
88
BookmarkActions.GotoNext (data);
89
Assert.AreEqual (2, data.Caret.Line);
90
BookmarkActions.GotoNext (data);
91
Assert.AreEqual (4, data.Caret.Line);
92
BookmarkActions.GotoNext (data);
93
Assert.AreEqual (6, data.Caret.Line);
94
BookmarkActions.GotoNext (data);
95
Assert.AreEqual (2, data.Caret.Line);
99
public void TestClearAll ()
101
TextEditorData data = Create (@"1
110
Assert.AreEqual (3, data.Lines.Count (l => l.IsBookmarked));
111
BookmarkActions.ClearAll (data);
112
Assert.AreEqual (0, data.Lines.Count (l => l.IsBookmarked));