Skip to content

Commit 3206848

Browse files
committed
Convert maintainability rules to the new test helpers
1 parent 604cfb5 commit 3206848

13 files changed

Lines changed: 498 additions & 621 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1119CSharp7UnitTests.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules
88
using StyleCop.Analyzers.Test.MaintainabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis,
13+
StyleCop.Analyzers.MaintainabilityRules.SA1119CodeFixProvider>;
1114

1215
public class SA1119CSharp7UnitTests : SA1119UnitTests
1316
{
@@ -31,7 +34,7 @@ public void Bar()
3134
}
3235
}";
3336

34-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
37+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3538
}
3639

3740
[Fact]
@@ -50,7 +53,7 @@ public void Bar()
5053
}
5154
}";
5255

53-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
56+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5457
}
5558

5659
[Fact]
@@ -73,14 +76,12 @@ public void Bar()
7376

7477
DiagnosticResult[] expected =
7578
{
76-
this.CSharpDiagnostic(DiagnosticId).WithLocation(5, 38),
77-
this.CSharpDiagnostic(ParenthesesDiagnosticId).WithLocation(5, 38),
78-
this.CSharpDiagnostic(ParenthesesDiagnosticId).WithLocation(5, 40),
79+
Diagnostic(DiagnosticId).WithLocation(5, 38),
80+
Diagnostic(ParenthesesDiagnosticId).WithLocation(5, 38),
81+
Diagnostic(ParenthesesDiagnosticId).WithLocation(5, 40),
7982
};
8083

81-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
82-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
83-
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
84+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
8485
}
8586
}
8687
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1400CSharp7UnitTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules
77
using System.Threading.Tasks;
88
using StyleCop.Analyzers.Test.MaintainabilityRules;
99
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.MaintainabilityRules.SA1400AccessModifierMustBeDeclared,
12+
StyleCop.Analyzers.MaintainabilityRules.SA1400CodeFixProvider>;
1013

1114
public class SA1400CSharp7UnitTests : SA1400UnitTests
1215
{
@@ -29,7 +32,7 @@ void LocalFunction()
2932
}
3033
";
3134

32-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
35+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3336
}
3437
}
3538
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1408CSharp7UnitTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules
77
using System.Threading.Tasks;
88
using StyleCop.Analyzers.Test.MaintainabilityRules;
99
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.MaintainabilityRules.SA1408ConditionalExpressionsMustDeclarePrecedence,
12+
StyleCop.Analyzers.MaintainabilityRules.SA1407SA1408CodeFixProvider>;
1013

1114
public class SA1408CSharp7UnitTests : SA1408UnitTests
1215
{
@@ -29,7 +32,7 @@ public void Bar()
2932
}
3033
}";
3134

32-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
35+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3336
}
3437
}
3538
}

0 commit comments

Comments
 (0)