Skip to content

Commit 91d82e3

Browse files
committed
Add a test for SA0002 when deserialization throws JsonParseException
Previously we were testing for cases where InvalidSettingsException was thrown, but not for the case where the JSON syntax was invalid. This commit adds a test covering the additional case.
1 parent 70e9c76 commit 91d82e3

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ public async Task TestInvalidSettingValueAsync()
7878
await this.VerifyCSharpDiagnosticAsync(TestCode, expected, CancellationToken.None).ConfigureAwait(false);
7979
}
8080

81+
[Fact]
82+
public async Task TestInvalidSettingSyntaxAsync()
83+
{
84+
// Missing the ':' between "companyName" and "name"
85+
this.settings = @"
86+
{
87+
""settings"": {
88+
""documentationRules"": {
89+
""companyName"" ""name""
90+
}
91+
}
92+
}
93+
";
94+
95+
// This diagnostic is reported without a location
96+
DiagnosticResult expected = this.CSharpDiagnostic();
97+
98+
await this.VerifyCSharpDiagnosticAsync(TestCode, expected, CancellationToken.None).ConfigureAwait(false);
99+
}
100+
81101
[Fact]
82102
public async Task TestEmptySettingsAsync()
83103
{

0 commit comments

Comments
 (0)