Skip to content

Commit b9881f0

Browse files
committed
Add a unit test that makes sure SA0002 is reported for a missing or empty settings file
1 parent 62ba4fe commit b9881f0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0002UnitTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ public async Task TestInvalidSettingsAsync()
5858
await this.VerifyCSharpDiagnosticAsync(TestCode, expected, CancellationToken.None).ConfigureAwait(false);
5959
}
6060

61+
[Fact]
62+
public async Task TestEmptySettingsAsync()
63+
{
64+
// The test infrastructure will not add a settings file to the compilation if GetSettings returns null or an empty string.
65+
// This is why we set settings to a simple whitespace character.
66+
this.settings = " ";
67+
68+
// This diagnostic is reported without a location
69+
DiagnosticResult expected = this.CSharpDiagnostic();
70+
71+
await this.VerifyCSharpDiagnosticAsync(TestCode, expected, CancellationToken.None).ConfigureAwait(false);
72+
}
73+
6174
/// <inheritdoc/>
6275
protected override string GetSettings()
6376
{

0 commit comments

Comments
 (0)