Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Restrict monitor events in tests.

This prevents hanging event messages from blowing up context objects
during test disposal.
  • Loading branch information...
commit 884dfcf62678db4883e96c2b99988434d2666b35 1 parent 9e8e863
John Gozde jgoz authored
12 src/ZeroMQ.AcceptanceTests/MonitorFixtures.cs
View
@@ -15,6 +15,8 @@ public abstract class UsingMonitor
protected ZmqMonitor ReqMonitor;
protected ZmqMonitor RepMonitor;
+ protected MonitorEvents ReqEvents;
+ protected MonitorEvents RepEvents;
protected Thread ReqThread;
protected Thread RepThread;
protected ZmqSocket Req;
@@ -33,17 +35,17 @@ public void Initialize()
RepMonitor = RepContext.CreateMonitorSocket(RepEndpoint);
Req = ReqContext.CreateSocket(SocketType.REQ);
Rep = RepContext.CreateSocket(SocketType.REP);
- Req.Monitor(ReqEndpoint);
- Rep.Monitor(RepEndpoint);
+ Req.Monitor(ReqEndpoint, ReqEvents);
+ Rep.Monitor(RepEndpoint, RepEvents);
EventRecorded = new ManualResetEvent(false);
ReqThread = new Thread(ReqMonitor.Start);
RepThread = new Thread(RepMonitor.Start);
- ReqThread.Start();
- RepThread.Start();
-
Fired = false;
Address = null;
+
+ ReqThread.Start();
+ RepThread.Start();
}
[TestFixtureTearDown]
26 src/ZeroMQ.AcceptanceTests/ZmqMonitorTests/MonitorEvents.cs
View
@@ -2,12 +2,18 @@
{
using System;
using NUnit.Framework;
+ using ZeroMQ.Monitoring;
[TestFixture]
public class MonitorTests
{
public class WhenMonitoringListeningEvent : UsingMonitorFd
{
+ public WhenMonitoringListeningEvent()
+ {
+ RepEvents = MonitorEvents.Listening;
+ }
+
[TestFixtureSetUp]
public void SetUp()
{
@@ -41,6 +47,11 @@ public void ShouldReturnASocketPointer()
public class WhenMonitoringAcceptedEvent : UsingMonitorFd
{
+ public WhenMonitoringAcceptedEvent()
+ {
+ RepEvents = MonitorEvents.Accepted;
+ }
+
[TestFixtureSetUp]
public void SetUp()
{
@@ -75,6 +86,11 @@ public void ShouldReturnASocketPointer()
public class WhenMonitoringAcceptedEventBeforeAConnectionIsMade : UsingMonitorFd
{
+ public WhenMonitoringAcceptedEventBeforeAConnectionIsMade()
+ {
+ RepEvents = MonitorEvents.Accepted;
+ }
+
[TestFixtureSetUp]
public void SetUp()
{
@@ -92,6 +108,11 @@ public void ShouldNotFireTheAcceptedEvent()
public class WhenMonitoringConnectedEvent : UsingMonitorFd
{
+ public WhenMonitoringConnectedEvent()
+ {
+ ReqEvents = MonitorEvents.Connected;
+ }
+
[TestFixtureSetUp]
public void SetUp()
{
@@ -126,6 +147,11 @@ public void ShouldReturnASocketPointer()
public class WhenMonitoringClosedEvent : UsingMonitorFd
{
+ public WhenMonitoringClosedEvent()
+ {
+ RepEvents = MonitorEvents.Closed;
+ }
+
[TestFixtureSetUp]
public void SetUp()
{
1  src/ZeroMQ/Monitoring/ZmqMonitor.cs
View
@@ -150,6 +150,7 @@ public void Start()
}
Marshal.FreeHGlobal(ptr);
+ _socket.Disconnect(_endpoint);
}
/// <summary>
Please sign in to comment.
Something went wrong with that request. Please try again.