diff --git a/src/NetMQ.Tests/NetMQMonitorTests.cs b/src/NetMQ.Tests/NetMQMonitorTests.cs index c21c05531..a4d3708ad 100644 --- a/src/NetMQ.Tests/NetMQMonitorTests.cs +++ b/src/NetMQ.Tests/NetMQMonitorTests.cs @@ -68,7 +68,7 @@ public void StartAsync() Thread.Sleep(200); Assert.Equal(TaskStatus.Running, task.Status); monitor.Stop(); - Assert.True(Utils.Tasks.Wait(task, TimeSpan.FromMilliseconds(1000))); + Assert.True(TaskUtils.Wait(task, TimeSpan.FromMilliseconds(1000))); } } #endif @@ -154,7 +154,7 @@ public void MonitorDisposeProperlyWhenDisposedAfterMonitoredTcpSocket() } Thread.Sleep(100); // Monitor.Dispose should complete - var completed = Utils.Tasks.Wait(Task.Factory.StartNew(() => monitor.Dispose()), TimeSpan.FromMilliseconds(1000)); + var completed = TaskUtils.Wait(Task.Factory.StartNew(() => monitor.Dispose()), TimeSpan.FromMilliseconds(1000)); Assert.True(completed); } // NOTE If this test fails, it will hang because context.Dispose will block diff --git a/src/NetMQ.Tests/NetMQPollerTest.cs b/src/NetMQ.Tests/NetMQPollerTest.cs index 841ca75e8..7f2c599f5 100644 --- a/src/NetMQ.Tests/NetMQPollerTest.cs +++ b/src/NetMQ.Tests/NetMQPollerTest.cs @@ -395,7 +395,7 @@ public void RemoveSocket() poller.Stop(); // await the pollerTask, 1ms should suffice - Utils.Tasks.Wait(pollerTask, TimeSpan.FromMilliseconds(1)); + TaskUtils.Wait(pollerTask, TimeSpan.FromMilliseconds(1)); Assert.True(pollerTask.IsCompleted); } } @@ -879,7 +879,7 @@ public void OneTask() Assert.True(poller.CanExecuteTaskInline, "Should be on NetMQPoller thread"); }); task.Start(poller); - Utils.Tasks.Wait(task); + TaskUtils.Wait(task); Assert.True(triggered); } @@ -894,7 +894,7 @@ public void SetsCurrentTaskScheduler() var task = new Task(() => Assert.Same(TaskScheduler.Current, poller)); task.Start(poller); - Utils.Tasks.Wait(task); + TaskUtils.Wait(task); } } @@ -911,7 +911,7 @@ public void CanExecuteTaskInline() var task = new Task(() => Assert.True(poller.CanExecuteTaskInline)); task.Start(poller); - Utils.Tasks.Wait(task); + TaskUtils.Wait(task); } } @@ -941,8 +941,8 @@ public void ContinueWith() }, poller); task.Start(poller); - Utils.Tasks.Wait(task); - Utils.Tasks.Wait(task2); + TaskUtils.Wait(task); + TaskUtils.Wait(task2); Assert.Equal(threadId1, threadId2); Assert.Equal(1, runCount1); @@ -982,9 +982,9 @@ public void TwoThreads() } }); - Utils.Tasks.Wait(t1, TimeSpan.FromMilliseconds(1000)); - Utils.Tasks.Wait(t2, TimeSpan.FromMilliseconds(1000)); - Utils.Tasks.WaitAll(allTasks.ToArray(), TimeSpan.FromMilliseconds(1000)); + TaskUtils.Wait(t1, TimeSpan.FromMilliseconds(1000)); + TaskUtils.Wait(t2, TimeSpan.FromMilliseconds(1000)); + TaskUtils.WaitAll(allTasks.ToArray(), TimeSpan.FromMilliseconds(1000)); Assert.Equal(100, count1); Assert.Equal(100, count2); diff --git a/src/NetMQ.Tests/NetMQQueueTests.cs b/src/NetMQ.Tests/NetMQQueueTests.cs index 3d3696a83..7540d9b38 100644 --- a/src/NetMQ.Tests/NetMQQueueTests.cs +++ b/src/NetMQ.Tests/NetMQQueueTests.cs @@ -39,7 +39,7 @@ public void EnqueueShouldNotBlockWhenCapacityIsZero() } }); - bool completed = Utils.Tasks.Wait(task, TimeSpan.FromSeconds(1)); + bool completed = TaskUtils.Wait(task, TimeSpan.FromSeconds(1)); Assert.True(completed, "Enqueue task should have completed " + socketWatermarkCapacity + " enqueue within 1 second"); } } diff --git a/src/NetMQ.Tests/PgmTests.cs b/src/NetMQ.Tests/PgmTests.cs index c8126146f..d9b38aa58 100644 --- a/src/NetMQ.Tests/PgmTests.cs +++ b/src/NetMQ.Tests/PgmTests.cs @@ -230,8 +230,8 @@ public void Sending1000Messages() } }); - Utils.Tasks.Wait(pubTask); - Utils.Tasks.Wait(subTask); + TaskUtils.Wait(pubTask); + TaskUtils.Wait(subTask); Assert.Equal(1000, count); } @@ -291,7 +291,7 @@ public void SubscriberCleanupOnUnbind(string address) monitor.Stop(); - Utils.Tasks.Wait(monitorTask); + TaskUtils.Wait(monitorTask); } } } diff --git a/src/NetMQ.Tests/SocketTests.cs b/src/NetMQ.Tests/SocketTests.cs index 63080cfda..4a0c3e241 100644 --- a/src/NetMQ.Tests/SocketTests.cs +++ b/src/NetMQ.Tests/SocketTests.cs @@ -134,7 +134,7 @@ public void ReceiveMessageWithTimeout() t1.Start(); t2.Start(); - Utils.Tasks.WaitAll(new[]{t1, t2}); + TaskUtils.WaitAll(new[]{t1, t2}); } } diff --git a/src/NetMQ/Utils/Tasks.cs b/src/NetMQ.Tests/TaskUtils.cs similarity index 93% rename from src/NetMQ/Utils/Tasks.cs rename to src/NetMQ.Tests/TaskUtils.cs index 49fd820ba..56b34d23c 100644 --- a/src/NetMQ/Utils/Tasks.cs +++ b/src/NetMQ.Tests/TaskUtils.cs @@ -1,13 +1,11 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; -namespace NetMQ.Utils +namespace NetMQ.Tests { - internal class Tasks + internal class TaskUtils { internal static async Task PollUntil(Func condition, TimeSpan timeout) {