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

« back to all changes in this revision

Viewing changes to tests/UnitTests/MonoDevelop.Ide.Gui/SearchPopupWindowTests.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
// SearchPopupWindowTests.cs
 
3
//
 
4
// Author:
 
5
//       Mike Krüger <mkrueger@xamarin.com>
 
6
//
 
7
// Copyright (c) 2012 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
using MonoDevelop.Components.MainToolbar;
 
27
using NUnit.Framework;
 
28
 
 
29
namespace MonoDevelop.Ide.Gui
 
30
{
 
31
        [TestFixture]
 
32
        public class SearchPopupWindowTests
 
33
        {
 
34
                [Test]
 
35
                public void TestEmptyPattern ()
 
36
                {
 
37
                        var pattern = SearchPopupSearchPattern.ParsePattern ("");
 
38
                        Assert.AreEqual (new SearchPopupSearchPattern (null, ""), pattern);
 
39
                }
 
40
 
 
41
                [Test]
 
42
                public void TestSimplePattern ()
 
43
                {
 
44
                        var pattern = SearchPopupSearchPattern.ParsePattern ("foo");
 
45
                        Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", -1), pattern);
 
46
                }
 
47
 
 
48
                [Test]
 
49
                public void TestLineNumber ()
 
50
                {
 
51
                        var pattern = SearchPopupSearchPattern.ParsePattern ("foo:4711");
 
52
                        Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", 4711), pattern);
 
53
                }
 
54
 
 
55
                [Test]
 
56
                public void TestLineNumberAndColumn ()
 
57
                {
 
58
                        var pattern = SearchPopupSearchPattern.ParsePattern ("foo:4711,1174");
 
59
                        Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", 4711, 1174), pattern);
 
60
                }
 
61
 
 
62
                [Test]
 
63
                public void TestLineNumberAndColumnFormat2 ()
 
64
                {
 
65
                        var pattern = SearchPopupSearchPattern.ParsePattern ("foo:4711:1174");
 
66
                        Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", 4711, 1174), pattern);
 
67
                }
 
68
 
 
69
                [Test]
 
70
                public void TestLineNumberAndMissingColumn ()
 
71
                {
 
72
                        var pattern = SearchPopupSearchPattern.ParsePattern (":4711:");
 
73
                        Assert.AreEqual (new SearchPopupSearchPattern (null, null, 4711, 0), pattern);
 
74
                }
 
75
 
 
76
                [Test]
 
77
                public void TestEmptySecondPart ()
 
78
                {
 
79
                        var pattern = SearchPopupSearchPattern.ParsePattern ("foo:");
 
80
                        Assert.AreEqual (new SearchPopupSearchPattern ("foo", "", -1), pattern);
 
81
                }
 
82
 
 
83
                [Test]
 
84
                public void TestEmptyThirdPart ()
 
85
                {
 
86
                        var pattern = SearchPopupSearchPattern.ParsePattern ("foo:bar:");
 
87
                        Assert.AreEqual (new SearchPopupSearchPattern ("foo", "bar", 0), pattern);
 
88
                }
 
89
 
 
90
                
 
91
                [Test]
 
92
                public void TestLineNumberOnly ()
 
93
                {
 
94
                        var pattern = SearchPopupSearchPattern.ParsePattern (":4711");
 
95
                        Assert.AreEqual (new SearchPopupSearchPattern (null, null, 4711), pattern);
 
96
                }
 
97
 
 
98
                [Test]
 
99
                public void TestLineNumberAndColumnOnly ()
 
100
                {
 
101
                        var pattern = SearchPopupSearchPattern.ParsePattern (":5,8");
 
102
                        Assert.AreEqual (new SearchPopupSearchPattern (null, null, 5, 8), pattern);
 
103
                }
 
104
 
 
105
                [Test]
 
106
                public void TestLineNumberAndColumnOnlySyntax2 ()
 
107
                {
 
108
                        var pattern = SearchPopupSearchPattern.ParsePattern (":5:8");
 
109
                        Assert.AreEqual (new SearchPopupSearchPattern (null, null, 5, 8), pattern);
 
110
                }
 
111
 
 
112
                [Test]
 
113
                public void TestCategory ()
 
114
                {
 
115
                        var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo");
 
116
                        Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", -1), pattern);
 
117
                }
 
118
 
 
119
                [Test]
 
120
                public void TestCategoryAndLineNumber ()
 
121
                {
 
122
                        var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo:1337");
 
123
                        Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", 1337), pattern);
 
124
                }
 
125
 
 
126
                [Test]
 
127
                public void TestCategoryAndLineNumberAndColumn ()
 
128
                {
 
129
                        var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo:1337:5");
 
130
                        Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", 1337, 5), pattern);
 
131
                }
 
132
 
 
133
                [Test]
 
134
                public void TestInvalidLineNumber ()
 
135
                {
 
136
                        var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo:bar");
 
137
                        Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", 0), pattern);
 
138
                }
 
139
        }
 
140
}
 
141