1- using System . Collections ;
1+ using System . Collections ;
22using System . ComponentModel ;
33using MaterialDesignThemes . UITests . Samples . AutoSuggestBoxes ;
44using MaterialDesignThemes . UITests . Samples . AutoSuggestTextBoxes ;
@@ -178,12 +178,13 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
178178 await suggestBox . SendInput ( new KeyboardInput ( "e" ) ) ;
179179 await Task . Delay ( delay ) ;
180180
181- //var itemSource = (await suggestBox.GetSuggestions()).Cast<object>().ToList();
182-
183- //var suggestions = await suggestionListBox.GetProperty<IEnumerable>(nameof(ListBox.ItemsSource));
184- //int itemCount = suggestions.Cast<object>().Count();
181+ static int ? GetSuggestionCount ( AutoSuggestBox autoSuggestBox )
182+ {
183+ int ? count = autoSuggestBox . Suggestions ? . OfType < object > ( ) . Count ( ) ;
184+ return count ;
185+ }
185186
186- int itemCount = CountNonGenericEnumerable ( await suggestBox . GetSuggestions ( ) ) ;
187+ int itemCount = await suggestBox . RemoteExecute ( GetSuggestionCount ) ?? 0 ;
187188
188189 //Assert that initially the first item is selected
189190 int selectedIndex = await suggestionListBox . GetSelectedIndex ( ) ;
@@ -198,27 +199,6 @@ public async Task AutoSuggestBox_KeysUpAndDown_WrapAround()
198199 //Assert that the first item is selected after pressing ArrowDown
199200 await suggestBox . SendInput ( new KeyboardInput ( Key . Down ) ) ;
200201 Assert . Equal ( 0 , await suggestionListBox . GetSelectedIndex ( ) ) ;
201-
202-
203- }
204-
205- internal static int CountNonGenericEnumerable ( IEnumerable ? source )
206- {
207- ArgumentNullException . ThrowIfNull ( source ) ;
208-
209- if ( source is ICollection collection )
210- {
211- return collection . Count ;
212- }
213-
214- int count = 0 ;
215- IEnumerator e = source . GetEnumerator ( ) ;
216- while ( e . MoveNext ( ) )
217- {
218- count ++ ;
219- }
220-
221- return count ;
222202 }
223203
224204 private static async Task AssertExists ( IVisualElement < ListBox > suggestionListBox , string text , bool existsOrNotCheck = true )
0 commit comments