File tree Expand file tree Collapse file tree
StyleCop.Analyzers/LightJson/Serialization Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+ namespace StyleCop . Analyzers . Test . LightJson
5+ {
6+ using global ::LightJson ;
7+ using global ::LightJson . Serialization ;
8+ using Xunit ;
9+
10+ public class JsonReaderTests
11+ {
12+ [ Fact ]
13+ public void TestKeyMatchesPreviousValue ( )
14+ {
15+ var jsonObject = JsonValue . Parse ( "{ \" x\" : \" value\" , \" value\" : \" value\" }" ) ;
16+ Assert . NotNull ( jsonObject ) ;
17+ Assert . Equal ( "value" , jsonObject [ "x" ] . AsString ) ;
18+ Assert . Equal ( "value" , jsonObject [ "value" ] . AsString ) ;
19+ Assert . Equal ( jsonObject [ "x" ] , jsonObject [ "value" ] ) ;
20+ }
21+
22+ [ Fact ]
23+ public void TestDuplicateKeys ( )
24+ {
25+ Assert . ThrowsAny < JsonParseException > ( ( ) => JsonValue . Parse ( "{ \" x\" : \" value\" , \" x\" : \" value\" }" ) ) ;
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change 235235 <Compile Include =" LayoutRules\SA1518UnitTests.cs" />
236236 <Compile Include =" LayoutRules\SA1519UnitTests.cs" />
237237 <Compile Include =" LayoutRules\SA1520UnitTests.cs" />
238+ <Compile Include =" LightJson\JsonReaderTests.cs" />
238239 <Compile Include =" LightJson\JsonValueTests.cs" />
239240 <Compile Include =" Lightup\AccessorDeclarationSyntaxExtensionsTests.cs" />
240241 <Compile Include =" Lightup\AutoWrapSeparatedSyntaxListTests.cs" />
Original file line number Diff line number Diff line change @@ -344,7 +344,7 @@ private JsonObject ReadObject(JsonObject jsonObject)
344344
345345 var key = this . ReadJsonKey ( ) ;
346346
347- if ( jsonObject . Contains ( key ) )
347+ if ( jsonObject . ContainsKey ( key ) )
348348 {
349349 throw new JsonParseException (
350350 ErrorType . DuplicateObjectKeys ,
You can’t perform that action at this time.
0 commit comments