@@ -11,17 +11,20 @@ namespace Bunit.JSInterop.ComponentSupport;
11
11
12
12
public class VirtualizeJSRuntimeInvocationHandlerTest : TestContext
13
13
{
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
+ ] ;
18
18
19
19
[ Theory ( DisplayName = "Can render component using <Virtualize Items> with ChildContent" ) ]
20
20
[ MemberData ( nameof ( ItemsInCollection ) ) ]
21
21
public void Test001 ( int itemsInDataSource )
22
22
{
23
23
var cut = RenderComponent < Virtualize < string > > ( ps => ps
24
24
. Add ( p => p . Items , CreateItems ( itemsInDataSource ) )
25
+ #if NET9_0_OR_GREATER
26
+ . Add ( p => p . MaxItemCount , itemsInDataSource )
27
+ #endif
25
28
. Add ( p => p . ChildContent , item => $ "<p>{ item } </p>") ) ;
26
29
27
30
cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -33,6 +36,9 @@ public void Test002(int itemsInDataSource)
33
36
{
34
37
var cut = RenderComponent < Virtualize < string > > ( ps => ps
35
38
. Add ( p => p . Items , CreateItems ( itemsInDataSource ) )
39
+ #if NET9_0_OR_GREATER
40
+ . Add ( p => p . MaxItemCount , itemsInDataSource )
41
+ #endif
36
42
. Add ( p => p . ItemContent , item => $ "<p>{ item } </p>") ) ;
37
43
38
44
cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -44,6 +50,9 @@ public void Test010(int itemsInDataSource)
44
50
{
45
51
var cut = RenderComponent < Virtualize < string > > ( ps => ps
46
52
. Add ( p => p . ItemsProvider , CreateItemsProvider ( itemsInDataSource ) )
53
+ #if NET9_0_OR_GREATER
54
+ . Add ( p => p . MaxItemCount , itemsInDataSource )
55
+ #endif
47
56
. Add ( p => p . ChildContent , item => $ "<p>{ item } </p>") ) ;
48
57
49
58
cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -55,6 +64,9 @@ public void Test011(int itemsInDataSource)
55
64
{
56
65
var cut = RenderComponent < Virtualize < string > > ( ps => ps
57
66
. Add ( p => p . ItemsProvider , CreateItemsProvider ( itemsInDataSource ) )
67
+ #if NET9_0_OR_GREATER
68
+ . Add ( p => p . MaxItemCount , itemsInDataSource )
69
+ #endif
58
70
. Add ( p => p . ItemContent , item => $ "<p>{ item } </p>") ) ;
59
71
60
72
cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -63,12 +75,8 @@ public void Test011(int itemsInDataSource)
63
75
public static readonly IEnumerable < object [ ] > ItemCountItemSizeOverscanCount =
64
76
ItemsInCollection . Select ( x => new object [ ] [ ]
65
77
{
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
+ ] ,
72
80
} ) . SelectMany ( x => x ) ;
73
81
74
82
[ 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)
79
87
. Add ( p => p . ItemsProvider , CreateItemsProvider ( itemsInDataSource ) )
80
88
. Add ( p => p . ItemContent , item => $ "<p>{ item } </p>")
81
89
. Add ( p => p . ItemSize , itemSize )
90
+ #if NET9_0_OR_GREATER
91
+ . Add ( p => p . MaxItemCount , itemsInDataSource )
92
+ #endif
82
93
. Add ( p => p . OverscanCount , overscanCount ) ) ;
83
94
84
95
cut . FindAll ( "p" ) . Count . ShouldBe ( itemsInDataSource ) ;
@@ -91,6 +102,9 @@ public void Test040(int itemsInDataSource)
91
102
var cut = RenderComponent < Virtualize < string > > ( ps => ps
92
103
. Add ( p => p . ItemsProvider , _ => ValueTask . FromResult ( new ItemsProviderResult < string > ( Array . Empty < string > ( ) , itemsInDataSource ) ) )
93
104
. Add ( p => p . ItemContent , item => @$ "<p class=""item"">{ item } </p>")
105
+ #if NET9_0_OR_GREATER
106
+ . Add ( p => p . MaxItemCount , itemsInDataSource )
107
+ #endif
94
108
. Add ( p => p . Placeholder , _ => @"<p class=""placeholder"" />" ) ) ;
95
109
96
110
cut . FindAll ( ".placeholder" ) . Count . ShouldBe ( itemsInDataSource ) ;
0 commit comments