Browse Source

Added more semantic highlighting unit tests.

pull/32/merge
Mike Krüger 13 years ago
parent
commit
428eee9ae2
  1. 54
      ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs

54
ICSharpCode.NRefactory.Tests/CSharp/Analysis/SemanticHighlightingTests.cs

@ -152,11 +152,23 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -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 @@ -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 @@ -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 @@ -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()
{

Loading…
Cancel
Save