Skip to content

Commit

Permalink
chore: DON'T assert in async void
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Feb 21, 2025
1 parent e47e107 commit a1a4727
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Uno.Toolkit.RuntimeTests.Tests
{
[TestClass]
[RunsOnUIThread]
partial class ItemsRepeaterExtensionsTests
public partial class ItemsRepeaterExtensionsTests
{
private const ItemsSelectionMode Single = ItemsSelectionMode.Single;

Expand Down
15 changes: 10 additions & 5 deletions src/Uno.Toolkit.RuntimeTests/Tests/NavigationBarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Uno.Disposables;
Expand Down Expand Up @@ -93,13 +94,12 @@ public async Task MainCommand_In_Popup_Without_Page(MainCommandMode mainCommandM
var popup = new Popup { Width = 100, Height = 100, HorizontalOffset = 100, VerticalOffset = 100, Child = new StackPanel { Children = { navigationBar } } };
var content = new StackPanel { Children = { popup } };

EventHandler<object> popupOpened = async (s, e) =>
var autoResetEvent = new AutoResetEvent(false);

EventHandler<object> popupOpened = (s, e) =>
{
Assert.IsTrue(navigationBar.TryPerformMainCommand() == shouldGoBack, "Unexpected result from TryPerformMainCommand");

await UnitTestsUIContentHelper.WaitForIdle();

Assert.IsTrue(popup.IsOpen == !shouldGoBack, "Popup is in an incorrect state");
autoResetEvent.Set();
};

try
Expand All @@ -108,6 +108,11 @@ public async Task MainCommand_In_Popup_Without_Page(MainCommandMode mainCommandM

popup.Opened += popupOpened;
popup.IsOpen = true;

autoResetEvent.WaitOne();
await UnitTestsUIContentHelper.WaitForIdle();

Assert.IsTrue(popup.IsOpen == !shouldGoBack, "Popup is in an incorrect state");
}
finally
{
Expand Down

0 comments on commit a1a4727

Please sign in to comment.