diff --git a/components/ColorPicker/tests/ExampleColorPickerTestClass.cs b/components/ColorPicker/tests/ExampleColorPickerTestClass.cs index 7f770e8d..b0a73ed2 100644 --- a/components/ColorPicker/tests/ExampleColorPickerTestClass.cs +++ b/components/ColorPicker/tests/ExampleColorPickerTestClass.cs @@ -97,23 +97,22 @@ await EnqueueAsync(() => // If you want to load other content not within a XAML page using the UIThreadTestMethod above. // Then you can do that using the Load/UnloadTestContentAsync methods. - [TestMethod] + [UIThreadTestMethod] public async Task ComplexAsyncLoadUIExampleTest() { - await EnqueueAsync(async () => - { - var component = new ColorPicker(); - Assert.IsNotNull(component); - Assert.IsFalse(component.IsLoaded); + var component = new ColorPicker(); + Assert.IsNotNull(component); + Assert.IsFalse(component.IsLoaded); - await LoadTestContentAsync(component); + await LoadTestContentAsync(component); + await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { }); - Assert.IsTrue(component.IsLoaded); + Assert.IsTrue(component.IsLoaded); - await UnloadTestContentAsync(component); + await UnloadTestContentAsync(component); + await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { }); - Assert.IsFalse(component.IsLoaded); - }); + Assert.IsFalse(component.IsLoaded); } // You can still use the UIThreadTestMethod to remove the extra layer for the dispatcher as well: diff --git a/components/Sizers/tests/ExampleSizerBaseTestClass.cs b/components/Sizers/tests/ExampleSizerBaseTestClass.cs index f8cb5619..658c7a01 100644 --- a/components/Sizers/tests/ExampleSizerBaseTestClass.cs +++ b/components/Sizers/tests/ExampleSizerBaseTestClass.cs @@ -12,25 +12,24 @@ namespace SizersTests; [TestClass] public partial class ExampleSizerBaseTestClass : VisualUITestBase { - [TestMethod] + [UIThreadTestMethod] public async Task ShouldConfigureGridSplitterAutomationPeer() { - await EnqueueAsync(() => - { - const string automationName = "MyCustomAutomationName"; - const string name = "Sizer"; + const string automationName = "MyCustomAutomationName"; + const string name = "Sizer"; - var gridSplitter = new GridSplitter(); - var gridSplitterAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(gridSplitter) as SizerAutomationPeer; + var gridSplitter = new GridSplitter(); + var gridSplitterAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(gridSplitter) as SizerAutomationPeer; - Assert.IsNotNull(gridSplitterAutomationPeer, "Verify that the AutomationPeer is SizerAutomationPeer."); + Assert.IsNotNull(gridSplitterAutomationPeer, "Verify that the AutomationPeer is SizerAutomationPeer."); - gridSplitter.Name = name; - Assert.IsTrue(gridSplitterAutomationPeer.GetName().Contains(name), "Verify that the UIA name contains the given Name of the GridSplitter (Sizer)."); + gridSplitter.Name = name; + await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { }); + Assert.IsTrue(gridSplitterAutomationPeer.GetName().Contains(name), "Verify that the UIA name contains the given Name of the GridSplitter (Sizer)."); - gridSplitter.SetValue(AutomationProperties.NameProperty, automationName); - Assert.IsTrue(gridSplitterAutomationPeer.GetName().Contains(automationName), "Verify that the UIA name contains the customized AutomationProperties.Name of the GridSplitter."); - }); + gridSplitter.SetValue(AutomationProperties.NameProperty, automationName); + await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { }); + Assert.IsTrue(gridSplitterAutomationPeer.GetName().Contains(automationName), "Verify that the UIA name contains the customized AutomationProperties.Name of the GridSplitter."); } [UIThreadTestMethod]