2
// CodeCompletionCSharpTests.cs
5
// Mike KrĆ¼ger <mkrueger@novell.com>
7
// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
using NUnit.Framework;
32
namespace ICSharpCode.NRefactory.CSharp.CodeCompletion
35
public class CodeCompletionCSharpTests : TestBase
38
public void TestUsingDeclaration ()
40
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
49
Assert.IsNotNull (provider, "provider == null");
50
Assert.IsNotNull (provider.Find ("Test"), "namespace 'Test' not found.");
54
public void TestLocalVariableDeclaration ()
56
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
65
Assert.IsNotNull (provider, "provider == null");
66
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
70
public void TestObjectCreationExpression ()
72
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
80
Assert.IsNotNull (provider, "provider == null");
81
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
85
public void TestCastExpression ()
87
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
96
Assert.IsNotNull (provider, "provider == null");
97
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
101
public void TestThisReferenceExpression ()
103
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
111
Assert.IsNotNull (provider, "provider == null");
112
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
116
public void TestBaseReferenceExpression ()
118
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
134
Assert.IsNotNull (provider, "provider == null");
135
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
136
Assert.IsNull (provider.Find ("Test2"), "method 'Test2' found but shouldn't.");
140
public void TestConditionalExpression ()
142
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
152
Assert.IsNotNull (provider, "provider == null");
153
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
157
public void TestIndexerExpression ()
159
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
169
Assert.IsNotNull (provider, "provider == null");
170
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
174
public void TestInvocationExpression ()
176
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
180
static Test GetTest () {}
187
Assert.IsNotNull (provider, "provider == null");
188
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
192
public void TestParenthesizedExpression ()
194
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
203
Assert.IsNotNull (provider, "provider == null");
204
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
208
public void TestForeachLoopVariable ()
210
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
216
foreach (Test t in new string[] {""hello""})
220
Assert.IsNotNull (provider, "provider == null");
221
Assert.IsNotNull (provider.Find ("Test"), "method 'Test' not found.");
225
public void TestMethodAccess ()
227
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
231
public AClass TestMethod ()
244
Assert.IsNotNull (provider, "provider == null");
245
Assert.IsNotNull (provider.Find ("TestMethod"), "method 'TestMethod ' not found.");
249
public void TestFieldAccess ()
251
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
255
public AClass TestField;
266
Assert.IsNotNull (provider, "provider == null");
267
Assert.IsNotNull (provider.Find ("TestField"), "field 'TestField' not found.");
271
public void TestPropertyAccess ()
273
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
277
public AClass TestProperty { get { return null; } }
288
Assert.IsNotNull (provider, "provider == null");
289
Assert.IsNotNull (provider.Find ("TestProperty"), "property 'TestProperty' not found.");
293
public void TestAsCompletionContext ()
295
CompletionDataList provider = CodeCompletionBugTests.CreateProvider (
311
public void TestMethod (object test)
317
Assert.IsNotNull (provider, "provider == null");
318
Assert.IsNotNull (provider.Find ("A"), "class 'A' not found.");
319
Assert.IsNotNull (provider.Find ("C"), "class 'C' not found.");
320
Assert.IsNull (provider.Find ("B"), "class 'B' found, but shouldn't.");
321
Assert.IsNull (provider.Find ("Test"), "class 'Test' found, but shouldn't.");
327
public void TestLocalVariableNameContext ()
329
CompletionDataList provider = CodeCompletionBugTests.CreateCtrlSpaceProvider (
331
public class TestMyLongName
333
public void Method ()
338
Assert.IsNotNull (provider, "provider == null");
339
Assert.IsNotNull (provider.Find ("testMyLongName"), "name 'testMyLongName' not found.");
340
Assert.IsNotNull (provider.Find ("myLongName"), "name 'myLongName' not found.");
341
Assert.IsNotNull (provider.Find ("longName"), "name 'longName' not found.");
342
Assert.IsNotNull (provider.Find ("name"), "name 'name' not found.");