~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/BookmarkActionsTests.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// BookmarkTests.cs
3
 
//  
4
 
// Author:
5
 
//       Mike Krüger <mkrueger@xamarin.com>
6
 
// 
7
 
// Copyright (c) 2011 Xamarin Inc. (http://xamarin.com)
8
 
// 
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:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
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
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using NUnit.Framework;
29
 
using System.Linq;
30
 
 
31
 
namespace Mono.TextEditor.Tests.Actions
32
 
{
33
 
        [TestFixture()]
34
 
        public class BookmarkActionsTests : TextEditorTestBase
35
 
        {
36
 
                internal static TextEditorData Create (string text)
37
 
                {
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;
43
 
                        } else {
44
 
                                result.Document.Text = text;
45
 
                        }
46
 
                        for (int i = 1; i <= result.Document.LineCount; i++) {
47
 
                                if (result.Document.GetLineText (i).StartsWith ("@"))
48
 
                                        result.GetLine (i).IsBookmarked = true;
49
 
                        }
50
 
                        return result;
51
 
                        
52
 
                }
53
 
                
54
 
                [Test()]
55
 
                public void TestPrevBookmark ()
56
 
                {
57
 
                        TextEditorData data = Create (@"1
58
 
@2
59
 
3
60
 
@4
61
 
5
62
 
@6
63
 
7
64
 
$8
65
 
9");
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);
74
 
                }
75
 
                
76
 
                [Test()]
77
 
                public void TestNextBookmark ()
78
 
                {
79
 
                        TextEditorData data = Create (@"1
80
 
@2
81
 
3
82
 
@4
83
 
5
84
 
@6
85
 
7
86
 
$8
87
 
9");
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);
96
 
                }
97
 
 
98
 
                [Test()]
99
 
                public void TestClearAll ()
100
 
                {
101
 
                        TextEditorData data = Create (@"1
102
 
@2
103
 
3
104
 
@4
105
 
5
106
 
@6
107
 
7
108
 
$8
109
 
9");
110
 
                        Assert.AreEqual (3, data.Lines.Count (l => l.IsBookmarked));
111
 
                        BookmarkActions.ClearAll (data);
112
 
                        Assert.AreEqual (0, data.Lines.Count (l => l.IsBookmarked));
113
 
                }
114
 
        }
115
 
}