2
// PreProcessorTests.cs
5
// Mike Krüger <mkrueger@xamarin.com>
7
// Copyright (c) 2011 Xamarin Inc.
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
27
using NUnit.Framework;
29
namespace ICSharpCode.NRefactory.CSharp.CodeCompletion
31
public class PreProcessorTests: TestBase
34
public void TestPreProcessorContext ()
36
CodeCompletionBugTests.CombinedProviderTest (@"$#$", provider => {
37
Assert.IsNotNull (provider.Find ("if"), "directive 'if' not found.");
38
Assert.IsNotNull (provider.Find ("region"), "directive 'region' not found.");
43
public void TestPreProcessorContext2 ()
45
CodeCompletionBugTests.CombinedProviderTest (@"// $#$", provider => {
46
Assert.IsNull (provider.Find ("if"), "directive 'if' not found.");
47
Assert.IsNull (provider.Find ("region"), "directive 'region' not found.");
53
public void TestIfContext ()
55
CodeCompletionBugTests.CombinedProviderTest (@"$#if D$", provider => {
56
Assert.IsNotNull (provider.Find ("DEBUG"), "define 'DEBUG' not found.");
61
public void TestIfInsideComment ()
63
CodeCompletionBugTests.CombinedProviderTest (@"$// #if D$", provider => {
64
Assert.IsNull (provider.Find ("DEBUG"), "define 'DEBUG' found.");
69
/// Bug 10051 - Cannot type negate conditional
72
public void TestBug10051 ()
74
var provider = CodeCompletionBugTests.CreateProvider (@"$#if $");
75
Assert.IsTrue (provider == null || provider.Count == 0);
77
provider = CodeCompletionBugTests.CreateProvider (@"$#if $", true);
78
Assert.IsNotNull (provider.Find ("DEBUG"), "define 'DEBUG' not found.");
82
///Bug 10079 - Cannot type && conditional
85
public void TestBug10079 ()
87
var provider = CodeCompletionBugTests.CreateProvider (@"$#if TRUE &$");
88
Assert.IsTrue (provider == null || provider.Count == 0);
90
provider = CodeCompletionBugTests.CreateProvider (@"$#if TRUE && $", true);
91
Assert.IsNotNull (provider.Find ("DEBUG"), "define 'DEBUG' not found.");
96
/// Bug 10294 - Comments in preprocessor directives are not handler correctly
99
public void TestBug10294 ()
101
var provider = CodeCompletionBugTests.CreateProvider (@"$#if TRUE // D$",true);
102
Assert.IsTrue (provider == null || provider.Count == 0);