File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
src/Aquality.Selenium.Core/Utilities
tests/Aquality.Selenium.Core.Tests/Utilities Expand file tree Collapse file tree 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)
6868 var envValue = GetEnvironmentValue ( path ) ;
6969 if ( envValue != null )
7070 {
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+ } ,
7278 envValue , path ) ;
7379 }
7480
Original file line number Diff line number Diff line change @@ -109,6 +109,19 @@ public void Should_BePossibleTo_GetEmptyValueDictionary()
109109 [ NonParallelizable ]
110110 public void Should_BePossibleTo_OverrideDictionaryOfValues_FromEnvVar ( )
111111 {
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+
112125 var expectedDict = new Dictionary < string , object >
113126 {
114127 { "intl.accept_languages" , "1" } ,
@@ -120,7 +133,7 @@ public void Should_BePossibleTo_OverrideDictionaryOfValues_FromEnvVar()
120133 Environment . SetEnvironmentVariable ( "driverSettings.chrome.options.disable-popup-blocking" , "bla" ) ;
121134
122135 Assert . AreEqual ( expectedDict ,
123- AddedParamsSettings . GetValueDictionary < string > ( ".driverSettings.chrome.options" ) ,
136+ AddedParamsSettings . GetValueDictionary < T > ( ".driverSettings.chrome.options" ) ,
124137 "Dictionary of keys and values was overriden successively" ) ;
125138 }
126139
You can’t perform that action at this time.
0 commit comments