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,24 +152,48 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
TestColor (@"delegate void $Class();", delegateTypeColor); TestColor (@"delegate void $Class();", delegateTypeColor);
} }
[Test]
public void TestTypeParameter()
{
TestColor (@"class Class<$T> where $T : class { void Foo<$Tx> () where $Tx : $T {} } ", typeParameterTypeColor);
}
[Test] [Test]
public void TestMethodDeclaration() public void TestMethodDeclaration()
{ {
TestColor (@"class Class { void $Foo () {} }", methodDeclarationColor); TestColor (@"class Class { void $Foo () {} }", methodDeclarationColor);
} }
[Test]
public void TestMethodCall()
{
TestColor (@"class Class { void Foo () { $Foo (); } }", methodCallColor);
}
[Test] [Test]
public void TestFieldDeclaration() public void TestFieldDeclaration()
{ {
TestColor (@"class Class { int $foo; }", fieldDeclarationColor); TestColor (@"class Class { int $foo; }", fieldDeclarationColor);
} }
[Test]
public void TestFieldAccess()
{
TestColor (@"using System; class Class { int Bar; void Foo () { Console.WriteLine ($Bar); } }", fieldAccessColor);
}
[Test] [Test]
public void TestPropertyDeclaration() public void TestPropertyDeclaration()
{ {
TestColor (@"class Class { int $Foo { get; set; } }", propertyDeclarationColor); 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] [Test]
public void TestEventDeclaration() public void TestEventDeclaration()
{ {
@ -182,11 +206,23 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
TestColor (@"class Class { event System.EventHandler $Foo { add {} remove {} } }", eventDeclarationColor); 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] [Test]
public void TestMethodParameterDeclaration() public void TestMethodParameterDeclaration()
{ {
TestColor (@"class Class { void Foo (int $a, string $b) {} }", parameterDeclarationColor); 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] [Test]
public void TestIndexerParameterDeclaration() public void TestIndexerParameterDeclaration()
@ -194,6 +230,24 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
TestColor (@"class Class { int this[int $a, string $b] { get { } } }", parameterDeclarationColor); 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] [Test]
public void TestValueKeywordInPropertySetter() public void TestValueKeywordInPropertySetter()
{ {

Loading…
Cancel
Save