Skip to content

Commit ef2c7af

Browse files
committed
More tests #94.
1 parent cdb6fc2 commit ef2c7af

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

ReflectionAnalyzers.Tests/REFL016UseNameofTests/ValidCode.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public class Generic<T>
127127
}
128128

129129
[Test]
130+
// ReSharper disable once InconsistentNaming
130131
public void IEnumeratorGetCurrent()
131132
{
132133
var testCode = @"
@@ -145,6 +146,54 @@ public void Meh(object value)
145146
AnalyzerAssert.Valid(Analyzer, testCode);
146147
}
147148

149+
[TestCase("GetMethod(\"add_Public\")")]
150+
[TestCase("GetMethod(\"remove_Public\")")]
151+
public void EventAccessors(string before)
152+
{
153+
var code = @"
154+
namespace RoslynSandbox
155+
{
156+
using System;
157+
using System.Reflection;
158+
159+
class Foo
160+
{
161+
public Foo()
162+
{
163+
var methodInfo = typeof(Foo).GetMethod(""add_Public"");
164+
}
165+
166+
public event EventHandler Public;
167+
}
168+
}".AssertReplace("GetMethod(\"add_Public\")", before);
169+
170+
AnalyzerAssert.Valid(Analyzer, ExpectedDiagnostic, code);
171+
}
172+
173+
[TestCase("GetMethod(\"get_Public\")")]
174+
[TestCase("GetMethod(\"set_Public\")")]
175+
public void PropertyAccessors(string before)
176+
{
177+
var code = @"
178+
namespace RoslynSandbox
179+
{
180+
using System;
181+
using System.Reflection;
182+
183+
class Foo
184+
{
185+
public Foo()
186+
{
187+
var methodInfo = typeof(Foo).GetMethod(""get_Public"");
188+
}
189+
190+
public int Public { get; set; }
191+
}
192+
}".AssertReplace("GetMethod(\"get_Public\")", before);
193+
194+
AnalyzerAssert.Valid(Analyzer, ExpectedDiagnostic, code);
195+
}
196+
148197
[Test]
149198
public void WhenThrowingArgumentException()
150199
{

0 commit comments

Comments
 (0)