Skip to content

Commit f609b96

Browse files
committed
Added additional test to cover all code paths
1 parent 5754710 commit f609b96

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1217UnitTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,54 @@ public static void TestMethod()
297297
await this.VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
298298
}
299299

300+
/// <summary>
301+
/// Verify that the systemUsingDirectivesFirst setting is honored correctly when using multiple static system usings.
302+
/// </summary>
303+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
304+
[Fact]
305+
[WorkItem(2163, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2163")]
306+
public async Task VerifyMultipleStaticSystemUsingDirectivesAsync()
307+
{
308+
this.useSystemUsingDirectivesFirst = true;
309+
310+
var testCode = @"
311+
using static System.Math;
312+
using static System.Activator;
313+
314+
namespace MyNamespace
315+
{
316+
public static class TestClass
317+
{
318+
public static void TestMethod()
319+
{
320+
}
321+
}
322+
}
323+
";
324+
325+
var fixedTestCode = @"
326+
using static System.Activator;
327+
using static System.Math;
328+
329+
namespace MyNamespace
330+
{
331+
public static class TestClass
332+
{
333+
public static void TestMethod()
334+
{
335+
}
336+
}
337+
}
338+
";
339+
340+
DiagnosticResult[] expectedDiagnostic =
341+
{
342+
Diagnostic().WithLocation(2, 1).WithArguments("System.Math", "System.Activator"),
343+
};
344+
345+
await this.VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
346+
}
347+
300348
private static DiagnosticResult Diagnostic()
301349
=> StyleCopCodeFixVerifier<SA1217UsingStaticDirectivesMustBeOrderedAlphabetically, UsingCodeFixProvider>.Diagnostic();
302350

0 commit comments

Comments
 (0)