diff --git a/UnitTests/UnitTests.UWP/UI/Controls/Test_TokenizingTextBox_General.cs b/UnitTests/UnitTests.UWP/UI/Controls/Test_TokenizingTextBox_General.cs index aa908ac5384..2fef71b8b57 100644 --- a/UnitTests/UnitTests.UWP/UI/Controls/Test_TokenizingTextBox_General.cs +++ b/UnitTests/UnitTests.UWP/UI/Controls/Test_TokenizingTextBox_General.cs @@ -5,6 +5,7 @@ using Microsoft.Toolkit.Uwp; using Microsoft.Toolkit.Uwp.UI; using Microsoft.Toolkit.Uwp.UI.Controls; +using Microsoft.Toolkit.Uwp.UI.Helpers; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; using System.Threading.Tasks; @@ -201,6 +202,51 @@ await App.DispatcherQueue.EnqueueAsync(async () => }); } + [TestCategory("Test_TokenizingTextBox_General")] + [TestMethod] + public async Task Test_ChangeText() + { + await App.DispatcherQueue.EnqueueAsync(async () => + { + var treeRoot = XamlReader.Load( +@" + + + +") as FrameworkElement; + + Assert.IsNotNull(treeRoot, "Could not load XAML tree."); + + await SetTestContentAsync(treeRoot); + + var tokenBox = treeRoot.FindChild("tokenboxname") as TokenizingTextBox; + + Assert.IsNotNull(tokenBox, "Could not find TokenizingTextBox in tree."); + Assert.AreEqual(1, tokenBox.Items.Count, "Token default items failed"); // AutoSuggestBox + + // Test initial value of property + Assert.AreEqual(string.Empty, tokenBox.Text, "Text should start as empty."); + + // Reach into AutoSuggestBox's text to check it was set properly + var autoSuggestBox = tokenBox.FindDescendant(); + + Assert.IsNotNull(autoSuggestBox, "Could not find inner autosuggestbox"); + Assert.AreEqual(string.Empty, autoSuggestBox.Text, "Inner text not set based on initial value of TokenizingTextBox"); + + // Change Text + tokenBox.Text = "New Text"; + + // Wait for update + await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { }); + + Assert.AreEqual("New Text", tokenBox.Text, "Text should be changed now."); + Assert.AreEqual("New Text", autoSuggestBox.Text, "Inner text not set based on value of TokenizingTextBox"); + }); + } + [TestCategory("Test_TokenizingTextBox_General")] [TestMethod] public async Task Test_ClearText()