Skip to content

Commit 0444ecd

Browse files
committed
Cleanup and refactor TokenizingTextBox automation tests
1 parent 847266c commit 0444ecd

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

components/TokenizingTextBox/tests/Test_TokenizingTextBox_AutomationPeer.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
// See the LICENSE file in the project root for more information.
44

55
using CommunityToolkit.Tests;
6+
using CommunityToolkit.Tooling.TestGen;
67
using CommunityToolkit.WinUI.Automation.Peers;
78
using CommunityToolkit.WinUI.Controls;
89

910
namespace TokenizingTextBoxExperiment.Tests;
1011

1112
[TestClass]
1213
[TestCategory("Test_TokenizingTextBox")]
13-
public class Test_TokenizingTextBox_AutomationPeer : VisualUITestBase
14+
public partial class Test_TokenizingTextBox_AutomationPeer : VisualUITestBase
1415
{
1516
[TestMethod]
1617
public async Task ShouldConfigureTokenizingTextBoxAutomationPeerAsync()
@@ -83,24 +84,21 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
8384
});
8485
}
8586

86-
[TestMethod]
87+
[UIThreadTestMethod]
8788
public async Task ShouldThrowElementNotEnabledExceptionIfValueSetWhenDisabled()
8889
{
89-
await App.DispatcherQueue.EnqueueAsync(async () =>
90-
{
91-
const string expectedValue = "Wor";
90+
const string expectedValue = "Wor";
9291

93-
var tokenizingTextBox = new TokenizingTextBox { IsEnabled = false };
92+
var tokenizingTextBox = new TokenizingTextBox { IsEnabled = false };
9493

95-
await LoadTestContentAsync(tokenizingTextBox);
94+
await LoadTestContentAsync(tokenizingTextBox);
9695

97-
var tokenizingTextBoxAutomationPeer =
98-
FrameworkElementAutomationPeer.CreatePeerForElement(tokenizingTextBox) as TokenizingTextBoxAutomationPeer;
96+
var tokenizingTextBoxAutomationPeer =
97+
FrameworkElementAutomationPeer.CreatePeerForElement(tokenizingTextBox) as TokenizingTextBoxAutomationPeer;
9998

100-
Assert.ThrowsException<ElementNotEnabledException>(() =>
101-
{
102-
tokenizingTextBoxAutomationPeer!.SetValue(expectedValue);
103-
});
99+
Assert.ThrowsException<ElementNotEnabledException>(() =>
100+
{
101+
tokenizingTextBoxAutomationPeer!.SetValue(expectedValue);
104102
});
105103
}
106104

0 commit comments

Comments
 (0)