@@ -343,82 +343,6 @@ function foo($x) {return $x * 2}
343
343
}
344
344
345
345
346
-
347
- [ TestMethod ]
348
- public void TestRecursiveFunctionCaptureOutput ( )
349
- {
350
- using ( var ps = PowerShell . Create ( ) )
351
- {
352
- ps . RunspacePool = _runspacePool ;
353
- ps . AddScript ( @"
354
- function foo($x) {return 2 * $x}
355
- function bar($x) {return 3 * (foo $x)}
356
- " , false ) ;
357
-
358
- ps . AddStatement ( )
359
- . AddCommand ( "Invoke-Parallel" , false )
360
- . AddParameter ( "ScriptBlock" , ScriptBlock . Create ( "bar $_" ) )
361
- . AddParameter ( "ThrottleLimit" , 1 )
362
- . AddParameter ( "NoProgress" ) ;
363
-
364
- var input = new PSDataCollection < int > { 1 , 2 , 3 , 4 , 5 } ;
365
- input . Complete ( ) ;
366
- var output = ps . Invoke < int > ( input ) ;
367
- var sum = output . Aggregate ( 0 , ( a , b ) => a + b ) ;
368
- Assert . AreEqual ( 90 , sum ) ;
369
- }
370
- }
371
-
372
- [ TestMethod ]
373
- public void TestLimitingVariables ( )
374
- {
375
- using ( PowerShell ps = PowerShell . Create ( ) ) {
376
- ps . RunspacePool = _runspacePool ;
377
- ps . AddScript ( @"
378
- $x = 1
379
- $y = 2
380
- " , false ) ;
381
-
382
- ps . AddStatement ( )
383
- . AddCommand ( "Invoke-Parallel" , false )
384
- . AddParameter ( "ImportVariable" , 'x' )
385
- . AddParameter ( "ScriptBlock" , ScriptBlock . Create ( "$x,$y" ) )
386
- . AddParameter ( "ThrottleLimit" , 1 )
387
- . AddParameter ( "NoProgress" )
388
- . AddParameter ( "InputObject" , 1 ) ;
389
-
390
- var output = ps . Invoke ( ) ;
391
- int x = ( int ) output [ 0 ] . BaseObject ;
392
- Assert . AreEqual ( 1 , x ) ;
393
- Assert . IsNull ( output [ 1 ] ) ;
394
- }
395
- }
396
-
397
- [ TestMethod ]
398
- public void TestLimitingFunctions ( )
399
- {
400
- using ( PowerShell ps = PowerShell . Create ( ) )
401
- {
402
- ps . RunspacePool = _runspacePool ;
403
- ps . AddScript ( @"
404
- function f{1}
405
- function g{}
406
- " , false ) . Invoke ( ) ;
407
- ps . AddStatement ( )
408
- . AddCommand ( "Invoke-Parallel" , false )
409
- . AddParameter ( "ImportFunction" , 'f' )
410
- . AddParameter ( "ScriptBlock" , ScriptBlock . Create ( "f;g" ) )
411
- . AddParameter ( "ThrottleLimit" , 1 )
412
- . AddParameter ( "NoProgress" )
413
- . AddParameter ( "InputObject" , 1 ) ;
414
-
415
- var output = ps . Invoke ( ) ;
416
- int x = ( int ) output [ 0 ] . BaseObject ;
417
- Assert . AreEqual ( 1 , x ) ;
418
- Assert . IsTrue ( ps . HadErrors ) ;
419
- }
420
- }
421
-
422
346
public void Dispose ( )
423
347
{
424
348
_runspacePool . Dispose ( ) ;
0 commit comments