Skip to content

Commit 8086ca4

Browse files
committed
Added additional test cases
1 parent 58cac53 commit 8086ca4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1306UnitTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public async Task TestThatDiagnosticIsReported_SingleFieldAsync(string modifiers
143143
string __gar;
144144
{0}
145145
string __Har;
146+
{0}
147+
string ___iar;
148+
{0}
149+
string ___Jar;
146150
}}";
147151

148152
DiagnosticResult[] expected =
@@ -151,6 +155,7 @@ public async Task TestThatDiagnosticIsReported_SingleFieldAsync(string modifiers
151155
this.CSharpDiagnostic().WithArguments("Dar").WithLocation(8, 8),
152156
this.CSharpDiagnostic().WithArguments("_Far").WithLocation(12, 8),
153157
this.CSharpDiagnostic().WithArguments("__Har").WithLocation(16, 8),
158+
this.CSharpDiagnostic().WithArguments("___Jar").WithLocation(20, 8),
154159
};
155160

156161
await this.VerifyCSharpDiagnosticAsync(string.Format(testCode, modifiers), expected, CancellationToken.None).ConfigureAwait(false);
@@ -171,6 +176,10 @@ public async Task TestThatDiagnosticIsReported_SingleFieldAsync(string modifiers
171176
string __gar;
172177
{0}
173178
string __har;
179+
{0}
180+
string ___iar;
181+
{0}
182+
string ___jar;
174183
}}";
175184

176185
await this.VerifyCSharpDiagnosticAsync(string.Format(fixedCode, modifiers), EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
@@ -226,7 +235,20 @@ public async Task TestFieldWithAllUnderscoresAsync()
226235
{
227236
var testCode = @"public class Foo
228237
{
238+
private string _ = ""bar"";
229239
private string __ = ""baz"";
240+
private string ___ = ""qux"";
241+
}";
242+
243+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
244+
}
245+
246+
[Fact]
247+
public async Task TestFieldWithTrailingUnderscoreAsync()
248+
{
249+
var testCode = @"public class Foo
250+
{
251+
private string someVar_ = ""bar"";
230252
}";
231253

232254
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);

0 commit comments

Comments
 (0)