@@ -459,106 +459,6 @@ public async Task ObjectResult_NullValue()
459
459
Assert . Null ( formatterContext . Object ) ;
460
460
}
461
461
462
- [ Fact ]
463
- public async Task ObjectResult_ReadsAsyncEnumerables ( )
464
- {
465
- // Arrange
466
- var executor = CreateExecutor ( ) ;
467
- var result = new ObjectResult ( AsyncEnumerable ( ) ) ;
468
- var formatter = new TestJsonOutputFormatter ( ) ;
469
- result . Formatters . Add ( formatter ) ;
470
-
471
- var actionContext = new ActionContext ( )
472
- {
473
- HttpContext = GetHttpContext ( ) ,
474
- } ;
475
-
476
- // Act
477
- await executor . ExecuteAsync ( actionContext , result ) ;
478
-
479
- // Assert
480
- var formatterContext = formatter . LastOutputFormatterContext ;
481
- Assert . Equal ( typeof ( List < string > ) , formatterContext . ObjectType ) ;
482
- var value = Assert . IsType < List < string > > ( formatterContext . Object ) ;
483
- Assert . Equal ( new [ ] { "Hello 0" , "Hello 1" , "Hello 2" , "Hello 3" , } , value ) ;
484
- }
485
-
486
- [ Fact ]
487
- public async Task ObjectResult_Throws_IfEnumerableThrows ( )
488
- {
489
- // Arrange
490
- var executor = CreateExecutor ( ) ;
491
- var result = new ObjectResult ( AsyncEnumerable ( throwError : true ) ) ;
492
- var formatter = new TestJsonOutputFormatter ( ) ;
493
- result . Formatters . Add ( formatter ) ;
494
-
495
- var actionContext = new ActionContext ( )
496
- {
497
- HttpContext = GetHttpContext ( ) ,
498
- } ;
499
-
500
- // Act & Assert
501
- await Assert . ThrowsAsync < TimeZoneNotFoundException > ( ( ) => executor . ExecuteAsync ( actionContext , result ) ) ;
502
- }
503
-
504
- [ Fact ]
505
- public async Task ObjectResult_AsyncEnumeration_AtLimit ( )
506
- {
507
- // Arrange
508
- var count = 24 ;
509
- var executor = CreateExecutor ( options : new MvcOptions { MaxIAsyncEnumerableBufferLimit = count } ) ;
510
- var result = new ObjectResult ( AsyncEnumerable ( count : count ) ) ;
511
- var formatter = new TestJsonOutputFormatter ( ) ;
512
- result . Formatters . Add ( formatter ) ;
513
-
514
- var actionContext = new ActionContext ( )
515
- {
516
- HttpContext = GetHttpContext ( ) ,
517
- } ;
518
-
519
- // Act
520
- await executor . ExecuteAsync ( actionContext , result ) ;
521
-
522
- // Assert
523
- var formatterContext = formatter . LastOutputFormatterContext ;
524
- var value = Assert . IsType < List < string > > ( formatterContext . Object ) ;
525
- Assert . Equal ( 24 , value . Count ) ;
526
- }
527
-
528
- [ Theory ]
529
- [ InlineData ( 25 ) ]
530
- [ InlineData ( 1024 ) ]
531
- public async Task ObjectResult_Throws_IfEnumerationExceedsLimit ( int count )
532
- {
533
- // Arrange
534
- var executor = CreateExecutor ( options : new MvcOptions { MaxIAsyncEnumerableBufferLimit = 24 } ) ;
535
- var result = new ObjectResult ( AsyncEnumerable ( count : count ) ) ;
536
- var formatter = new TestJsonOutputFormatter ( ) ;
537
- result . Formatters . Add ( formatter ) ;
538
-
539
- var actionContext = new ActionContext ( )
540
- {
541
- HttpContext = GetHttpContext ( ) ,
542
- } ;
543
-
544
- // Act & Assert
545
- var ex = await Assert . ThrowsAsync < InvalidOperationException > ( ( ) => executor . ExecuteAsync ( actionContext , result ) ) ;
546
- }
547
-
548
- private static async IAsyncEnumerable < string > AsyncEnumerable ( int count = 4 , bool throwError = false )
549
- {
550
- await Task . Yield ( ) ;
551
- for ( var i = 0 ; i < count ; i ++ )
552
- {
553
- yield return $ "Hello { i } ";
554
- }
555
-
556
- if ( throwError )
557
- {
558
- throw new TimeZoneNotFoundException ( ) ;
559
- }
560
- }
561
-
562
462
private static IServiceCollection CreateServices ( )
563
463
{
564
464
var services = new ServiceCollection ( ) ;
0 commit comments