Skip to content

Commit

Permalink
Stabilize date time test (#15626)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 authored Nov 14, 2024
1 parent f532ef9 commit 2c09b9d
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/DynamoCoreWpfTests/WebRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

using WebRequest = CoreNodeModels.WebRequest;
using Dynamo.Graph.Nodes.ZeroTouch;
using System.Threading.Tasks;
using System.Threading;
using DynamoCoreWpfTests.Utility;

namespace DynamoCoreWpfTests
{
Expand Down Expand Up @@ -70,7 +73,7 @@ public void WebRequest()
}

[Test]
public void DateTimeNow()
public Task DateTimeNow()
{
var openPath = Path.Combine(GetTestDirectory(ExecutingDirectory), @"core\periodic_update\datetimenow.dyn");
ViewModel.OpenCommand.Execute(openPath);
Expand All @@ -83,19 +86,21 @@ public void DateTimeNow()

var time1 = GetPreviewValue(guid).ToString();

var stopWatch = new Stopwatch();
stopWatch.Start();

// Switch to periodic mode
// Switch to periodic mode.
ws.RunSettings.RunPeriod = 100;
ws.RunSettings.RunType = RunType.Periodic;

while (stopWatch.Elapsed.Seconds <= 1) { }
var task = Task.Run(() =>
{
Thread.Sleep(1000);
}).ContinueWith((t) =>
{
var time2 = GetPreviewValue(guid).ToString();
Assert.AreNotEqual(time1, time2);
stopWatch.Stop();
var time2 = GetPreviewValue(guid).ToString();
}, TaskScheduler.FromCurrentSynchronizationContext());

Assert.AreNotEqual(time1, time2);
return task;
}


Expand Down

0 comments on commit 2c09b9d

Please sign in to comment.