public void TimesOutAfterTimeoutElapses_SpinWait_BeGreaterOrEqualTo() { var elapsed = PerformanceDiagnostics.Time(() => { SHSpinWait.SpinUntil(() => true == false, TimeSpan.FromMilliseconds(50)); }); //Because of the way spinuntil works there is a slight margin of error, this checks it's within that margin elapsed.Should().BeGreaterOrEqualTo(TimeSpan.FromMilliseconds(30)).And.BeLessOrEqualTo(TimeSpan.FromMilliseconds(70)); }
public void ElementNotFoundWaitsForTimeout_Find_BeGreaterOrEqualTo() { using var calc = Application.LaunchStoreApp("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); using var automation = new UIA3Automation(); var window = calc.GetMainWindow(automation); Action act = () => window.Find(x => x.ByAutomationId("nonExistentId"), TimeSpan.FromSeconds(5)); var elapsed = PerformanceDiagnostics.Time(() => { act.Should().Throw <ElementNotFoundException>(); }); elapsed.Should().BeGreaterOrEqualTo(TimeSpan.FromSeconds(4.9)).And.BeLessOrEqualTo(TimeSpan.FromSeconds(6)); }