From b1cbf3b6baab735321de2b5410dc0dee4ecdba8b Mon Sep 17 00:00:00 2001 From: "Xiaofeng Wang (from Dev Box)" Date: Mon, 10 Mar 2025 16:50:53 +0800 Subject: [PATCH] Update IsTrue to alternative methods --- src/common/UITestAutomation/Session.cs | 2 +- src/modules/Hosts/Hosts.UITests/HostModuleTests.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/UITestAutomation/Session.cs b/src/common/UITestAutomation/Session.cs index ef0a6fff3f..50dad00596 100644 --- a/src/common/UITestAutomation/Session.cs +++ b/src/common/UITestAutomation/Session.cs @@ -44,7 +44,7 @@ namespace Microsoft.PowerToys.UITest // leverage findAll to filter out mismatched elements var collection = this.FindAll(by, timeoutMS); - Assert.IsTrue(collection.Count > 0, $"Element not found using selector: {by}"); + Assert.AreNotEqual(0, collection.Count, $"Element not found using selector: {by}"); return collection[0]; } diff --git a/src/modules/Hosts/Hosts.UITests/HostModuleTests.cs b/src/modules/Hosts/Hosts.UITests/HostModuleTests.cs index c50bbe988e..e9af64d9be 100644 --- a/src/modules/Hosts/Hosts.UITests/HostModuleTests.cs +++ b/src/modules/Hosts/Hosts.UITests/HostModuleTests.cs @@ -125,8 +125,9 @@ namespace Hosts.UITests // Add new URL override and a warning tip should be shown this.AddEntry("192.168.0.1", "localhost", true); - Assert.IsTrue( - this.FindAll("The hosts file cannot be saved because the program isn't running as administrator.").Count == 1, + Assert.AreEqual( + 1, + this.FindAll("The hosts file cannot be saved because the program isn't running as administrator.").Count, "Should display host-file saving error if not run as administrator"); }