@@ -157,33 +157,96 @@ public async Task OnSelectedItemChanged_Ok()
157157 }
158158
159159 [ Fact ]
160- public void OnGetDisplayText_Ok ( )
160+ public async Task OnGetDisplayText_Ok ( )
161161 {
162162 var cut = Context . RenderComponent < AutoFill < Foo > > ( pb =>
163163 {
164164 pb . Add ( a => a . Value , Model ) ;
165- pb . Add ( a => a . Items , Items ) ;
166- pb . Add ( a => a . OnGetDisplayText , foo => foo . Name ) ;
165+ pb . Add ( a => a . Items , new List < Foo > { null ! , new ( ) { Name = "Test" } } ) ;
166+ pb . Add ( a => a . OnGetDisplayText , foo => foo ? . Name ) ;
167167 } ) ;
168168 var input = cut . Find ( "input" ) ;
169169 Assert . Equal ( "张三 1000" , input . Attributes [ "value" ] ? . Value ) ;
170+
171+ cut . SetParametersAndRender ( pb =>
172+ {
173+ pb . Add ( a => a . OnGetDisplayText , null ! ) ;
174+ } ) ;
175+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
176+
177+ cut . SetParametersAndRender ( pb =>
178+ {
179+ pb . Add ( a => a . IsLikeMatch , true ) ;
180+ } ) ;
181+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
170182 }
171183
172184 [ Fact ]
173- public async Task DisplayCount_Ok ( )
185+ public async Task IgnoreCase_Ok ( )
174186 {
175- var items = new List < Foo > ( ) { new ( ) { Name = "task1" } , new ( ) { Name = "Task2 " } , new ( ) { Name = "task3 " } , new ( ) { Name = "Task4" } } ;
187+ var items = new List < Foo > ( ) { new ( ) { Name = "task1" } , new ( ) { Name = "task2 " } , new ( ) { Name = "Task3 " } , new ( ) { Name = "Task4" } } ;
176188 var cut = Context . RenderComponent < AutoFill < Foo > > ( builder =>
177189 {
178190 builder . Add ( a => a . Items , items ) ;
179- builder . Add ( a => a . DisplayCount , 2 ) ;
191+ builder . Add ( a => a . IgnoreCase , true ) ;
192+ builder . Add ( a => a . OnGetDisplayText , foo => foo . Name ) ;
180193 } ) ;
181194
182195 await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
183196 var menus = cut . FindAll ( ".dropdown-item" ) ;
197+ Assert . Equal ( 4 , menus . Count ) ;
198+
199+ cut . SetParametersAndRender ( pb =>
200+ {
201+ pb . Add ( a => a . DisplayCount , 2 ) ;
202+ } ) ;
203+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
204+ menus = cut . FindAll ( ".dropdown-item" ) ;
205+ Assert . Equal ( 2 , menus . Count ) ;
206+
207+ cut . SetParametersAndRender ( pb =>
208+ {
209+ pb . Add ( a => a . IgnoreCase , false ) ;
210+ pb . Add ( a => a . DisplayCount , null ) ;
211+ } ) ;
212+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
213+ menus = cut . FindAll ( ".dropdown-item" ) ;
184214 Assert . Equal ( 2 , menus . Count ) ;
185215 }
186216
217+ [ Fact ]
218+ public async Task IsLikeMatch_Ok ( )
219+ {
220+ var items = new List < Foo > ( ) { new ( ) { Name = "task1" } , new ( ) { Name = "task2" } , new ( ) { Name = "Task3" } , new ( ) { Name = "Task4" } } ;
221+ var cut = Context . RenderComponent < AutoFill < Foo > > ( builder =>
222+ {
223+ builder . Add ( a => a . Items , items ) ;
224+ builder . Add ( a => a . IsLikeMatch , false ) ;
225+ builder . Add ( a => a . OnGetDisplayText , foo => foo . Name ) ;
226+ } ) ;
227+
228+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
229+ var menus = cut . FindAll ( ".dropdown-item" ) ;
230+ Assert . Equal ( 4 , menus . Count ) ;
231+
232+ cut . SetParametersAndRender ( pb =>
233+ {
234+ pb . Add ( a => a . DisplayCount , 2 ) ;
235+ } ) ;
236+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "t" ) ) ;
237+ menus = cut . FindAll ( ".dropdown-item" ) ;
238+ Assert . Equal ( 2 , menus . Count ) ;
239+
240+ cut . SetParametersAndRender ( pb =>
241+ {
242+ pb . Add ( a => a . IsLikeMatch , true ) ;
243+ pb . Add ( a => a . DisplayCount , null ) ;
244+ } ) ;
245+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerOnChange ( "a" ) ) ;
246+ menus = cut . FindAll ( ".dropdown-item" ) ;
247+ Assert . Equal ( 4 , menus . Count ) ;
248+ }
249+
187250 [ Fact ]
188251 public void ShowDropdownListOnFocus_Ok ( )
189252 {
0 commit comments