-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from somdoron/master
cherry picks fixes from NetMQ4
- Loading branch information
Showing
12 changed files
with
208 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using NetMQ.Sockets; | ||
using NUnit.Framework; | ||
|
||
namespace NetMQ.Tests | ||
{ | ||
[TestFixture] | ||
public class CleanupTests | ||
{ | ||
[Test] | ||
public void Block() | ||
{ | ||
const int count = 1000; | ||
|
||
NetMQConfig.Linger = TimeSpan.FromSeconds(0.5); | ||
|
||
using (var client = new DealerSocket(">tcp://localhost:5557")) | ||
{ | ||
// Sending a lot of messages | ||
client.Options.SendHighWatermark = count; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
client.SendFrame("Hello"); | ||
} | ||
} | ||
|
||
Stopwatch stopwatch = Stopwatch.StartNew(); | ||
NetMQConfig.Cleanup(); | ||
stopwatch.Stop(); | ||
|
||
Assert.Greater(stopwatch.ElapsedMilliseconds, 500); | ||
} | ||
|
||
[Test] | ||
public void NoBlock() | ||
{ | ||
const int count = 1000; | ||
|
||
NetMQConfig.Linger = TimeSpan.FromSeconds(0.5); | ||
|
||
using (var client = new DealerSocket(">tcp://localhost:5557")) | ||
{ | ||
// Sending a lot of messages | ||
client.Options.SendHighWatermark = count; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
client.SendFrame("Hello"); | ||
} | ||
} | ||
|
||
Stopwatch stopwatch = Stopwatch.StartNew(); | ||
NetMQConfig.Cleanup(false); | ||
stopwatch.Stop(); | ||
|
||
Assert.Less(stopwatch.ElapsedMilliseconds, 500); | ||
} | ||
|
||
[Test] | ||
public void NoBlockNoDispose() | ||
{ | ||
var client = new DealerSocket(">tcp://localhost:5557"); | ||
NetMQConfig.Cleanup(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
|
||
namespace NetMQ.Tests | ||
{ | ||
[SetUpFixture] | ||
public class Setup | ||
{ | ||
[TearDown] | ||
public void TearDown() | ||
{ | ||
NetMQConfig.Cleanup(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.