1- using System . Globalization ;
21using System . Reflection ;
32using Microsoft . Extensions . Configuration ;
43using Serilog . Events ;
@@ -16,17 +15,18 @@ public class ConfigurationReaderTests
1615 public ConfigurationReaderTests ( )
1716 {
1817 _configurationReader = new ConfigurationReader (
19- JsonStringConfigSource . LoadSection ( "{ ' Serilog' : { } }" , "Serilog" ) ,
18+ JsonStringConfigSource . LoadSection ( "{ \" Serilog\" : { } }" , "Serilog" ) ,
2019 AssemblyFinder . ForSource ( ConfigurationAssemblySource . UseLoadedAssemblies ) ,
2120 new ConfigurationReaderOptions ( ) ) ;
2221 }
2322
2423 [ Fact ]
2524 public void WriteToSupportSimplifiedSyntax ( )
2625 {
26+ // language=json
2727 var json = """
2828 {
29- ' WriteTo' : [ ' LiterateConsole', ' DiagnosticTrace' ]
29+ " WriteTo" : [ " LiterateConsole", " DiagnosticTrace" ]
3030 }
3131 """ ;
3232
@@ -42,10 +42,11 @@ public void WriteToSupportSimplifiedSyntax()
4242 [ Fact ]
4343 public void WriteToSupportExpandedSyntaxWithoutArgs ( )
4444 {
45+ // language=json
4546 var json = """
4647 {
47- ' WriteTo' : [ {
48- ' Name': ' LiterateConsole'
48+ " WriteTo" : [ {
49+ " Name": " LiterateConsole"
4950 }]
5051 }
5152 """ ;
@@ -60,13 +61,14 @@ public void WriteToSupportExpandedSyntaxWithoutArgs()
6061 [ Fact ]
6162 public void WriteToSupportExpandedSyntaxWithArgs ( )
6263 {
64+ // language=json
6365 var json = """
6466 {
65- ' WriteTo' : [ {
66- ' Name': ' LiterateConsole' ,
67- ' Args' : {
68- ' outputTemplate': ' {Message}'
69- },
67+ " WriteTo" : [ {
68+ " Name": " LiterateConsole" ,
69+ " Args" : {
70+ " outputTemplate": " {Message}"
71+ }
7072 }]
7173 }
7274 """ ;
@@ -88,28 +90,29 @@ public void WriteToSupportExpandedSyntaxWithArgs()
8890 [ Fact ]
8991 public void WriteToSupportMultipleSinksOfTheSameKind ( )
9092 {
93+ // language=json
9194 var json = """
9295 {
93- ' WriteTo' : [
96+ " WriteTo" : [
9497 {
95- ' Name': ' LiterateConsole' ,
96- ' Args' : {
97- ' outputTemplate': ' {Message}'
98- },
98+ " Name": " LiterateConsole" ,
99+ " Args" : {
100+ " outputTemplate": " {Message}"
101+ }
99102 },
100- ' DiagnosticTrace'
103+ " DiagnosticTrace"
101104 ],
102- ' WriteTo:File1' : {
103- ' Name': ' File' ,
104- ' Args' : {
105- ' outputTemplate': ' {Message}'
106- },
105+ " WriteTo:File1" : {
106+ " Name": " File" ,
107+ " Args" : {
108+ " outputTemplate": " {Message}"
109+ }
107110 },
108- ' WriteTo:File2' : {
109- ' Name': ' File' ,
110- ' Args' : {
111- ' outputTemplate': ' {Message}'
112- },
111+ " WriteTo:File2" : {
112+ " Name": " File" ,
113+ " Args" : {
114+ " outputTemplate": " {Message}"
115+ }
113116 }
114117 }
115118 """ ;
@@ -129,9 +132,10 @@ public void WriteToSupportMultipleSinksOfTheSameKind()
129132 [ Fact ]
130133 public void Enrich_SupportSimplifiedSyntax ( )
131134 {
135+ // language=json
132136 var json = """
133137 {
134- ' Enrich' : [ ' FromLogContext', ' WithMachineName', ' WithThreadId' ]
138+ " Enrich" : [ " FromLogContext", " WithMachineName", " WithThreadId" ]
135139 }
136140 """ ;
137141
@@ -274,7 +278,18 @@ public void MixedMinimumLevelCorrectOneIsEnabledOnLogger(IConfigurationRoot root
274278 [ Fact ]
275279 public void NoConfigurationRootUsedStillValid ( )
276280 {
277- var section = JsonStringConfigSource . LoadSection ( "{ 'Nest': { 'Serilog': { 'MinimumLevel': 'Error' } } }" , "Nest" ) ;
281+ // language=json
282+ var json = """
283+ {
284+ "Nest": {
285+ "Serilog": {
286+ "MinimumLevel": "Error"
287+ }
288+ }
289+ }
290+ """ ;
291+
292+ var section = JsonStringConfigSource . LoadSection ( json , "Nest" ) ;
278293 var reader = new ConfigurationReader ( section . GetSection ( "Serilog" ) , AssemblyFinder . ForSource ( ConfigurationAssemblySource . UseLoadedAssemblies ) , new ConfigurationReaderOptions ( ) , section ) ;
279294 var loggerConfig = new LoggerConfiguration ( ) ;
280295
0 commit comments