Skip to content

Commit

Permalink
I Cry
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-dmxc committed May 10, 2024
1 parent 8d27c38 commit 7bc6631
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions ArtNetTests/LoopTests/ControllerToControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,25 @@ public void OneTimeSetUp()
}

artNet.AddInstance([instanceTX, instanceRX]);
CancellationTokenSource cts = new CancellationTokenSource(30000);
initialTask = Task.Run(async () =>
}

private async Task init()
{
DateTime startTime= DateTime.UtcNow;
while ((DateTime.UtcNow - startTime).TotalSeconds < 12 && (rcRX == null || rcTX == null) && !(artNet.IsDisposed || artNet.IsDisposing))
{
while ((rcRX == null || rcTX == null) && !(artNet.IsDisposed || artNet.IsDisposing))
{
await Task.Delay(100);
rcRX ??= instanceTX.RemoteClients.FirstOrDefault(rc => rc.LongName.Equals(instanceRX.Name));
rcTX ??= instanceRX.RemoteClients.FirstOrDefault(rc => rc.LongName.Equals(instanceTX.Name));
foreach (var rc in instanceTX.RemoteClients)
Logger.LogTrace($"{nameof(instanceTX)} has {rc}");
foreach (var rc in instanceRX.RemoteClients)
Logger.LogTrace($"{nameof(instanceRX)} has {rc}");
Logger.LogTrace($"{nameof(rcRX)} is {rcRX}");
Logger.LogTrace($"{nameof(rcTX)} is {rcTX}");
if (rcRX != null && rcTX != null && rcRX.IpAddress != rcTX.IpAddress)
rcTX ??= instanceRX.RemoteClients.FirstOrDefault(rc => rc.IpAddress.Equals(rcRX.IpAddress));
}
}, cts.Token);
await Task.Delay(100);
rcRX ??= instanceTX.RemoteClients.FirstOrDefault(rc => rc.LongName.Equals(instanceRX.Name));
rcTX ??= instanceRX.RemoteClients.FirstOrDefault(rc => rc.LongName.Equals(instanceTX.Name));
foreach (var rc in instanceTX.RemoteClients)
Logger.LogTrace($"{nameof(instanceTX)} has {rc}");
foreach (var rc in instanceRX.RemoteClients)
Logger.LogTrace($"{nameof(instanceRX)} has {rc}");
Logger.LogTrace($"{nameof(rcRX)} is {rcRX}");
Logger.LogTrace($"{nameof(rcTX)} is {rcTX}");
if (rcRX != null && rcTX != null && rcRX.IpAddress != rcTX.IpAddress)
rcTX ??= instanceRX.RemoteClients.FirstOrDefault(rc => rc.IpAddress.Equals(rcRX.IpAddress));
}
}

[OneTimeTearDown]
Expand All @@ -89,6 +90,7 @@ public void OneTimeTearDown()
[Test, Order(1)]
public async Task TestLoopDetection()
{
initialTask ??= init();
await initialTask;
Logger.LogDebug(nameof(TestLoopDetection));
Assert.Multiple(() =>
Expand Down Expand Up @@ -120,6 +122,7 @@ public async Task TestLoopDetection()
[Test, Order(2)]
public async Task TestSendDMX()
{
initialTask ??= init();
await initialTask;
Logger.LogDebug(nameof(TestSendDMX));
Assert.Multiple(() =>
Expand Down Expand Up @@ -196,6 +199,7 @@ void InstanceRX_DMXReceived(object? sender, PortAddress e)
[Test, Order(3)]
public async Task TestSendDMXTiming()
{
initialTask ??= init();
await initialTask;
Logger.LogDebug(nameof(TestSendDMXTiming));
//if(ArtNetSharp.Tools.IsRunningOnGithubWorker())
Expand Down

0 comments on commit 7bc6631

Please sign in to comment.