File tree Expand file tree Collapse file tree
src/BootstrapBlazor/Components/Filters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,15 +14,15 @@ namespace BootstrapBlazor.Components;
1414public interface IFilterAction
1515{
1616 /// <summary>
17- /// 获得 IFilter 实例中的过滤条件集合
17+ /// 重置过滤条件方法
1818 /// </summary>
19- /// <returns></returns>
20- FilterKeyValueAction GetFilterConditions ( ) ;
19+ void Reset ( ) ;
2120
2221 /// <summary>
23- /// 重置过滤条件方法
22+ /// 获得 IFilter 实例中的过滤条件集合
2423 /// </summary>
25- void Reset ( ) ;
24+ /// <returns></returns>
25+ FilterKeyValueAction GetFilterConditions ( ) ;
2626
2727 /// <summary>
2828 /// Override existing filter conditions
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public void Reset()
4343 /// <returns></returns>
4444 public Task SetFilterConditionsAsync ( FilterKeyValueAction filter )
4545 {
46- var first = filter . Filters ? . FirstOrDefault ( ) ?? filter ;
46+ var first = filter . Filters . FirstOrDefault ( ) ?? filter ;
4747 if ( first . FieldKey == Name )
4848 {
4949 Value = first . FieldValue ;
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(argo@live.ca) Website: https://www.blazor.zone
5+
6+ namespace UnitTest . Components ;
7+
8+ public class SearchFilterActionTest
9+ {
10+ [ Fact ]
11+ public async Task SearchFilterAction_Ok ( )
12+ {
13+ var filter = new SearchFilterAction ( "Name" , "Argo" ) ;
14+ Assert . Equal ( "Argo" , filter . Value ) ;
15+
16+ filter . Reset ( ) ;
17+ Assert . Null ( filter . Value ) ;
18+
19+ await filter . SetFilterConditionsAsync ( new FilterKeyValueAction
20+ {
21+ FieldKey = "Name" ,
22+ FieldValue = "Argo Zhang"
23+ } ) ;
24+ Assert . Equal ( "Argo Zhang" , filter . Value ) ;
25+
26+ await filter . SetFilterConditionsAsync ( new FilterKeyValueAction
27+ {
28+ Filters =
29+ [
30+ new FilterKeyValueAction
31+ {
32+ FieldKey = "Name" ,
33+ FieldValue = "Argo"
34+ }
35+ ]
36+ } ) ;
37+ Assert . Equal ( "Argo" , filter . Value ) ;
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments