Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ffb1698

Browse files
danmoseleystephentoub
authored andcommitted
Increase window for process start time test (#28852)
1 parent 4739720 commit ffb1698

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/System.Diagnostics.Process/tests/ProcessThreadTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void TestStartTimeProperty_OSX()
9090
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Retrieving information about local processes is not supported on uap")]
9191
public async Task TestStartTimeProperty()
9292
{
93-
TimeSpan allowedWindow = TimeSpan.FromSeconds(1);
93+
TimeSpan allowedWindow = TimeSpan.FromSeconds(2);
9494

9595
using (Process p = Process.GetCurrentProcess())
9696
{
@@ -129,7 +129,8 @@ await Task.Factory.StartNew(() =>
129129
p.Refresh();
130130
try
131131
{
132-
Assert.Contains(p.Threads.Cast<ProcessThread>(), t => t.StartTime.ToUniversalTime() >= curTime - allowedWindow);
132+
var newest = p.Threads.Cast<ProcessThread>().OrderBy(t => t.StartTime.ToUniversalTime()).Last();
133+
Assert.InRange(newest.StartTime.ToUniversalTime(), curTime - allowedWindow, DateTime.Now.ToUniversalTime() + allowedWindow);
133134
}
134135
catch (InvalidOperationException)
135136
{

0 commit comments

Comments
 (0)