@@ -129,7 +129,76 @@ public async Task SetCIEnv()
129129 }
130130 }
131131 }
132+ #if OS_WINDOWS
133+ [ Fact ]
134+ [ Trait ( "Level" , "L0" ) ]
135+ [ Trait ( "Category" , "Common" ) ]
136+ public async Task SetTestEnvWithNullInKey ( )
137+ {
138+ using ( TestHostContext hc = new ( this ) )
139+ {
140+ Tracing trace = hc . GetTrace ( ) ;
141+
142+ Int32 exitCode = - 1 ;
143+ var processInvoker = new ProcessInvokerWrapper ( ) ;
144+ processInvoker . Initialize ( hc ) ;
145+ var stdout = new List < string > ( ) ;
146+ var stderr = new List < string > ( ) ;
147+ processInvoker . OutputDataReceived += ( object sender , ProcessDataReceivedEventArgs e ) =>
148+ {
149+ trace . Info ( e . Data ) ;
150+ stdout . Add ( e . Data ) ;
151+ } ;
152+ processInvoker . ErrorDataReceived += ( object sender , ProcessDataReceivedEventArgs e ) =>
153+ {
154+ trace . Info ( e . Data ) ;
155+ stderr . Add ( e . Data ) ;
156+ } ;
157+
158+ exitCode = await processInvoker . ExecuteAsync ( "" , "cmd.exe" , "/c \" echo %TEST%\" " , new Dictionary < string , string > ( ) { { "TEST\0 second" , "first" } } , CancellationToken . None ) ;
159+
160+
161+ trace . Info ( "Exit Code: {0}" , exitCode ) ;
162+ Assert . Equal ( 0 , exitCode ) ;
163+ Assert . Equal ( "first" , stdout . First ( x => ! string . IsNullOrWhiteSpace ( x ) ) ) ;
164+
165+ }
166+ }
132167
168+ [ Fact ]
169+ [ Trait ( "Level" , "L0" ) ]
170+ [ Trait ( "Category" , "Common" ) ]
171+ public async Task SetTestEnvWithNullInValue ( )
172+ {
173+ using ( TestHostContext hc = new ( this ) )
174+ {
175+ Tracing trace = hc . GetTrace ( ) ;
176+
177+ Int32 exitCode = - 1 ;
178+ var processInvoker = new ProcessInvokerWrapper ( ) ;
179+ processInvoker . Initialize ( hc ) ;
180+ var stdout = new List < string > ( ) ;
181+ var stderr = new List < string > ( ) ;
182+ processInvoker . OutputDataReceived += ( object sender , ProcessDataReceivedEventArgs e ) =>
183+ {
184+ trace . Info ( e . Data ) ;
185+ stdout . Add ( e . Data ) ;
186+ } ;
187+ processInvoker . ErrorDataReceived += ( object sender , ProcessDataReceivedEventArgs e ) =>
188+ {
189+ trace . Info ( e . Data ) ;
190+ stderr . Add ( e . Data ) ;
191+ } ;
192+
193+ exitCode = await processInvoker . ExecuteAsync ( "" , "cmd.exe" , "/c \" echo %TEST%\" " , new Dictionary < string , string > ( ) { { "TEST" , "first\0 second" } } , CancellationToken . None ) ;
194+
195+ trace . Info ( "Exit Code: {0}" , exitCode ) ;
196+ Assert . Equal ( 0 , exitCode ) ;
197+ Assert . Equal ( "first" , stdout . First ( x => ! string . IsNullOrWhiteSpace ( x ) ) ) ;
198+
199+ }
200+ }
201+ #endif
133202 [ Fact ]
134203 [ Trait ( "Level" , "L0" ) ]
135204 [ Trait ( "Category" , "Common" ) ]
0 commit comments