@@ -78,6 +78,45 @@ public void TestGetProviderWithDefaultConfig()
78
78
Assert . NotNull ( client ) ;
79
79
}
80
80
81
+ [ Fact ]
82
+ public void TestGetProviderWithConfig ( )
83
+ {
84
+ // Create a config with default values set
85
+ var config = new FlagdConfig ( ) ;
86
+
87
+ // Set env variables (should be ignored by the constructor)
88
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvCertPart , "path" ) ;
89
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarHost , "localhost111" ) ;
90
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarPort , "5001" ) ;
91
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarTLS , "true" ) ;
92
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarCache , "LRU" ) ;
93
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarMaxCacheSize , "20" ) ;
94
+
95
+ // Create provider, which ignores the env vars and uses the config
96
+ var flagdProvider = new FlagdProvider ( config ) ;
97
+
98
+ // Client should no be nil
99
+ var client = flagdProvider . GetClient ( ) ;
100
+ Assert . NotNull ( client ) ;
101
+
102
+ // Retrieve config for assertions
103
+ config = flagdProvider . GetConfig ( ) ;
104
+
105
+ // Assert
106
+ Assert . Equal ( "" , config . CertificatePath ) ;
107
+ Assert . Equal ( new Uri ( "http://localhost:8013" ) , config . GetUri ( ) ) ;
108
+ Assert . False ( config . CacheEnabled ) ;
109
+ Assert . Equal ( 0 , config . MaxCacheSize ) ;
110
+
111
+ // Cleanup
112
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvCertPart , "" ) ;
113
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarHost , "" ) ;
114
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarPort , "" ) ;
115
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarTLS , "" ) ;
116
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarCache , "" ) ;
117
+ System . Environment . SetEnvironmentVariable ( FlagdConfig . EnvVarMaxCacheSize , "" ) ;
118
+ }
119
+
81
120
[ Fact ]
82
121
public void TestResolveBooleanValue ( )
83
122
{
0 commit comments