@@ -1036,6 +1036,31 @@ public static void JsonSerializerOptions_Default_IsReadOnly()
10361036 Assert . Same ( resolver , optionsSingleton . TypeInfoResolver ) ;
10371037 }
10381038
1039+ [ Fact ]
1040+ public static void JsonSerializerOptions_Web_MatchesConstructorWithJsonSerializerDefaults ( )
1041+ {
1042+ var options = new JsonSerializerOptions ( JsonSerializerDefaults . Web ) ;
1043+ JsonSerializerOptions optionsSingleton = JsonSerializerOptions . Web ;
1044+ JsonTestHelper . AssertOptionsEqual ( options , optionsSingleton ) ;
1045+ }
1046+
1047+ [ Fact ]
1048+ public static void JsonSerializerOptions_Web_ReturnsSameInstance ( )
1049+ {
1050+ Assert . Same ( JsonSerializerOptions . Web , JsonSerializerOptions . Web ) ;
1051+ }
1052+
1053+ [ Fact ]
1054+ public static void JsonSerializerOptions_Web_IsReadOnly ( )
1055+ {
1056+ var optionsSingleton = JsonSerializerOptions . Web ;
1057+ Assert . True ( optionsSingleton . IsReadOnly ) ;
1058+ Assert . Throws < InvalidOperationException > ( ( ) => optionsSingleton . PropertyNameCaseInsensitive = true ) ;
1059+ Assert . Throws < InvalidOperationException > ( ( ) => optionsSingleton . PropertyNamingPolicy = JsonNamingPolicy . CamelCase ) ;
1060+ Assert . Throws < InvalidOperationException > ( ( ) => optionsSingleton . NumberHandling = JsonNumberHandling . AllowReadingFromString ) ;
1061+ Assert . Throws < InvalidOperationException > ( ( ) => new JsonContext ( optionsSingleton ) ) ;
1062+ }
1063+
10391064 [ Theory ]
10401065 [ MemberData ( nameof ( GetInitialTypeInfoResolversAndExpectedChains ) ) ]
10411066 public static void TypeInfoResolverChain_SetTypeInfoResolver_ReturnsExpectedChain (
@@ -1253,7 +1278,7 @@ public static void DefaultSerializerOptions_General()
12531278 [ Fact ]
12541279 public static void PredefinedSerializerOptions_Web ( )
12551280 {
1256- var options = JsonSerializerOptions . Web ;
1281+ var options = new JsonSerializerOptions ( JsonSerializerDefaults . Web ) ;
12571282 Assert . True ( options . PropertyNameCaseInsensitive ) ;
12581283 Assert . Same ( JsonNamingPolicy . CamelCase , options . PropertyNamingPolicy ) ;
12591284 Assert . Equal ( JsonNumberHandling . AllowReadingFromString , options . NumberHandling ) ;
0 commit comments