@@ -243,5 +243,84 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
243
243
Assert . AreEqual ( string . Empty , tokenBox . Text , "TokenizingTextBox text was not cleared." ) ;
244
244
} ) ;
245
245
}
246
+
247
+ [ TestCategory ( "Test_TokenizingTextBox_General" ) ]
248
+ [ TestMethod ]
249
+ public async Task Test_SetInitialTextWithDelimiter ( )
250
+ {
251
+ await App . DispatcherQueue . EnqueueAsync ( async ( ) =>
252
+ {
253
+ var treeRoot = XamlReader . Load (
254
+ @"<Page
255
+ xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
256
+ xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
257
+ xmlns:controls=""using:Microsoft.Toolkit.Uwp.UI.Controls"">
258
+
259
+ <controls:TokenizingTextBox x:Name=""tokenboxname"" TokenDelimiter="","" Text=""Token 1, Token 2, Token 3""/>
260
+
261
+ </Page>" ) as FrameworkElement ;
262
+
263
+ Assert . IsNotNull ( treeRoot , "Could not load XAML tree." ) ;
264
+
265
+ await SetTestContentAsync ( treeRoot ) ;
266
+
267
+ var tokenBox = treeRoot . FindChild ( "tokenboxname" ) as TokenizingTextBox ;
268
+
269
+ Assert . IsNotNull ( tokenBox , "Could not find TokenizingTextBox in tree." ) ;
270
+ Assert . AreEqual ( 1 , tokenBox . Items . Count , "Tokens not created" ) ; // AutoSuggestBox
271
+
272
+ Assert . AreEqual ( "Token 1, Token 2, Token 3" , tokenBox . Text , "Token text not equal to starting value." ) ;
273
+
274
+ await Task . Delay ( 500 ) ; // TODO: Wait for a loaded event?
275
+
276
+ Assert . AreEqual ( 1 + 2 , tokenBox . Items . Count , "Tokens not created" ) ;
277
+
278
+ // Test initial value of property
279
+ Assert . AreEqual ( "Token 3" , tokenBox . Text , "Token text should be last value now." ) ;
280
+
281
+ Assert . AreEqual ( "Token 1" , tokenBox . Items [ 0 ] ) ;
282
+ Assert . AreEqual ( "Token 2" , tokenBox . Items [ 1 ] ) ;
283
+ } ) ;
284
+ }
285
+
286
+ [ TestCategory ( "Test_TokenizingTextBox_General" ) ]
287
+ [ TestMethod ]
288
+ public async Task Test_SetInitialTextWithDelimiterAll ( )
289
+ {
290
+ await App . DispatcherQueue . EnqueueAsync ( async ( ) =>
291
+ {
292
+ var treeRoot = XamlReader . Load (
293
+ @"<Page
294
+ xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
295
+ xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
296
+ xmlns:controls=""using:Microsoft.Toolkit.Uwp.UI.Controls"">
297
+
298
+ <controls:TokenizingTextBox x:Name=""tokenboxname"" TokenDelimiter="","" Text=""Token 1, Token 2, Token 3, ""/>
299
+
300
+ </Page>" ) as FrameworkElement ;
301
+
302
+ Assert . IsNotNull ( treeRoot , "Could not load XAML tree." ) ;
303
+
304
+ await SetTestContentAsync ( treeRoot ) ;
305
+
306
+ var tokenBox = treeRoot . FindChild ( "tokenboxname" ) as TokenizingTextBox ;
307
+
308
+ Assert . IsNotNull ( tokenBox , "Could not find TokenizingTextBox in tree." ) ;
309
+ Assert . AreEqual ( 1 , tokenBox . Items . Count , "Tokens not created" ) ; // AutoSuggestBox
310
+
311
+ Assert . AreEqual ( "Token 1, Token 2, Token 3, " , tokenBox . Text , "Token text not equal to starting value." ) ;
312
+
313
+ await Task . Delay ( 500 ) ; // TODO: Wait for a loaded event?
314
+
315
+ Assert . AreEqual ( 1 + 3 , tokenBox . Items . Count , "Tokens not created" ) ;
316
+
317
+ // Test initial value of property
318
+ Assert . AreEqual ( string . Empty , tokenBox . Text , "Token text should be blank now." ) ;
319
+
320
+ Assert . AreEqual ( "Token 1" , tokenBox . Items [ 0 ] ) ;
321
+ Assert . AreEqual ( "Token 2" , tokenBox . Items [ 1 ] ) ;
322
+ Assert . AreEqual ( "Token 3" , tokenBox . Items [ 2 ] ) ;
323
+ } ) ;
324
+ }
246
325
}
247
326
}
0 commit comments