22{
33 using System ;
44 using System . Collections . Generic ;
5+ using System . Linq ;
56 using Extensions ;
67 using Microsoft . Extensions . Configuration ;
78 using Microsoft . Extensions . Hosting ;
@@ -25,6 +26,8 @@ public class ConfigurationRootExtensionsTests
2526 /// </value>
2627 public static IReadOnlyDictionary < String , String > DefaultAppSettings { get ; } = new Dictionary < String , String >
2728 {
29+ [ "AppSettings:Test" ] = "" ,
30+ [ "AppSettings:Test1" ] = null ,
2831 [ "AppSettings:ClientId" ] = "clientId" ,
2932 [ "AppSettings:ClientSecret" ] = "Secret1" ,
3033 [ "EventStoreSettings:ConnectionString" ] = "https://192.168.1.133:2113" ,
@@ -42,7 +45,7 @@ public class ConfigurationRootExtensionsTests
4245 [ Fact ]
4346 public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged ( )
4447 {
45- IConfigurationBuilder builder = new ConfigurationBuilder ( ) . AddInMemoryCollection ( ConfigurationRootExtensionsTests . DefaultAppSettings ) ;
48+ IConfigurationBuilder builder = new ConfigurationBuilder ( ) . AddInMemoryCollection ( ConfigurationRootExtensionsTests . DefaultAppSettings ) . AddEnvironmentVariables ( ) ;
4649
4750 IConfigurationRoot configuration = builder . Build ( ) ;
4851
@@ -54,6 +57,7 @@ public void ConfigurationRootExtensions_LogConfiguration_ConfigurationIsLogged()
5457 String [ ] loggedEntries = testLogger . GetLogEntries ( ) ;
5558 Int32 expectedCount = ConfigurationRootExtensionsTests . DefaultAppSettings . Count + 6 ; // 3 blank lines & 3 headers
5659 loggedEntries . Length . ShouldBe ( expectedCount ) ;
60+ loggedEntries . Where ( l => l . Contains ( "No Value" ) ) . Count ( ) . ShouldBe ( 2 ) ;
5761 }
5862
5963 /// <summary>
@@ -81,7 +85,7 @@ public void ConfigurationRootExtensions_LogConfiguration_NoConfiguration_NoConfi
8185 [ Fact ]
8286 public void ConfigurationRootExtensions_LogConfiguration_NullAction_ErrorIsThrown ( )
8387 {
84- IConfigurationBuilder builder = new ConfigurationBuilder ( ) . AddInMemoryCollection ( ConfigurationRootExtensionsTests . DefaultAppSettings ) ;
88+ IConfigurationBuilder builder = new ConfigurationBuilder ( ) . AddInMemoryCollection ( ConfigurationRootExtensionsTests . DefaultAppSettings ) . AddEnvironmentVariables ( ) ;
8589
8690 IConfigurationRoot configuration = builder . Build ( ) ;
8791
0 commit comments