From 428eee9ae26302efc0098acd2e286ea7f5597a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Sun, 24 Feb 2013 08:26:27 +0100 Subject: [PATCH] Added more semantic highlighting unit tests. --- .../Analysis/SemanticHighlightingTests.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs index 9ef7d783b1..c6d29c3930 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs @@ -152,11 +152,23 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis TestColor (@"delegate void $Class();", delegateTypeColor); } + [Test] + public void TestTypeParameter() + { + TestColor (@"class Class<$T> where $T : class { void Foo<$Tx> () where $Tx : $T {} } ", typeParameterTypeColor); + } + [Test] public void TestMethodDeclaration() { TestColor (@"class Class { void $Foo () {} }", methodDeclarationColor); } + + [Test] + public void TestMethodCall() + { + TestColor (@"class Class { void Foo () { $Foo (); } }", methodCallColor); + } [Test] public void TestFieldDeclaration() @@ -164,12 +176,24 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis TestColor (@"class Class { int $foo; }", fieldDeclarationColor); } + [Test] + public void TestFieldAccess() + { + TestColor (@"using System; class Class { int Bar; void Foo () { Console.WriteLine ($Bar); } }", fieldAccessColor); + } + [Test] public void TestPropertyDeclaration() { TestColor (@"class Class { int $Foo { get; set; } }", propertyDeclarationColor); } + [Test] + public void TestPropertyAccess() + { + TestColor (@"using System; class Class { int Bar {get; set; } void Foo () { Console.WriteLine ($Bar); } }", propertyAccessColor); + } + [Test] public void TestEventDeclaration() { @@ -182,11 +206,23 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis TestColor (@"class Class { event System.EventHandler $Foo { add {} remove {} } }", eventDeclarationColor); } + + [Test] + public void TestEventAccess() + { + TestColor (@"class Class { event System.EventHandler Bar; void Foo () { $Bar += (o, s) => {}; } }", eventAccessColor); + } + [Test] public void TestMethodParameterDeclaration() { TestColor (@"class Class { void Foo (int $a, string $b) {} }", parameterDeclarationColor); } + [Test] + public void TestMethodParameterAccess() + { + TestColor (@"class Class { void Foo (int a, string b) { int c = $a + $b;} }", parameterAccessColor); + } [Test] public void TestIndexerParameterDeclaration() @@ -194,6 +230,24 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis TestColor (@"class Class { int this[int $a, string $b] { get { } } }", parameterDeclarationColor); } + [Test] + public void TestIndexerParameterAccess() + { + TestColor (@"class Class { int this[int a, string b] { get { return $a + $b; } } }", parameterAccessColor); + } + + [Test] + public void TestVariableDeclaration() + { + TestColor (@"class Class { void Test () { int $bar, $foo; } }", variableDeclarationColor); + } + + [Test] + public void TestVariableAccess() + { + TestColor (@"class Class { void Test () { int bar, foo; int c = $foo + $bar; } }", variableAccessColor); + } + [Test] public void TestValueKeywordInPropertySetter() {