File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the Apache 2.0 License
3+ // See the LICENSE file in the project root for more information.
4+ // Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 5+
6+ using System . Data ;
7+
8+ namespace UnitTest . Components ;
9+
10+ public class DataTableDynamicContextTest : BootstrapBlazorTestBase
11+ {
12+ [ Fact ]
13+ public void UseCache_Ok ( )
14+ {
15+ var table = new DataTable ( ) ;
16+ table . Columns . Add ( "Id" , typeof ( int ) ) ;
17+ table . Rows . Add ( 1 ) ;
18+ table . AcceptChanges ( ) ;
19+
20+ var context = new DataTableDynamicContext ( table ) ;
21+ Assert . True ( context . UseCache ) ;
22+
23+ var data = context . GetItems ( ) ;
24+ Assert . Single ( data ) ;
25+ Assert . Equal ( 1 , data . First ( ) . GetValue ( "Id" ) ) ;
26+
27+ // 增加数据
28+ table . Rows . Add ( 2 ) ;
29+ var data2 = context . GetItems ( ) ;
30+ Assert . Equal ( data , data2 ) ;
31+
32+ // 关闭缓存
33+ context . UseCache = false ;
34+ table . Rows . Add ( 3 ) ;
35+ data2 = context . GetItems ( ) ;
36+ Assert . Equal ( 3 , data2 . Count ( ) ) ;
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments