Skip to content

Commit 1e5a42c

Browse files
committed
Add regression tests for #436
1 parent d6c83c4 commit 1e5a42c

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,56 @@ public interface FileOpenDialog111
185185
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
186186
}
187187

188+
[Fact]
189+
public async Task TestInterfaceDeclarationDoesNotStartWithIWithConflictAsync()
190+
{
191+
string testCode = @"
192+
public interface Foo
193+
{
194+
}
195+
196+
public interface IFoo { }";
197+
string fixedCode = @"
198+
public interface IFoo1
199+
{
200+
}
201+
202+
public interface IFoo { }";
203+
204+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(2, 18);
205+
206+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
207+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
208+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
209+
}
210+
211+
[Fact]
212+
public async Task TestInterfaceDeclarationDoesNotStartWithIWithConflictInAnotherAssemblyAsync()
213+
{
214+
string testCode = @"
215+
namespace System
216+
{
217+
public interface Disposable
218+
{
219+
}
220+
}
221+
";
222+
string fixedCode = @"
223+
namespace System
224+
{
225+
public interface IDisposable1
226+
{
227+
}
228+
}
229+
";
230+
231+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(4, 22);
232+
233+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
234+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
235+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
236+
}
237+
188238
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
189239
{
190240
yield return new SA1302InterfaceNamesMustBeginWithI();

0 commit comments

Comments
 (0)