File tree 2 files changed +21
-2
lines changed
src/Aquality.Selenium.Core/Utilities
tests/Aquality.Selenium.Core.Tests/Utilities
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,13 @@ public T GetValue<T>(string path)
68
68
var envValue = GetEnvironmentValue ( path ) ;
69
69
if ( envValue != null )
70
70
{
71
- return ConvertEnvVar ( ( ) => ( T ) TypeDescriptor . GetConverter ( typeof ( T ) ) . ConvertFrom ( envValue ) ,
71
+ return ConvertEnvVar ( ( ) =>
72
+ {
73
+ var type = typeof ( T ) ;
74
+ return type == typeof ( object )
75
+ ? ( T ) Convert . ChangeType ( envValue , type )
76
+ : ( T ) TypeDescriptor . GetConverter ( type ) . ConvertFrom ( envValue ) ;
77
+ } ,
72
78
envValue , path ) ;
73
79
}
74
80
Original file line number Diff line number Diff line change @@ -109,6 +109,19 @@ public void Should_BePossibleTo_GetEmptyValueDictionary()
109
109
[ NonParallelizable ]
110
110
public void Should_BePossibleTo_OverrideDictionaryOfValues_FromEnvVar ( )
111
111
{
112
+ CheckOverrideDictionaryFromEnvVar < string > ( ) ;
113
+ }
114
+
115
+ [ Test ]
116
+ [ NonParallelizable ]
117
+ public void Should_BePossibleTo_OverrideDictionaryOfObjects_FromEnvVar ( )
118
+ {
119
+ CheckOverrideDictionaryFromEnvVar < object > ( ) ;
120
+ }
121
+
122
+ private void CheckOverrideDictionaryFromEnvVar < T > ( )
123
+ {
124
+
112
125
var expectedDict = new Dictionary < string , object >
113
126
{
114
127
{ "intl.accept_languages" , "1" } ,
@@ -120,7 +133,7 @@ public void Should_BePossibleTo_OverrideDictionaryOfValues_FromEnvVar()
120
133
Environment . SetEnvironmentVariable ( "driverSettings.chrome.options.disable-popup-blocking" , "bla" ) ;
121
134
122
135
Assert . AreEqual ( expectedDict ,
123
- AddedParamsSettings . GetValueDictionary < string > ( ".driverSettings.chrome.options" ) ,
136
+ AddedParamsSettings . GetValueDictionary < T > ( ".driverSettings.chrome.options" ) ,
124
137
"Dictionary of keys and values was overriden successively" ) ;
125
138
}
126
139
You can’t perform that action at this time.
0 commit comments