@@ -24,7 +24,7 @@ public class EasyLoggingStarterTest
2424 private const string ConfigPath = "/some-path/config.json" ;
2525 private const string AnotherConfigPath = "/another/path" ;
2626 private static readonly string s_expectedLogPath = Path . Combine ( LogPath , "dotnet" ) ;
27-
27+
2828 private static readonly ClientConfig s_configWithErrorLevel = new ClientConfig
2929 {
3030 CommonProps = new ClientConfigCommonProps
@@ -33,7 +33,7 @@ public class EasyLoggingStarterTest
3333 LogPath = LogPath
3434 }
3535 } ;
36-
36+
3737 private static readonly ClientConfig s_configWithInfoLevel = new ClientConfig
3838 {
3939 CommonProps = new ClientConfigCommonProps
@@ -51,12 +51,21 @@ public class EasyLoggingStarterTest
5151 }
5252 } ;
5353
54+ private static readonly ClientConfig s_configWithStdoutAsLogPath = new ClientConfig
55+ {
56+ CommonProps = new ClientConfigCommonProps
57+ {
58+ LogLevel = "Info" ,
59+ LogPath = "STDOUT"
60+ }
61+ } ;
62+
5463 [ ThreadStatic ]
5564 private static Mock < EasyLoggingConfigProvider > t_easyLoggingProvider ;
56-
65+
5766 [ ThreadStatic ]
5867 private static Mock < EasyLoggerManager > t_easyLoggerManager ;
59-
68+
6069 [ ThreadStatic ]
6170 private static Mock < UnixOperations > t_unixOperations ;
6271
@@ -68,7 +77,7 @@ public class EasyLoggingStarterTest
6877
6978 [ ThreadStatic ]
7079 private static EasyLoggingStarter t_easyLoggerStarter ;
71-
80+
7281 [ SetUp ]
7382 public void BeforeEach ( )
7483 {
@@ -158,7 +167,7 @@ public void TestFailIfDirectoryCreationFails()
158167 {
159168 Assert . Ignore ( "skip test on Windows" ) ;
160169 }
161-
170+
162171 // arrange
163172 t_easyLoggingProvider
164173 . Setup ( provider => provider . ProvideConfig ( ConfigPath ) )
@@ -169,7 +178,7 @@ public void TestFailIfDirectoryCreationFails()
169178
170179 // act
171180 var thrown = Assert . Throws < Exception > ( ( ) => t_easyLoggerStarter . Init ( ConfigPath ) ) ;
172-
181+
173182 // assert
174183 Assert . That ( thrown . Message , Does . Contain ( "Failed to create logs directory" ) ) ;
175184 }
@@ -187,10 +196,10 @@ public void TestThatConfiguresEasyLoggingOnlyOnceWhenInitializedWithConfigPath()
187196 t_easyLoggingProvider
188197 . Setup ( provider => provider . ProvideConfig ( AnotherConfigPath ) )
189198 . Returns ( s_configWithInfoLevel ) ;
190-
199+
191200 // act
192201 t_easyLoggerStarter . Init ( ConfigPath ) ;
193-
202+
194203 // assert
195204 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
196205 {
@@ -202,24 +211,24 @@ public void TestThatConfiguresEasyLoggingOnlyOnceWhenInitializedWithConfigPath()
202211 FilePermissions . S_IRUSR | FilePermissions . S_IWUSR | FilePermissions . S_IXUSR ) , Times . Once ) ;
203212 }
204213 t_easyLoggerManager . Verify ( manager => manager . ReconfigureEasyLogging ( EasyLoggingLogLevel . Error , s_expectedLogPath ) , Times . Once ) ;
205-
214+
206215 // act
207216 t_easyLoggerStarter . Init ( null ) ;
208217 t_easyLoggerStarter . Init ( ConfigPath ) ;
209218 t_easyLoggerStarter . Init ( AnotherConfigPath ) ;
210-
219+
211220 // assert
212221 t_easyLoggerManager . VerifyNoOtherCalls ( ) ;
213222 }
214-
223+
215224 [ Test ]
216225 public void TestThatConfiguresEasyLoggingOnlyOnceForInitializationsWithoutConfigPath ( )
217226 {
218227 // arrange
219228 t_easyLoggingProvider
220229 . Setup ( provider => provider . ProvideConfig ( null ) )
221230 . Returns ( s_configWithErrorLevel ) ;
222-
231+
223232 // act
224233 t_easyLoggerStarter . Init ( null ) ;
225234 t_easyLoggerStarter . Init ( null ) ;
@@ -247,10 +256,10 @@ public void TestThatReconfiguresEasyLoggingWithConfigPathIfNotGivenForTheFirstTi
247256 t_easyLoggingProvider
248257 . Setup ( provider => provider . ProvideConfig ( ConfigPath ) )
249258 . Returns ( s_configWithInfoLevel ) ;
250-
259+
251260 // act
252261 t_easyLoggerStarter . Init ( null ) ;
253-
262+
254263 // assert
255264 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
256265 {
@@ -265,10 +274,25 @@ public void TestThatReconfiguresEasyLoggingWithConfigPathIfNotGivenForTheFirstTi
265274
266275 // act
267276 t_easyLoggerStarter . Init ( ConfigPath ) ;
268-
277+
269278 // assert
270279 t_easyLoggerManager . Verify ( manager => manager . ReconfigureEasyLogging ( EasyLoggingLogLevel . Info , s_expectedLogPath ) , Times . Once ) ;
271280 t_easyLoggerManager . VerifyNoOtherCalls ( ) ;
272281 }
282+
283+ [ Test ]
284+ public void TestConfigureStdout ( )
285+ {
286+ // arrange
287+ t_easyLoggingProvider
288+ . Setup ( provider => provider . ProvideConfig ( null ) )
289+ . Returns ( s_configWithStdoutAsLogPath ) ;
290+
291+ // act
292+ t_easyLoggerStarter . Init ( null ) ;
293+
294+ // assert
295+ t_easyLoggerManager . Verify ( manager => manager . ReconfigureEasyLogging ( EasyLoggingLogLevel . Info , "STDOUT" ) , Times . Once ) ;
296+ }
273297 }
274298}
0 commit comments