Skip to content

Commit 27d36be

Browse files
committed
Add tests for containing type and contained member conflicts
1 parent 92ad652 commit 27d36be

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1302UnitTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,27 @@ public interface IFoo { }";
208208
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
209209
}
210210

211+
[Fact]
212+
public async Task TestInterfaceDeclarationDoesNotStartWithIWithMemberConflictAsync()
213+
{
214+
string testCode = @"
215+
public interface Foo
216+
{
217+
int IFoo { get; }
218+
}";
219+
string fixedCode = @"
220+
public interface IFoo1
221+
{
222+
int IFoo { get; }
223+
}";
224+
225+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(2, 18);
226+
227+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
228+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
229+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
230+
}
231+
211232
[Fact]
212233
public async Task TestNestedInterfaceDeclarationDoesNotStartWithIWithConflictAsync()
213234
{
@@ -237,6 +258,31 @@ public interface IFoo { }
237258
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
238259
}
239260

261+
[Fact]
262+
public async Task TestNestedInterfaceDeclarationDoesNotStartWithIWithContainingTypeConflictAsync()
263+
{
264+
string testCode = @"
265+
public class IFoo
266+
{
267+
public interface Foo
268+
{
269+
}
270+
}";
271+
string fixedCode = @"
272+
public class IFoo
273+
{
274+
public interface IFoo1
275+
{
276+
}
277+
}";
278+
279+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(4, 22);
280+
281+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
282+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
283+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
284+
}
285+
240286
[Fact]
241287
public async Task TestNestedInterfaceDeclarationDoesNotStartWithIWithNonInterfaceConflictAsync()
242288
{

0 commit comments

Comments
 (0)