Browse files

Merge branch 'spike-tests'

  • Loading branch information...
2 parents e0bc587 + 054af1a commit 51734c8e92ec7a4a90f5bda86928abf53f976b4e @jgoz jgoz committed Dec 13, 2011
View
3 .gitignore
@@ -2,6 +2,9 @@ clrzmq.userprefs
obj
bin
!/bin
+/packages
+nuget.exe
+lib/**/libzmq.dll
*.pidb
*.suo
_ReSharper.*
View
BIN bin/nuget/nuget-bootstrap.exe
Binary file not shown.
View
19 clrzmq.5.1.ReSharper
@@ -390,6 +390,25 @@
<ExtraRule Prefix="" Suffix="" Style="AA_BB" />
</PredefinedRule>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
+ <UserRule Inspect="True" Prefix="" Suffix="" Style="AaBb" StaticnessKind="Static, Instance" AccessRight="Private, Protected, ProtectedInternal, Internal, Public" Description="">
+ <ElementKinds>
+ <Kind Name="CLASS" />
+ <Kind Name="Machine.Specifications_Behavior" />
+ <Kind Name="Machine.Specifications_Context" />
+ <Kind Name="Machine.Specifications_ContextBase" />
+ <Kind Name="Machine.Specifications_Specification" />
+ <Kind Name="Machine.Specifications_SupportingField" />
+ <Kind Name="Machine.Specifications_Constant" />
+ </ElementKinds>
+ <ExtraRule Prefix="" Suffix="" Style="aa_bb" />
+ </UserRule>
+ <UserRule Inspect="True" Prefix="" Suffix="" Style="aaBb" StaticnessKind="Static, Instance" AccessRight="Private, Protected, ProtectedInternal, Internal, Public" Description="">
+ <ElementKinds>
+ <Kind Name="Machine.Specifications_Field" />
+ <Kind Name="Machine.Specifications_Local" />
+ </ElementKinds>
+ <ExtraRule Prefix="" Suffix="" Style="AaBb" />
+ </UserRule>
<Abbreviation Text="MQ" />
<Abbreviation Text="ZMQ" />
<Abbreviation Text="IO" />
View
59 clrzmq.sln
@@ -34,6 +34,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncReturn", "tests\AsyncR
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkerPool", "tests\WorkerPool\WorkerPool.csproj", "{45D99DFA-FB55-4765-BB8B-B05C69D431E7}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AcceptanceTests", "tests\AcceptanceTests\AcceptanceTests.csproj", "{7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
POSIX_DEBUG|x64 = POSIX_DEBUG|x64
@@ -126,67 +128,84 @@ Global
{FE6D6CDD-8A04-4A3A-A654-5C687AB724E3}.WIN_RELEASE|x64.Build.0 = WIN_RELEASE|x64
{FE6D6CDD-8A04-4A3A-A654-5C687AB724E3}.WIN_RELEASE|x86.ActiveCfg = WIN_RELEASE|x86
{FE6D6CDD-8A04-4A3A-A654-5C687AB724E3}.WIN_RELEASE|x86.Build.0 = WIN_RELEASE|x86
- {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x64.ActiveCfg = Release|x64
- {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x64.Build.0 = Release|x64
- {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x86.ActiveCfg = Release|x86
- {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x86.Build.0 = Release|x86
+ {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x64.ActiveCfg = Debug|x64
+ {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x64.Build.0 = Debug|x64
+ {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x86.ActiveCfg = Debug|x86
+ {7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_DEBUG|x86.Build.0 = Debug|x86
{7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_RELEASE|x64.ActiveCfg = Release|x64
{7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_RELEASE|x64.Build.0 = Release|x64
{7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_RELEASE|x86.ActiveCfg = Release|x86
{7203CF55-A452-407E-B767-4AA7BA616794}.POSIX_RELEASE|x86.Build.0 = Release|x86
- {7203CF55-A452-407E-B767-4AA7BA616794}.WIN_DEBUG|x64.ActiveCfg = Release|x64
- {7203CF55-A452-407E-B767-4AA7BA616794}.WIN_DEBUG|x64.Build.0 = Release|x64
+ {7203CF55-A452-407E-B767-4AA7BA616794}.WIN_DEBUG|x64.ActiveCfg = Debug|x64
+ {7203CF55-A452-407E-B767-4AA7BA616794}.WIN_DEBUG|x64.Build.0 = Debug|x64
{7203CF55-A452-407E-B767-4AA7BA616794}.WIN_DEBUG|x86.ActiveCfg = Debug|x86
{7203CF55-A452-407E-B767-4AA7BA616794}.WIN_DEBUG|x86.Build.0 = Debug|x86
{7203CF55-A452-407E-B767-4AA7BA616794}.WIN_RELEASE|x64.ActiveCfg = Release|x64
{7203CF55-A452-407E-B767-4AA7BA616794}.WIN_RELEASE|x64.Build.0 = Release|x64
{7203CF55-A452-407E-B767-4AA7BA616794}.WIN_RELEASE|x86.ActiveCfg = Release|x86
{7203CF55-A452-407E-B767-4AA7BA616794}.WIN_RELEASE|x86.Build.0 = Release|x86
- {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x64.ActiveCfg = Release|x64
- {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x64.Build.0 = Release|x64
- {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x86.ActiveCfg = Release|x86
- {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x86.Build.0 = Release|x86
+ {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x64.ActiveCfg = Debug|x64
+ {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x64.Build.0 = Debug|x64
+ {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x86.ActiveCfg = Debug|x86
+ {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_DEBUG|x86.Build.0 = Debug|x86
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_RELEASE|x64.ActiveCfg = Release|x64
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_RELEASE|x64.Build.0 = Release|x64
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_RELEASE|x86.ActiveCfg = Release|x86
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.POSIX_RELEASE|x86.Build.0 = Release|x86
- {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_DEBUG|x64.ActiveCfg = Release|x64
- {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_DEBUG|x64.Build.0 = Release|x64
+ {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_DEBUG|x64.ActiveCfg = Debug|x64
+ {B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_DEBUG|x64.Build.0 = Debug|x64
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_DEBUG|x86.ActiveCfg = Debug|x86
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_DEBUG|x86.Build.0 = Debug|x86
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_RELEASE|x64.ActiveCfg = Release|x64
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_RELEASE|x64.Build.0 = Release|x64
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_RELEASE|x86.ActiveCfg = Release|x86
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93}.WIN_RELEASE|x86.Build.0 = Release|x86
- {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x64.ActiveCfg = Release|x64
- {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x64.Build.0 = Release|x64
- {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x86.ActiveCfg = Release|x86
- {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x86.Build.0 = Release|x86
+ {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x64.ActiveCfg = Debug|x64
+ {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x64.Build.0 = Debug|x64
+ {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x86.ActiveCfg = Debug|x86
+ {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_DEBUG|x86.Build.0 = Debug|x86
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_RELEASE|x64.ActiveCfg = Release|x64
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_RELEASE|x64.Build.0 = Release|x64
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_RELEASE|x86.ActiveCfg = Release|x86
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.POSIX_RELEASE|x86.Build.0 = Release|x86
- {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_DEBUG|x64.ActiveCfg = Release|x64
- {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_DEBUG|x64.Build.0 = Release|x64
+ {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_DEBUG|x64.ActiveCfg = Debug|x64
+ {45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_DEBUG|x64.Build.0 = Debug|x64
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_DEBUG|x86.ActiveCfg = Debug|x86
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_DEBUG|x86.Build.0 = Debug|x86
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_RELEASE|x64.ActiveCfg = Release|x64
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_RELEASE|x64.Build.0 = Release|x64
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_RELEASE|x86.ActiveCfg = Release|x86
{45D99DFA-FB55-4765-BB8B-B05C69D431E7}.WIN_RELEASE|x86.Build.0 = Release|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_DEBUG|x64.ActiveCfg = POSIX_DEBUG|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_DEBUG|x64.Build.0 = POSIX_DEBUG|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_DEBUG|x86.ActiveCfg = POSIX_DEBUG|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_DEBUG|x86.Build.0 = POSIX_DEBUG|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_RELEASE|x64.ActiveCfg = POSIX_RELEASE|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_RELEASE|x64.Build.0 = POSIX_RELEASE|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_RELEASE|x86.ActiveCfg = POSIX_RELEASE|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.POSIX_RELEASE|x86.Build.0 = POSIX_RELEASE|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_DEBUG|x64.ActiveCfg = WIN_DEBUG|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_DEBUG|x64.Build.0 = WIN_DEBUG|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_DEBUG|x86.ActiveCfg = WIN_DEBUG|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_DEBUG|x86.Build.0 = WIN_DEBUG|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_RELEASE|x64.ActiveCfg = WIN_RELEASE|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_RELEASE|x64.Build.0 = WIN_RELEASE|x64
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_RELEASE|x86.ActiveCfg = WIN_RELEASE|x86
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}.WIN_RELEASE|x86.Build.0 = WIN_RELEASE|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {FE6D6CDD-8A04-4A3A-A654-5C687AB724E3} = {30C08BF9-B591-4038-A54E-2D6D70F6EAB7}
- {7203CF55-A452-407E-B767-4AA7BA616794} = {30C08BF9-B591-4038-A54E-2D6D70F6EAB7}
{E30D3D43-99B4-48ED-B060-56D88C77CCD0} = {137A2F03-0D94-40F2-ADC7-3C194B143A78}
{CB79FF77-F94F-4E4B-A860-7BF941EAA2B6} = {137A2F03-0D94-40F2-ADC7-3C194B143A78}
{35C65BA4-86AF-43AE-9159-5CEE9D27C51D} = {137A2F03-0D94-40F2-ADC7-3C194B143A78}
{0AF25616-C9CB-4137-B281-2100161A610C} = {137A2F03-0D94-40F2-ADC7-3C194B143A78}
+ {FE6D6CDD-8A04-4A3A-A654-5C687AB724E3} = {30C08BF9-B591-4038-A54E-2D6D70F6EAB7}
+ {7203CF55-A452-407E-B767-4AA7BA616794} = {30C08BF9-B591-4038-A54E-2D6D70F6EAB7}
{B06D0C3B-37E4-49E8-986A-ABE2DC6A2A93} = {FED23C0F-5417-4B04-BCF3-B18DDDCF15E9}
{45D99DFA-FB55-4765-BB8B-B05C69D431E7} = {FED23C0F-5417-4B04-BCF3-B18DDDCF15E9}
+ {7B12A63E-EC15-4F13-A91C-C03C7E97D8B6} = {FED23C0F-5417-4B04-BCF3-B18DDDCF15E9}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = clrzmq\clrzmq.csproj
View
2 lib/x64/what_to_put_here.txt
@@ -0,0 +1,2 @@
+64-bit libzmq library:
+ - libzmq.dll
View
2 lib/x86/what_to_put_here.txt
@@ -0,0 +1,2 @@
+32-bit libzmq library:
+ - libzmq.dll
View
23 nuget.cmd
@@ -0,0 +1,23 @@
+@echo off
+setlocal
+
+set NUGET_EXE=bin\nuget\nuget.exe
+set NUGET_BOOTSTRAPPER_EXE=bin\nuget\nuget-bootstrap.exe
+set PACKAGE_DIR=packages
+
+if not exist %NUGET_EXE% (goto bootstrap) else (goto install)
+
+:bootstrap
+%NUGET_BOOTSTRAPPER_EXE%
+move %NUGET_BOOTSTRAPPER_EXE% %NUGET_EXE%
+move %NUGET_BOOTSTRAPPER_EXE%.old %NUGET_BOOTSTRAPPER_EXE%
+
+:install
+%NUGET_EXE% update -self
+for /F %%C in ('dir /b /s packages.config') do %NUGET_EXE% install %%C -o %PACKAGE_DIR%
+
+:update
+for /F %%C in ('dir /b /s packages.config') do %NUGET_EXE% update %%C -RepositoryPath %PACKAGE_DIR%
+
+endlocal
+if errorlevel 1 pause else exit
View
13 nuget.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+NUGET_EXE=bin/nuget/nuget.exe
+NUGET_BOOTSTRAPPER_EXE=bin/nuget/nuget-bootstrap.exe
+PACKAGE_DIR=packages
+
+if [ ! -e $NUGET_EXE ]; then
+ mono --runtime=v4.0 $NUGET_BOOTSTRAPPER_EXE
+ mv $NUGET_BOOTSTRAPPER_EXE $NUGET_EXE
+ mv ${NUGET_BOOTSTRAPPER_EXE}.old $NUGET_BOOTSTRAPPER_EXE
+fi
+
+find . -name 'packages.config' -exec mono --runtime=v4.0 $NUGET_EXE install '{}' -o $PACKAGE_DIR \;
View
1 src/clrzmq-ext/clrzmq-ext.csproj
@@ -75,7 +75,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
View
37 src/clrzmq/Socket.cs
@@ -486,7 +486,7 @@ public class Socket : IDisposable {
C.zmq_msg_close(_msg);
break;
}
- if (C.zmq_errno() == 4) {
+ if (C.zmq_errno() == (int)ERRNOS.EINTR) {
continue;
}
if (C.zmq_errno() != (int)ERRNOS.EAGAIN) {
@@ -606,26 +606,50 @@ public class Socket : IDisposable {
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
public Queue<byte[]> RecvAll() {
- return RecvAll(SendRecvOpt.NONE);
+ return RecvAll((Queue<byte[]>)null);
}
/// <summary>
/// Listen for message, retrieving all pending message parts
/// </summary>
+ /// <param name="messages">The queue object to put the message into</param>
+ /// <returns>Queue of message parts</returns>
+ /// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ public Queue<byte[]> RecvAll(Queue<byte[]> messages) {
+ if (messages == null) {
+ messages = new Queue<byte[]>();
+ }
+
+ messages.Enqueue(Recv());
+ while (RcvMore) {
+ messages.Enqueue(Recv());
+ }
+ return messages;
+ }
+
+ /// <summary>
+ /// DO NOT USE. Left in for backward compatibility, but SendRecvOpt flags are
+ /// not compatible with RecvAll.
+ /// Listen for message, retrieving all pending message parts.
+ /// </summary>
/// <param name="flags">Receive options</param>
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ [Obsolete("Will be removed in version 3.x.")]
public Queue<byte[]> RecvAll(params SendRecvOpt[] flags) {
return RecvAll((Queue<byte[]>)null, flags);
}
/// <summary>
- /// Listen for message, retrieving all pending message parts
+ /// DO NOT USE. Left in for backward compatibility, but SendRecvOpt flags are
+ /// not compatible with RecvAll.
+ /// Listen for message, retrieving all pending message parts.
/// </summary>
/// <param name="messages">The queue object to put the message into</param>
/// <param name="flags">Receive options</param>
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ [Obsolete("Will be removed in version 3.x.")]
public Queue<byte[]> RecvAll(Queue<byte[]> messages, params SendRecvOpt[] flags) {
if (messages == null) {
messages = new Queue<byte[]>();
@@ -654,14 +678,15 @@ public class Socket : IDisposable {
}
/// <summary>
- /// Listen for message, retrieving all pending message parts. DO NOT
- /// USE, left for backwards compatibility reasons but the sendrecvopts
- /// are not compatible with receiving all messages.
+ /// DO NOT USE. Left in for backward compatibility, but SendRecvOpt flags are
+ /// not compatible with RecvAll.
+ /// Listen for message, retrieving all pending message parts.
/// </summary>
/// <param name="encoding">String Encoding</param>
/// <param name="flags">Socket options to use when receiving</param>
/// <returns>Queue of message parts</returns>
/// <exception cref="ZMQ.Exception">ZMQ Exception</exception>
+ [Obsolete("Will be removed in version 3.x.")]
public Queue<string> RecvAll(Encoding encoding, params SendRecvOpt[] flags) {
var messages = new Queue<string>();
messages.Enqueue(Recv(encoding, flags));
View
190 tests/AcceptanceTests/AcceptanceTests.csproj
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{7B12A63E-EC15-4F13-A91C-C03C7E97D8B6}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ZMQ.AcceptanceTests</RootNamespace>
+ <AssemblyName>AcceptanceTests</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'WIN_DEBUG|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Debug\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ <NoWarn>169</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'WIN_DEBUG|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <NoWarn>169</NoWarn>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Debug\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'WIN_RELEASE|x64'">
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ <NoWarn>169</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'WIN_RELEASE|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ <NoWarn>169</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'POSIX_DEBUG|x64'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <DefineConstants>TRACE;DEBUG;POSIX</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Debug\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ <NoWarn>414</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'POSIX_DEBUG|x86'">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <DefineConstants>TRACE;DEBUG;POSIX</DefineConstants>
+ <NoWarn>414</NoWarn>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Debug\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'POSIX_RELEASE|x64'">
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'POSIX_RELEASE|x86'">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <CodeAnalysisLogFile>bin\Release\AcceptanceTests.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
+ <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+ <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+ <ErrorReport>prompt</ErrorReport>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
+ <CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
+ <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+ <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Machine.Specifications">
+ <HintPath>..\..\packages\Machine.Specifications.0.5.1.0\lib\Machine.Specifications.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Behaviors.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SocketSpecs\Bind_Connect.cs" />
+ <Compile Include="SocketSpecs\SendMore_RecvAll.cs" />
+ <Compile Include="SocketSpecs\Send_Recv.cs" />
+ <Compile Include="SocketSpecs\SocketOptions.cs" />
+ <Compile Include="SocketSpecs\SpecContext.cs" />
+ <Compile Include="SocketSpecs\Subscribe.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\clrzmq\clrzmq.csproj">
+ <Project>{FE6D6CDD-8A04-4A3A-A654-5C687AB724E3}</Project>
+ <Name>clrzmq</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PostBuildEvent>xcopy /y /c $(SolutionDir)lib\$(PlatformName)\libzmq.dll .</PostBuildEvent>
+ </PropertyGroup>
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
142 tests/AcceptanceTests/Behaviors.cs
@@ -0,0 +1,142 @@
+#pragma warning disable 649
+
+namespace ZMQ.AcceptanceTests
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using Machine.Specifications;
+
+ static class Messages
+ {
+ public static readonly byte[] SingleMessage = Encoding.Default.GetBytes("Test message");
+ public static readonly byte[] MultiFirst = Encoding.Default.GetBytes("First");
+ public static readonly byte[] MultiLast = Encoding.Default.GetBytes("Last");
+
+ public static readonly byte[] PubSubPrefix = Encoding.Default.GetBytes("PREFIX");
+ public static readonly byte[] PubSubFirst = Encoding.Default.GetBytes("PREFIX Test message");
+ public static readonly byte[] PubSubSecond = Encoding.Default.GetBytes("NOPREFIX Test message");
+ }
+
+ [Behaviors]
+ class SingleMessageReceived
+ {
+ protected static Socket receiver;
+ protected static byte[] message;
+
+ It should_be_successfully_received = () =>
+ message.ShouldNotBeNull();
+
+ It should_contain_the_given_message = () =>
+ message.ShouldEqual(Messages.SingleMessage);
+
+ It should_not_have_more_parts = () =>
+ receiver.RcvMore.ShouldBeFalse();
+ }
+
+ [Behaviors]
+ class SingleMessageNotReceived
+ {
+ protected static Socket receiver;
+ protected static byte[] message;
+
+ It should_not_contain_the_given_message = () =>
+ message.ShouldBeNull();
+
+ It should_not_have_more_parts = () =>
+ receiver.RcvMore.ShouldBeFalse();
+ }
+
+ [Behaviors]
+ class SingleMessageReceivedWithExternalBuffer
+ {
+ protected static Socket receiver;
+ protected static byte[] message;
+ protected static byte[] buffer;
+ protected static int size;
+
+ It should_be_successfully_received = () =>
+ message.ShouldNotBeNull();
+
+ It should_set_the_actual_message_size = () =>
+ size.ShouldEqual(Messages.SingleMessage.Length);
+
+ It should_contain_the_given_message = () =>
+ message.Take(size).ShouldEqual(Messages.SingleMessage);
+
+ It should_not_have_more_parts = () =>
+ receiver.RcvMore.ShouldBeFalse();
+ }
+
+ [Behaviors]
+ class MultipleMessagesReceived
+ {
+ protected static Socket receiver;
+ protected static Queue<byte[]> messages;
+
+ It should_receive_all_message_parts = () =>
+ messages.Count.ShouldEqual(2);
+
+ It should_contain_the_correct_first_message_data = () =>
+ messages.First().ShouldEqual(Messages.MultiFirst);
+
+ It should_contain_the_correct_second_message_data = () =>
+ messages.Last().ShouldEqual(Messages.MultiLast);
+
+ It should_not_have_more_parts_after_the_second_message = () =>
+ receiver.RcvMore.ShouldBeFalse();
+ }
+
+ [Behaviors]
+ class PubSubReceiveFirst
+ {
+ protected static byte[] message1;
+ protected static byte[] message2;
+ protected static bool receiveMore1;
+ protected static bool receiveMore2;
+
+ It should_receive_the_first_message_successfully = () =>
+ message1.ShouldNotBeNull();
+
+ It should_contain_the_correct_first_message_data = () =>
+ message1.ShouldEqual(Messages.PubSubFirst);
+
+ It should_not_have_more_parts_after_the_first_message = () =>
+ receiveMore1.ShouldBeFalse();
+
+ It should_tell_receiver_to_retry_the_second_message = () =>
+ message2.ShouldBeNull();
+
+ It should_not_have_more_parts_after_the_second_message = () =>
+ receiveMore2.ShouldBeFalse();
+ }
+
+ [Behaviors]
+ class PubSubReceiveAll
+ {
+ protected static byte[] message1;
+ protected static byte[] message2;
+ protected static bool receiveMore1;
+ protected static bool receiveMore2;
+
+ It should_receive_the_first_message_successfully = () =>
+ message1.ShouldNotBeNull();
+
+ It should_contain_the_correct_first_message_data = () =>
+ message1.ShouldEqual(Messages.PubSubFirst);
+
+ It should_not_have_more_parts_after_the_first_message = () =>
+ receiveMore1.ShouldBeFalse();
+
+ It should_receive_the_second_message_successfully = () =>
+ message2.ShouldNotBeNull();
+
+ It should_contain_the_correct_second_message_data = () =>
+ message2.ShouldEqual(Messages.PubSubSecond);
+
+ It should_not_have_more_parts_after_the_second_message = () =>
+ receiveMore2.ShouldBeFalse();
+ }
+}
+
+#pragma warning restore 649
View
36 tests/AcceptanceTests/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AcceptanceTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("AcceptanceTests")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3e1135c5-44fe-423b-ae4d-2bb8735e5608")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
126 tests/AcceptanceTests/SocketSpecs/Bind_Connect.cs
@@ -0,0 +1,126 @@
+namespace ZMQ.AcceptanceTests.SocketSpecs
+{
+ using System.Threading;
+ using Machine.Specifications;
+
+ [Subject("Bind/Connect")]
+ class when_binding_and_connecting_to_a_tcp_ip_address_and_port : using_req_rep
+ {
+ Because of = () =>
+ exception = Catch.Exception(() =>
+ {
+ rep.Bind("tcp://127.0.0.1:9000");
+ req.Connect("tcp://127.0.0.1:9000");
+ });
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+ }
+
+ [Subject("Bind/Connect")]
+ class when_binding_to_a_tcp_port_and_connecting_to_address_and_port : using_req_rep
+ {
+ Because of = () =>
+ exception = Catch.Exception(() =>
+ {
+ rep.Bind("tcp://*:9000");
+ req.Connect("tcp://127.0.0.1:9000");
+ });
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+ }
+
+ [Subject("Bind/Connect")]
+ class when_binding_and_connecting_to_a_named_inproc_address : using_req_rep
+ {
+ Because of = () =>
+ exception = Catch.Exception(() =>
+ {
+ rep.Bind("inproc://named");
+ req.Connect("inproc://named");
+ });
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+ }
+
+ [Subject("Connect")]
+ class when_connecting_to_a_pgm_socket_with_pub_and_sub : using_pub_sub
+ {
+ Because of = () =>
+ exception = Catch.Exception(() =>
+ {
+ pub.Linger = 0;
+ pub.Connect("epgm://127.0.0.1;239.192.1.1:5000");
+
+ sub.Connect("epgm://127.0.0.1;239.192.1.1:5000");
+
+ // TODO: Is there any other way to ensure the PGM thread has started?
+ Thread.Sleep(100);
+ });
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+ }
+
+ [Subject("Connect")]
+ class when_connecting_to_a_pgm_socket_with_an_incompatible_socket_type : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.Connect("epgm://127.0.0.1;239.192.1.1:5000"));
+
+ It should_fail_because_pgm_is_not_supported = () =>
+ exception.ShouldBeOfType<ZMQ.Exception>();
+
+ It should_have_an_error_code_of_enocompatproto = () =>
+ ((ZMQ.Exception)exception).Errno.ShouldEqual((int)ERRNOS.ENOCOMPATPROTO);
+
+ It should_have_a_specific_error_message = () =>
+ exception.Message.ShouldContain("protocol is not compatible with the socket type");
+ }
+
+ [Subject("Bind")]
+ class when_binding_to_an_ipc_address : using_req_rep
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => rep.Bind("ipc:///tmp/testsock"));
+
+ [Ignore("Deferred until EPROTONOSUPPORT is set correctly for all platforms.")] // TODO
+ It should_have_an_error_code_of_eprotonosupport = () =>
+ ((ZMQ.Exception)exception).Errno.ShouldEqual((int)ERRNOS.EPROTONOSUPPORT);
+
+#if POSIX
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+#else
+ It should_fail_because_ipc_is_not_supported_on_windows = () =>
+ exception.ShouldBeOfType<ZMQ.Exception>();
+
+ It should_have_a_specific_error_message = () =>
+ exception.Message.ShouldContain("Protocol not supported");
+#endif
+ }
+
+ [Subject("Connect")]
+ class when_connecting_to_an_ipc_address : using_req_rep
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => rep.Connect("ipc:///tmp/testsock"));
+
+ [Ignore("Deferred until EPROTONOSUPPORT is set correctly for all platforms.")] // TODO
+ It should_have_an_error_code_of_eprotonosupport = () =>
+ ((ZMQ.Exception)exception).Errno.ShouldEqual((int)ERRNOS.EPROTONOSUPPORT);
+
+#if POSIX
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+#else
+ It should_fail_because_ipc_is_not_supported_on_windows = () =>
+ exception.ShouldBeOfType<ZMQ.Exception>();
+
+ It should_have_a_specific_error_message = () =>
+ exception.Message.ShouldContain("Protocol not supported");
+#endif
+ }
+}
View
52 tests/AcceptanceTests/SocketSpecs/SendMore_RecvAll.cs
@@ -0,0 +1,52 @@
+namespace ZMQ.AcceptanceTests.SocketSpecs
+{
+ using System.Collections.Generic;
+ using Machine.Specifications;
+
+ [Subject("SendMore/RecvAll")]
+ class when_transferring_multipart_messages : using_threaded_req_rep
+ {
+ protected static Queue<byte[]> messages;
+
+ Establish context = () =>
+ {
+ senderAction = req =>
+ {
+ req.SendMore(Messages.MultiFirst);
+ req.Send(Messages.MultiLast);
+ };
+
+ receiverAction = rep => messages = rep.RecvAll();
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<MultipleMessagesReceived> successfully_received_single_message;
+ }
+
+ [Subject("SendMore/RecvAll")]
+ class when_transferring_multipart_messages_with_an_external_buffer : using_threaded_req_rep
+ {
+ protected static Queue<byte[]> messages;
+ protected static Queue<byte[]> buffer;
+
+ Establish context = () =>
+ {
+ senderAction = req =>
+ {
+ req.SendMore(Messages.MultiFirst);
+ req.Send(Messages.MultiLast);
+ };
+
+ buffer = new Queue<byte[]>();
+ receiverAction = rep => messages = rep.RecvAll(buffer);
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<MultipleMessagesReceived> successfully_received_single_message;
+
+ It should_return_the_supplied_buffer = () =>
+ messages.ShouldBeTheSameAs(buffer);
+ }
+}
View
103 tests/AcceptanceTests/SocketSpecs/Send_Recv.cs
@@ -0,0 +1,103 @@
+namespace ZMQ.AcceptanceTests.SocketSpecs
+{
+ using System.Threading;
+ using Machine.Specifications;
+
+ [Subject("Send/Recv")]
+ class when_transferring_in_blocking_mode : using_threaded_req_rep
+ {
+ protected static byte[] message;
+
+ Establish context = () =>
+ {
+ senderAction = req => req.Send(Messages.SingleMessage);
+ receiverAction = rep => message = rep.Recv();
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<SingleMessageReceived> successfully_received_single_message;
+ }
+
+ [Subject("Send/Recv")]
+ class when_transferring_with_an_ample_receive_timeout : using_threaded_req_rep
+ {
+ protected static byte[] message;
+
+ Establish context = () =>
+ {
+ senderAction = req =>
+ {
+ Thread.Sleep(500);
+ req.Send(Messages.SingleMessage);
+ };
+
+ receiverAction = rep => message = rep.Recv(2000);
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<SingleMessageReceived> successfully_received_single_message;
+ }
+
+ [Subject("Send/Recv")]
+ class when_transferring_with_an_insufficient_receive_timeout : using_threaded_req_rep
+ {
+ protected static byte[] message;
+
+ Establish context = () =>
+ {
+ receiverAction = rep => message = rep.Recv(5);
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<SingleMessageNotReceived> receiver_must_try_again;
+ }
+
+ [Subject("Send/Recv")]
+ class when_transferring_with_an_ample_external_receive_buffer : using_threaded_req_rep
+ {
+ protected static byte[] message;
+ protected static byte[] buffer;
+ protected static int size;
+
+ Establish context = () =>
+ {
+ senderAction = req => req.Send(Messages.SingleMessage);
+
+ buffer = new byte[256];
+ receiverAction = rep => message = rep.Recv(buffer, out size);
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<SingleMessageReceivedWithExternalBuffer> successfully_received_message_with_buffer;
+
+ It should_return_the_supplied_buffer = () =>
+ message.ShouldBeTheSameAs(buffer);
+ }
+
+ [Subject("Send/Recv")]
+ class when_transferring_with_an_undersized_external_receive_buffer : using_threaded_req_rep
+ {
+ protected static byte[] message;
+ protected static byte[] buffer;
+ protected static int size;
+
+ Establish context = () =>
+ {
+ senderAction = req => req.Send(Messages.SingleMessage);
+
+ buffer = new byte[1];
+ receiverAction = rep => message = rep.Recv(buffer, out size);
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<SingleMessageReceivedWithExternalBuffer> successfully_received_message_with_buffer;
+
+ It should_not_return_the_supplied_buffer = () =>
+ message.ShouldNotBeTheSameAs(buffer);
+ }
+}
View
187 tests/AcceptanceTests/SocketSpecs/SocketOptions.cs
@@ -0,0 +1,187 @@
+namespace ZMQ.AcceptanceTests.SocketSpecs
+{
+ using System.Text;
+ using Machine.Specifications;
+
+ [Subject("Socket options")]
+ class when_setting_the_affinity_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.Affinity = 0x03ul);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.Affinity.ShouldEqual(0x03ul);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_backlog_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.Backlog = 6);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.Backlog.ShouldEqual(6);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_high_watermark_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.HWM = 100UL);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.HWM.ShouldEqual(100UL);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_identity_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.StringToIdentity("id", Encoding.Default));
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.IdentityToString(Encoding.Default).ShouldEqual("id");
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_linger_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.Linger = 333);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.Linger.ShouldEqual(333);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_multicast_loop_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.MCastLoop = 1);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.MCastLoop.ShouldEqual(1);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_multicast_rate_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.Rate = 60);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.Rate.ShouldEqual(60);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_multicast_recovery_interval_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.RecoveryIvl = 333);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.RecoveryIvl.ShouldEqual(333);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_multicast_recovery_interval_milliseconds_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.RecoveryIvlMsec = 333);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.RecoveryIvlMsec.ShouldEqual(333);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_receive_buffer_size_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.RcvBuf = 10000UL);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.RcvBuf.ShouldEqual(10000UL);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_reconnect_interval_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.ReconnectIvl = 333);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.ReconnectIvl.ShouldEqual(333);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_reconnect_interval_max_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.ReconnectIvlMax = 333);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.ReconnectIvlMax.ShouldEqual(333);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_send_buffer_size_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.SndBuf = 10000UL);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.SndBuf.ShouldEqual(10000UL);
+ }
+
+ [Subject("Socket options")]
+ class when_setting_the_swap_socket_option : using_req
+ {
+ Because of = () =>
+ exception = Catch.Exception(() => socket.Swap = 10000L);
+
+ It should_not_fail = () =>
+ exception.ShouldBeNull();
+
+ It should_return_the_given_value = () =>
+ socket.Swap.ShouldEqual(10000L);
+ }
+}
View
160 tests/AcceptanceTests/SocketSpecs/SpecContext.cs
@@ -0,0 +1,160 @@
+namespace ZMQ.AcceptanceTests.SocketSpecs
+{
+ using System;
+ using System.Threading;
+ using Machine.Specifications;
+
+ abstract class using_req
+ {
+ protected static Socket socket;
+ protected static Context zmqContext;
+ protected static Exception exception;
+
+ Establish context = () =>
+ {
+ zmqContext = new Context();
+ socket = zmqContext.Socket(SocketType.REQ);
+ };
+
+ Cleanup resources = () =>
+ {
+ socket.Dispose();
+ zmqContext.Dispose();
+ };
+ }
+
+ abstract class using_req_rep
+ {
+ protected static Socket req;
+ protected static Socket rep;
+ protected static Context zmqContext;
+ protected static Exception exception;
+
+ Establish context = () =>
+ {
+ zmqContext = new Context();
+ req = zmqContext.Socket(SocketType.REQ);
+ rep = zmqContext.Socket(SocketType.REP);
+ };
+
+ Cleanup resources = () =>
+ {
+ req.Dispose();
+ rep.Dispose();
+ zmqContext.Dispose();
+ };
+ }
+
+ abstract class using_pub_sub
+ {
+ protected static Socket pub;
+ protected static Socket sub;
+ protected static Context zmqContext;
+ protected static Exception exception;
+
+ Establish context = () =>
+ {
+ zmqContext = new Context();
+ pub = zmqContext.Socket(SocketType.PUB);
+ sub = zmqContext.Socket(SocketType.SUB);
+ };
+
+ Cleanup resources = () =>
+ {
+ sub.Dispose();
+ pub.Dispose();
+ zmqContext.Dispose();
+ };
+ }
+
+ abstract class using_threaded_req_rep : using_threaded_socket_pair
+ {
+ static using_threaded_req_rep()
+ {
+ createSender = () => zmqContext.Socket(SocketType.REQ);
+ createReceiver = () => zmqContext.Socket(SocketType.REP);
+ }
+ }
+
+ abstract class using_threaded_pub_sub : using_threaded_socket_pair
+ {
+ static using_threaded_pub_sub()
+ {
+ createSender = () => zmqContext.Socket(SocketType.PUB);
+ createReceiver = () => zmqContext.Socket(SocketType.SUB);
+ }
+ }
+
+ abstract class using_threaded_socket_pair
+ {
+ protected static Func<Socket> createSender;
+ protected static Func<Socket> createReceiver;
+
+ protected static Socket sender;
+ protected static Socket receiver;
+ protected static Context zmqContext;
+
+ protected static Action<Socket> senderInit;
+ protected static Action<Socket> senderAction;
+ protected static Action<Socket> receiverInit;
+ protected static Action<Socket> receiverAction;
+
+ private static Thread receiverThread;
+ private static Thread senderThread;
+
+ private static readonly ManualResetEvent receiverReady = new ManualResetEvent(false);
+
+ Establish context = () =>
+ {
+ zmqContext = new Context();
+ sender = createSender();
+ receiver = createReceiver();
+
+ senderInit = sck => { };
+ receiverInit = sck => { };
+ senderAction = sck => { };
+ receiverAction = sck => { };
+
+ senderThread = new Thread(() =>
+ {
+ senderInit(sender);
+ sender.HWM = 1;
+ receiverReady.WaitOne();
+ sender.Connect("inproc://spec_context");
+ senderAction(sender);
+ });
+
+ receiverThread = new Thread(() =>
+ {
+ receiverInit(receiver);
+ receiver.HWM = 1;
+ receiver.Bind("inproc://spec_context");
+ receiverReady.Set();
+ receiverAction(receiver);
+ });
+ };
+
+ Cleanup resources = () =>
+ {
+ sender.Dispose();
+ receiver.Dispose();
+ zmqContext.Dispose();
+ };
+
+ protected static void StartThreads()
+ {
+ receiverThread.Start();
+ senderThread.Start();
+
+ if (!receiverThread.Join(5000))
+ {
+ receiverThread.Abort();
+ }
+
+ if (!senderThread.Join(5000))
+ {
+ senderThread.Abort();
+ }
+ }
+ }
+}
View
83 tests/AcceptanceTests/SocketSpecs/Subscribe.cs
@@ -0,0 +1,83 @@
+namespace ZMQ.AcceptanceTests.SocketSpecs
+{
+ using System.Threading;
+ using Machine.Specifications;
+
+ [Subject("Subscribe")]
+ class when_subscribing_to_a_specific_prefix : using_threaded_pub_sub
+ {
+ protected static byte[] message1;
+ protected static byte[] message2;
+ protected static bool receiveMore1;
+ protected static bool receiveMore2;
+
+ Establish context = () =>
+ {
+ var signal = new ManualResetEvent(false);
+
+ receiverInit = sub => sub.Subscribe(Messages.PubSubPrefix);
+
+ receiverAction = sub =>
+ {
+ signal.Set();
+
+ message1 = sub.Recv();
+ receiveMore1 = sub.RcvMore;
+
+ message2 = sub.Recv(500);
+ receiveMore2 = sub.RcvMore;
+ };
+
+ senderInit = pub => signal.WaitOne(1000);
+
+ senderAction = pub =>
+ {
+ pub.Send(Messages.PubSubFirst);
+ pub.Send(Messages.PubSubSecond);
+ };
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<PubSubReceiveFirst> successfully_received_first_message_and_filtered_out_second;
+ }
+
+ [Subject("Subscribe")]
+ class when_subscribing_to_all_prefixes : using_threaded_pub_sub
+ {
+ protected static byte[] message1;
+ protected static byte[] message2;
+ protected static bool receiveMore1;
+ protected static bool receiveMore2;
+
+ Establish context = () =>
+ {
+ var signal = new ManualResetEvent(false);
+
+ receiverInit = sub => sub.Subscribe(new byte[0]);
+
+ receiverAction = sub =>
+ {
+ signal.Set();
+
+ message1 = sub.Recv();
+ receiveMore1 = sub.RcvMore;
+
+ message2 = sub.Recv(500);
+ receiveMore2 = sub.RcvMore;
+ };
+
+ senderInit = pub => signal.WaitOne(1000);
+
+ senderAction = pub =>
+ {
+ pub.Send(Messages.PubSubFirst);
+ pub.Send(Messages.PubSubSecond);
+ };
+ };
+
+ Because of = StartThreads;
+
+ Behaves_like<PubSubReceiveAll> successfully_received_all_messages;
+ }
+}
View
4 tests/AcceptanceTests/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Machine.Specifications" version="0.5.1.0" />
+</packages>
View
1 tests/AsyncReturn/AsyncReturn.csproj
@@ -71,7 +71,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
View
1 tests/WorkerPool/WorkerPool.csproj
@@ -76,7 +76,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>

0 comments on commit 51734c8

Please sign in to comment.