@@ -211,18 +211,25 @@ public void TestEnvironmentProperty()
211211 }
212212
213213 [ Fact ]
214- public void EnvironmentVariableNameContainingNull_ThrowsArgumentException ( )
214+ public void EnvironmentVariableContainingNull_ThrowsArgumentException ( )
215215 {
216- const string InvalidName = "Name\0 Suffix" ;
216+ const string InvalidKey = "Name\0 Suffix" ;
217+ const string InvalidValue = "Value\0 Suffix" ;
217218 ProcessStartInfo psi = new ProcessStartInfo ( ) ;
218219 IDictionary environment = ( IDictionary ) psi . Environment ;
219220 ICollection < KeyValuePair < string , string > > environmentCollection = psi . Environment ;
220221
221- AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => psi . Environment [ InvalidName ] = "value" ) ;
222- AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => environment [ InvalidName ] = "value" ) ;
223- AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => psi . Environment . Add ( InvalidName , "value" ) ) ;
224- AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => environmentCollection . Add ( new KeyValuePair < string , string > ( InvalidName , "value" ) ) ) ;
225- AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => environment . Add ( InvalidName , "value" ) ) ;
222+ AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => psi . Environment [ InvalidKey ] = "value" ) ;
223+ AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => environment [ InvalidKey ] = "value" ) ;
224+ AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => psi . Environment . Add ( InvalidKey , "value" ) ) ;
225+ AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => environmentCollection . Add ( new KeyValuePair < string , string > ( InvalidKey , "value" ) ) ) ;
226+ AssertExtensions . Throws < ArgumentException > ( "key" , ( ) => environment . Add ( InvalidKey , "value" ) ) ;
227+
228+ AssertExtensions . Throws < ArgumentException > ( "value" , ( ) => psi . Environment [ "key" ] = InvalidValue ) ;
229+ AssertExtensions . Throws < ArgumentException > ( "value" , ( ) => environment [ "key" ] = InvalidValue ) ;
230+ AssertExtensions . Throws < ArgumentException > ( "value" , ( ) => psi . Environment . Add ( "key" , InvalidValue ) ) ;
231+ AssertExtensions . Throws < ArgumentException > ( "value" , ( ) => environmentCollection . Add ( new KeyValuePair < string , string > ( "key" , InvalidValue ) ) ) ;
232+ AssertExtensions . Throws < ArgumentException > ( "value" , ( ) => environment . Add ( "key" , InvalidValue ) ) ;
226233 }
227234
228235 [ ConditionalFact ( typeof ( RemoteExecutor ) , nameof ( RemoteExecutor . IsSupported ) ) ]
0 commit comments