@@ -11,17 +11,20 @@ namespace Bunit.JSInterop.ComponentSupport;
1111
1212public class VirtualizeJSRuntimeInvocationHandlerTest : TestContext
1313{
14- public static readonly IEnumerable < object [ ] > ItemsInCollection = new object [ ] [ ]
15- {
16- new object [ ] { 0 } , new object [ ] { 7 } , new object [ ] { 30 } , new object [ ] { 60 } , new object [ ] { 100 } , new object [ ] { 300 } , new object [ ] { 500 } ,
17- } ;
14+ public static readonly IEnumerable < object [ ] > ItemsInCollection =
15+ [
16+ [ 0 ] , [ 7 ] , [ 30 ] , [ 60 ] , [ 100 ] , [ 300 ] , [ 500 ] ,
17+ ] ;
1818
1919 [ Theory ( DisplayName = "Can render component using <Virtualize Items> with ChildContent" ) ]
2020 [ MemberData ( nameof ( ItemsInCollection ) ) ]
2121 public void Test001 ( int itemsInDataSource )
2222 {
2323 var cut = RenderComponent < Virtualize < string > > ( ps => ps
2424 . Add ( p => p . Items , CreateItems ( itemsInDataSource ) )
25+ #if NET9_0_OR_GREATER
26+ . Add ( p => p . MaxItemCount , itemsInDataSource )
27+ #endif
2528 . Add ( p => p . ChildContent , item => $ "<p>{ item } </p>") ) ;
2629
2730 cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -33,6 +36,9 @@ public void Test002(int itemsInDataSource)
3336 {
3437 var cut = RenderComponent < Virtualize < string > > ( ps => ps
3538 . Add ( p => p . Items , CreateItems ( itemsInDataSource ) )
39+ #if NET9_0_OR_GREATER
40+ . Add ( p => p . MaxItemCount , itemsInDataSource )
41+ #endif
3642 . Add ( p => p . ItemContent , item => $ "<p>{ item } </p>") ) ;
3743
3844 cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -44,6 +50,9 @@ public void Test010(int itemsInDataSource)
4450 {
4551 var cut = RenderComponent < Virtualize < string > > ( ps => ps
4652 . Add ( p => p . ItemsProvider , CreateItemsProvider ( itemsInDataSource ) )
53+ #if NET9_0_OR_GREATER
54+ . Add ( p => p . MaxItemCount , itemsInDataSource )
55+ #endif
4756 . Add ( p => p . ChildContent , item => $ "<p>{ item } </p>") ) ;
4857
4958 cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -55,6 +64,9 @@ public void Test011(int itemsInDataSource)
5564 {
5665 var cut = RenderComponent < Virtualize < string > > ( ps => ps
5766 . Add ( p => p . ItemsProvider , CreateItemsProvider ( itemsInDataSource ) )
67+ #if NET9_0_OR_GREATER
68+ . Add ( p => p . MaxItemCount , itemsInDataSource )
69+ #endif
5870 . Add ( p => p . ItemContent , item => $ "<p>{ item } </p>") ) ;
5971
6072 cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -63,12 +75,8 @@ public void Test011(int itemsInDataSource)
6375 public static readonly IEnumerable < object [ ] > ItemCountItemSizeOverscanCount =
6476 ItemsInCollection . Select ( x => new object [ ] [ ]
6577 {
66- new object [ ] { x [ 0 ] , 1 , 3 } ,
67- new object [ ] { x [ 0 ] , 1_000_000 , 3 } ,
68- new object [ ] { x [ 0 ] , 50 , 1 } ,
69- new object [ ] { x [ 0 ] , 50 , 1_000_000 } ,
70- new object [ ] { x [ 0 ] , 1 , 1 } ,
71- new object [ ] { x [ 0 ] , 1_000_000 , 1_000_000 } ,
78+ [ x [ 0 ] , 1 , 3 ] , [ x [ 0 ] , 1_000_000 , 3 ] , [ x [ 0 ] , 50 , 1 ] , [ x [ 0 ] , 50 , 1_000_000 ] , [ x [ 0 ] , 1 , 1 ] , [ x [ 0 ] , 1_000_000 , 1_000_000
79+ ] ,
7280 } ) . SelectMany ( x => x ) ;
7381
7482 [ Theory ( DisplayName = "Can render component using <Virtualize Items> and different ItemSize and OverscanCount" ) ]
@@ -79,6 +87,9 @@ public void Test030(int itemsInDataSource, float itemSize, int overscanCount)
7987 . Add ( p => p . ItemsProvider , CreateItemsProvider ( itemsInDataSource ) )
8088 . Add ( p => p . ItemContent , item => $ "<p>{ item } </p>")
8189 . Add ( p => p . ItemSize , itemSize )
90+ #if NET9_0_OR_GREATER
91+ . Add ( p => p . MaxItemCount , itemsInDataSource )
92+ #endif
8293 . Add ( p => p . OverscanCount , overscanCount ) ) ;
8394
8495 cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -91,6 +102,9 @@ public void Test040(int itemsInDataSource)
91102 var cut = RenderComponent < Virtualize < string > > ( ps => ps
92103 . Add ( p => p . ItemsProvider , _ => ValueTask . FromResult ( new ItemsProviderResult < string > ( Array . Empty < string > ( ) , itemsInDataSource ) ) )
93104 . Add ( p => p . ItemContent , item => @$ "<p class=""item"">{ item } </p>")
105+ #if NET9_0_OR_GREATER
106+ . Add ( p => p . MaxItemCount , itemsInDataSource )
107+ #endif
94108 . Add ( p => p . Placeholder , _ => @"<p class=""placeholder"" />" ) ) ;
95109
96110 cut . FindAll ( ".placeholder" ) . Count . ShouldBe ( itemsInDataSource ) ;
0 commit comments