2
// SearchPopupWindowTests.cs
5
// Mike Krüger <mkrueger@xamarin.com>
7
// Copyright (c) 2012 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
26
using MonoDevelop.Components.MainToolbar;
27
using NUnit.Framework;
29
namespace MonoDevelop.Ide.Gui
32
public class SearchPopupWindowTests
35
public void TestEmptyPattern ()
37
var pattern = SearchPopupSearchPattern.ParsePattern ("");
38
Assert.AreEqual (new SearchPopupSearchPattern (null, ""), pattern);
42
public void TestSimplePattern ()
44
var pattern = SearchPopupSearchPattern.ParsePattern ("foo");
45
Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", -1), pattern);
49
public void TestLineNumber ()
51
var pattern = SearchPopupSearchPattern.ParsePattern ("foo:4711");
52
Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", 4711), pattern);
56
public void TestLineNumberAndColumn ()
58
var pattern = SearchPopupSearchPattern.ParsePattern ("foo:4711,1174");
59
Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", 4711, 1174), pattern);
63
public void TestLineNumberAndColumnFormat2 ()
65
var pattern = SearchPopupSearchPattern.ParsePattern ("foo:4711:1174");
66
Assert.AreEqual (new SearchPopupSearchPattern (null, "foo", 4711, 1174), pattern);
70
public void TestLineNumberAndMissingColumn ()
72
var pattern = SearchPopupSearchPattern.ParsePattern (":4711:");
73
Assert.AreEqual (new SearchPopupSearchPattern (null, null, 4711, 0), pattern);
77
public void TestEmptySecondPart ()
79
var pattern = SearchPopupSearchPattern.ParsePattern ("foo:");
80
Assert.AreEqual (new SearchPopupSearchPattern ("foo", "", -1), pattern);
84
public void TestEmptyThirdPart ()
86
var pattern = SearchPopupSearchPattern.ParsePattern ("foo:bar:");
87
Assert.AreEqual (new SearchPopupSearchPattern ("foo", "bar", 0), pattern);
92
public void TestLineNumberOnly ()
94
var pattern = SearchPopupSearchPattern.ParsePattern (":4711");
95
Assert.AreEqual (new SearchPopupSearchPattern (null, null, 4711), pattern);
99
public void TestLineNumberAndColumnOnly ()
101
var pattern = SearchPopupSearchPattern.ParsePattern (":5,8");
102
Assert.AreEqual (new SearchPopupSearchPattern (null, null, 5, 8), pattern);
106
public void TestLineNumberAndColumnOnlySyntax2 ()
108
var pattern = SearchPopupSearchPattern.ParsePattern (":5:8");
109
Assert.AreEqual (new SearchPopupSearchPattern (null, null, 5, 8), pattern);
113
public void TestCategory ()
115
var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo");
116
Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", -1), pattern);
120
public void TestCategoryAndLineNumber ()
122
var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo:1337");
123
Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", 1337), pattern);
127
public void TestCategoryAndLineNumberAndColumn ()
129
var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo:1337:5");
130
Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", 1337, 5), pattern);
134
public void TestInvalidLineNumber ()
136
var pattern = SearchPopupSearchPattern.ParsePattern ("cat:foo:bar");
137
Assert.AreEqual (new SearchPopupSearchPattern ("cat", "foo", 0), pattern);