Skip to content
This repository
Browse code

Convert socket option tests.

  • Loading branch information...
commit 37a31fd3806318ebf987aecb2611ff4dd2626f96 1 parent 165532f
John Gozde jgoz authored
568 src/ZeroMQ.AcceptanceTests/ZmqSocketSpecs/SocketOptions.cs
... ... @@ -1,403 +1,285 @@
1 1 namespace ZeroMQ.AcceptanceTests.ZmqSocketSpecs
2 2 {
3 3 using System;
4   - using Machine.Specifications;
  4 + using System.Linq.Expressions;
  5 + using System.Reflection;
  6 + using NUnit.Framework;
5 7
6   - [Subject("Socket options")]
7   - class when_setting_the_affinity_socket_option : using_req
  8 + [TestFixture]
  9 + public class SocketOptionTests
8 10 {
9   - Because of = () =>
10   - exception = Catch.Exception(() => socket.Affinity = 0x03ul);
11   -
12   - It should_not_fail = () =>
13   - exception.ShouldBeNull();
14   -
15   - It should_return_the_given_value = () =>
16   - socket.Affinity.ShouldEqual(0x03ul);
17   - }
18   -
19   - [Subject("Socket options")]
20   - class when_setting_the_backlog_socket_option : using_req
21   - {
22   - Because of = () =>
23   - exception = Catch.Exception(() => socket.Backlog = 6);
24   -
25   - It should_not_fail = () =>
26   - exception.ShouldBeNull();
27   -
28   - It should_return_the_given_value = () =>
29   - socket.Backlog.ShouldEqual(6);
30   - }
31   -
32   - [Subject("Socket options")]
33   - class when_setting_the_identity_socket_option : using_req
34   - {
35   - Because of = () =>
36   - exception = Catch.Exception(() => socket.Identity = Messages.Identity);
37   -
38   - It should_not_fail = () =>
39   - exception.ShouldBeNull();
40   -
41   - It should_return_the_given_value = () =>
42   - socket.Identity.ShouldEqual(Messages.Identity);
43   - }
44   -
45   - [Subject("Socket options")]
46   - class when_setting_the_linger_socket_option : using_req
47   - {
48   - Because of = () =>
49   - exception = Catch.Exception(() => socket.Linger = TimeSpan.FromMilliseconds(333));
50   -
51   - It should_not_fail = () =>
52   - exception.ShouldBeNull();
53   -
54   - It should_return_the_given_value = () =>
55   - socket.Linger.ShouldEqual(TimeSpan.FromMilliseconds(333));
56   - }
57   -
58   - [Subject("Socket options")]
59   - class when_setting_the_max_message_size_socket_option : using_req
60   - {
61   - Because of = () =>
  11 + public class Affinity : SocketOptionSetSuccessfully<ulong>
62 12 {
63   - if (ZmqVersion.Current.IsAtLeast(3))
64   - exception = Catch.Exception(() => socket.MaxMessageSize = 60000L);
65   - };
66   -
67   - It should_not_fail = () =>
68   - exception.ShouldBeNull();
  13 + public Affinity() : base(socket => socket.Affinity, 0x03ul) { }
  14 + }
69 15
70   - It should_return_the_given_value = () =>
  16 + public class Backlog : SocketOptionSetSuccessfully<int>
71 17 {
72   - if (ZmqVersion.Current.IsAtLeast(3))
73   - socket.MaxMessageSize.ShouldEqual(60000L);
74   - };
75   - }
  18 + public Backlog() : base(socket => socket.Backlog, 6) { }
  19 + }
76 20
77   - [Subject("Socket options")]
78   - class when_setting_the_multicast_hops_socket_option : using_req
79   - {
80   - Because of = () =>
  21 + public class Identity : SocketOptionSetSuccessfully<byte[]>
81 22 {
82   - if (ZmqVersion.Current.IsAtLeast(3))
83   - exception = Catch.Exception(() => socket.MulticastHops = 6);
84   - };
  23 + public Identity() : base(socket => socket.Identity, Messages.Identity) { }
  24 + }
85 25
86   - It should_not_fail = () =>
87   - exception.ShouldBeNull();
88   -
89   - It should_return_the_given_value = () =>
  26 + public class Linger : SocketOptionSetSuccessfully<TimeSpan>
90 27 {
91   - if (ZmqVersion.Current.IsAtLeast(3))
92   - socket.MulticastHops.ShouldEqual(6);
93   - };
94   - }
95   -
96   - [Subject("Socket options")]
97   - class when_setting_the_multicast_rate_socket_option : using_req
98   - {
99   - Because of = () =>
100   - exception = Catch.Exception(() => socket.MulticastRate = 60);
101   -
102   - It should_not_fail = () =>
103   - exception.ShouldBeNull();
  28 + public Linger() : base(socket => socket.Linger, TimeSpan.FromMilliseconds(333)) { }
  29 + }
104 30
105   - It should_return_the_given_value = () =>
106   - socket.MulticastRate.ShouldEqual(60);
107   - }
108   -
109   - [Subject("Socket options")]
110   - class when_setting_the_multicast_recovery_interval_socket_option : using_req
111   - {
112   - Because of = () =>
113   - exception = Catch.Exception(() => socket.MulticastRecoveryInterval = TimeSpan.FromMilliseconds(333));
114   -
115   - It should_not_fail = () =>
116   - exception.ShouldBeNull();
117   -
118   - It should_return_the_given_value = () =>
119   - socket.MulticastRecoveryInterval.ShouldEqual(TimeSpan.FromMilliseconds(333));
120   - }
121   -
122   - [Subject("Socket options")]
123   - class when_setting_the_receive_buffer_size_socket_option : using_req
124   - {
125   - Because of = () =>
126   - exception = Catch.Exception(() => socket.ReceiveBufferSize = 10000);
127   -
128   - It should_not_fail = () =>
129   - exception.ShouldBeNull();
130   -
131   - It should_return_the_given_value = () =>
132   - socket.ReceiveBufferSize.ShouldEqual(10000);
133   - }
134   -
135   - [Subject("Socket options")]
136   - class when_setting_the_receive_high_watermark_socket_option : using_req
137   - {
138   - Because of = () =>
139   - exception = Catch.Exception(() => socket.ReceiveHighWatermark = 100);
140   -
141   - It should_not_fail = () =>
142   - exception.ShouldBeNull();
143   -
144   - It should_return_the_given_value = () =>
145   - socket.ReceiveHighWatermark.ShouldEqual(100);
146   - }
147   -
148   - [Subject("Socket options")]
149   - class when_setting_the_receive_timeout_socket_option : using_req
150   - {
151   - Because of = () =>
  31 + public class MaxMessageSize : SocketOptionSetSuccessfully<long>
152 32 {
153   - if (ZmqVersion.Current.IsAtLeast(3))
154   - exception = Catch.Exception(() => socket.ReceiveTimeout = TimeSpan.FromMilliseconds(333));
155   - };
  33 + public MaxMessageSize() : base(socket => socket.MaxMessageSize, 60000L) { }
156 34
157   - It should_not_fail = () =>
158   - exception.ShouldBeNull();
  35 + protected override bool CheckVersion()
  36 + {
  37 + return ZmqVersion.Current.IsAtLeast(3);
  38 + }
  39 + }
159 40
160   - It should_return_the_given_value = () =>
  41 + public class MulticastHops : SocketOptionSetSuccessfully<int>
161 42 {
162   - if (ZmqVersion.Current.IsAtLeast(3))
163   - socket.ReceiveTimeout.ShouldEqual(TimeSpan.FromMilliseconds(333));
164   - };
165   - }
166   -
167   - [Subject("Socket options")]
168   - class when_setting_the_reconnect_interval_socket_option : using_req
169   - {
170   - Because of = () =>
171   - exception = Catch.Exception(() => socket.ReconnectInterval = TimeSpan.FromMilliseconds(333));
  43 + public MulticastHops() : base(socket => socket.MulticastHops, 6) { }
172 44
173   - It should_not_fail = () =>
174   - exception.ShouldBeNull();
175   -
176   - It should_return_the_given_value = () =>
177   - socket.ReconnectInterval.ShouldEqual(TimeSpan.FromMilliseconds(333));
178   - }
179   -
180   - [Subject("Socket options")]
181   - class when_setting_the_reconnect_interval_max_socket_option : using_req
182   - {
183   - Because of = () =>
184   - exception = Catch.Exception(() => socket.ReconnectIntervalMax = TimeSpan.FromMilliseconds(333));
185   -
186   - It should_not_fail = () =>
187   - exception.ShouldBeNull();
188   -
189   - It should_return_the_given_value = () =>
190   - socket.ReconnectIntervalMax.ShouldEqual(TimeSpan.FromMilliseconds(333));
191   - }
  45 + protected override bool CheckVersion()
  46 + {
  47 + return ZmqVersion.Current.IsAtLeast(3);
  48 + }
  49 + }
192 50
193   - [Subject("Socket options")]
194   - class when_setting_the_send_buffer_size_socket_option : using_req
195   - {
196   - Because of = () =>
197   - exception = Catch.Exception(() => socket.SendBufferSize = 10000);
198   -
199   - It should_not_fail = () =>
200   - exception.ShouldBeNull();
201   -
202   - It should_return_the_given_value = () =>
203   - socket.SendBufferSize.ShouldEqual(10000);
204   - }
205   -
206   - [Subject("Socket options")]
207   - class when_setting_the_send_high_watermark_socket_option : using_req
208   - {
209   - Because of = () =>
210   - exception = Catch.Exception(() => socket.SendHighWatermark = 100);
211   -
212   - It should_not_fail = () =>
213   - exception.ShouldBeNull();
214   -
215   - It should_return_the_given_value = () =>
216   - socket.SendHighWatermark.ShouldEqual(100);
217   - }
218   -
219   - [Subject("Socket options")]
220   - class when_setting_the_send_timeout_socket_option : using_req
221   - {
222   - Because of = () =>
  51 + public class MulticastRate : SocketOptionSetSuccessfully<int>
223 52 {
224   - if (ZmqVersion.Current.IsAtLeast(3))
225   - exception = Catch.Exception(() => socket.SendTimeout = TimeSpan.FromMilliseconds(333));
226   - };
  53 + public MulticastRate() : base(socket => socket.MulticastRate, 60) { }
  54 + }
227 55
228   - It should_not_fail = () =>
229   - exception.ShouldBeNull();
230   -
231   - It should_return_the_given_value = () =>
  56 + public class MulticastRecoveryInterval : SocketOptionSetSuccessfully<TimeSpan>
232 57 {
233   - if (ZmqVersion.Current.IsAtLeast(3))
234   - socket.SendTimeout.ShouldEqual(TimeSpan.FromMilliseconds(333));
235   - };
236   - }
  58 + public MulticastRecoveryInterval() : base(socket => socket.MulticastRecoveryInterval, TimeSpan.FromMilliseconds(333)) { }
  59 + }
237 60
238   - [Subject("Socket options")]
239   - class when_setting_the_supported_protocol_socket_option : using_req
240   - {
241   - Because of = () =>
  61 + public class ReceiveBufferSize : SocketOptionSetSuccessfully<int>
242 62 {
243   - if (ZmqVersion.Current.IsAtLeast(3))
244   - exception = Catch.Exception(() => socket.SupportedProtocol = ProtocolType.Both);
245   - };
  63 + public ReceiveBufferSize() : base(socket => socket.ReceiveBufferSize, 10000) { }
  64 + }
246 65
247   - It should_not_fail = () =>
248   - exception.ShouldBeNull();
  66 + public class ReceiveHighWatermark : SocketOptionSetSuccessfully<int>
  67 + {
  68 + public ReceiveHighWatermark() : base(socket => socket.ReceiveHighWatermark, 100) { }
  69 + }
249 70
250   - It should_return_the_given_value = () =>
  71 + public class ReceiveTimeout : SocketOptionSetSuccessfully<TimeSpan>
251 72 {
252   - if (ZmqVersion.Current.IsAtLeast(3))
253   - socket.SupportedProtocol.ShouldEqual(ProtocolType.Both);
254   - };
255   - }
  73 + public ReceiveTimeout() : base(socket => socket.ReceiveTimeout, TimeSpan.FromMilliseconds(333)) { }
256 74
257   - [Subject("Socket options")]
258   - class when_gettings_the_last_endpoint_socket_option : using_req
259   - {
260   - Because of = () =>
261   - exception = Catch.Exception(() => socket.Bind("inproc://last_endpoint"));
  75 + protected override bool CheckVersion()
  76 + {
  77 + return ZmqVersion.Current.IsAtLeast(3);
  78 + }
  79 + }
262 80
263   - It should_not_fail = () =>
264   - exception.ShouldBeNull();
  81 + public class ReconnectInterval : SocketOptionSetSuccessfully<TimeSpan>
  82 + {
  83 + public ReconnectInterval() : base(socket => socket.ReconnectInterval, TimeSpan.FromMilliseconds(333)) { }
  84 + }
265 85
266   - It should_return_the_given_value = () =>
267   - socket.LastEndpoint.ShouldEqual("inproc://last_endpoint");
268   - }
  86 + public class ReconnectIntervalMax : SocketOptionSetSuccessfully<TimeSpan>
  87 + {
  88 + public ReconnectIntervalMax() : base(socket => socket.ReconnectIntervalMax, TimeSpan.FromMilliseconds(333)) { }
  89 + }
269 90
270   - [Subject("Socket options")]
271   - class when_setting_the_router_behavior_socket_option : using_router
272   - {
273   - Because of = () =>
  91 + public class SendBufferSize : SocketOptionSetSuccessfully<int>
274 92 {
275   - if (ZmqVersion.Current.IsAtLeast(3))
276   - exception = Catch.Exception(() => socket.RouterBehavior = RouterBehavior.Report);
277   - };
  93 + public SendBufferSize() : base(socket => socket.SendBufferSize, 10000) { }
  94 + }
278 95
279   - It should_not_fail = () =>
280   - exception.ShouldBeNull();
281   - }
  96 + public class SendHighWatermark : SocketOptionSetSuccessfully<int>
  97 + {
  98 + public SendHighWatermark() : base(socket => socket.SendHighWatermark, 100) { }
  99 + }
282 100
283   - [Subject("Socket options")]
284   - class when_setting_the_tcp_accept_filter_socket_option : using_req
285   - {
286   - Because of = () =>
  101 + public class SendTimeout : SocketOptionSetSuccessfully<TimeSpan>
287 102 {
288   - if (ZmqVersion.Current.IsAtLeast(3))
289   - exception = Catch.Exception(() => socket.AddTcpAcceptFilter("localhost"));
290   - };
  103 + public SendTimeout() : base(socket => socket.SendTimeout, TimeSpan.FromMilliseconds(333)) { }
291 104
292   - It should_not_fail = () =>
293   - exception.ShouldBeNull();
294   - }
  105 + protected override bool CheckVersion()
  106 + {
  107 + return ZmqVersion.Current.IsAtLeast(3);
  108 + }
  109 + }
295 110
296   - [Subject("Socket options")]
297   - class when_setting_the_tcp_keepalive_socket_option : using_req
298   - {
299   - Because of = () =>
  111 + public class SupportedProtocol : SocketOptionSetSuccessfully<ProtocolType>
300 112 {
301   - if (ZmqVersion.Current.IsAtLeast(3))
302   - exception = Catch.Exception(() => socket.TcpKeepalive = TcpKeepaliveBehaviour.Enable);
303   - };
  113 + public SupportedProtocol() : base(socket => socket.SupportedProtocol, ProtocolType.Both) { }
304 114
305   - It should_not_fail = () =>
306   - exception.ShouldBeNull();
  115 + protected override bool CheckVersion()
  116 + {
  117 + return ZmqVersion.Current.IsAtLeast(3);
  118 + }
  119 + }
307 120
308   -#if POSIX
309   - It should_return_the_given_value = () =>
  121 + public class LastEndpoint : UsingReq
310 122 {
311   - if (ZmqVersion.Current.IsAtLeast(3))
312   - socket.TcpKeepalive.ShouldEqual(TcpKeepaliveBehaviour.Enable);
313   - };
314   -#else
315   - It should_return_the_default_value_on_windows = () =>
  123 + [TestFixtureSetUp]
  124 + public void RunTest()
  125 + {
  126 + Socket.Bind("inproc://last_endpoint");
  127 + }
  128 +
  129 + [Test]
  130 + public void ShouldReturnTheGivenValue()
  131 + {
  132 + Assert.AreEqual("inproc://last_endpoint", Socket.LastEndpoint);
  133 + }
  134 + }
  135 +
  136 + public class RouterBehavior : UsingSocket
316 137 {
317   - if (ZmqVersion.Current.IsAtLeast(3))
318   - socket.TcpKeepalive.ShouldEqual(TcpKeepaliveBehaviour.Default);
319   - };
320   -#endif
321   - }
322   -
323   - [Subject("Socket options")]
324   - class when_setting_the_tcp_keepalive_cnt_socket_option : using_req
325   - {
326   - Because of = () =>
  138 + public RouterBehavior() : base(SocketType.ROUTER) { }
  139 +
  140 + [Test]
  141 + public void ShouldExecuteWithoutException()
  142 + {
  143 + if (ZmqVersion.Current.IsAtLeast(3))
  144 + {
  145 + Assert.DoesNotThrow(() => Socket.RouterBehavior = ZeroMQ.RouterBehavior.Report);
  146 + }
  147 + }
  148 + }
  149 +
  150 + public class TcpAcceptFilter : UsingReq
327 151 {
328   - if (ZmqVersion.Current.IsAtLeast(3))
329   - exception = Catch.Exception(() => socket.TcpKeepaliveCnt = 42);
330   - };
331   -
332   - It should_not_fail = () =>
333   - exception.ShouldBeNull();
334   -
335   -#if POSIX
336   - It should_return_the_given_value = () =>
  152 + [Test]
  153 + public void ShouldExecuteWithoutException()
  154 + {
  155 + if (ZmqVersion.Current.IsAtLeast(3))
  156 + {
  157 + Assert.DoesNotThrow(() => Socket.AddTcpAcceptFilter("localhost"));
  158 + }
  159 + }
  160 + }
  161 +
  162 + public class TcpKeepalive : SocketOptionSetSuccessfully<TcpKeepaliveBehaviour>
337 163 {
338   - if (ZmqVersion.Current.IsAtLeast(3))
339   - socket.TcpKeepaliveCnt.ShouldEqual(42);
340   - };
  164 +#if POSIX
  165 + public TcpKeepalive() : base(socket => socket.TcpKeepalive, TcpKeepaliveBehaviour.Enable) { }
341 166 #else
342   - It should_return_the_default_value_on_windows = () =>
343   - {
344   - if (ZmqVersion.Current.IsAtLeast(3))
345   - socket.TcpKeepaliveCnt.ShouldEqual(-1);
346   - };
  167 + public TcpKeepalive() : base(socket => socket.TcpKeepalive, TcpKeepaliveBehaviour.Enable, TcpKeepaliveBehaviour.Default) { }
347 168 #endif
348   - }
349 169
350   - [Subject("Socket options")]
351   - class when_setting_the_tcp_keepalive_idle_socket_option : using_req
352   - {
353   - Because of = () =>
354   - {
355   - if (ZmqVersion.Current.IsAtLeast(3))
356   - exception = Catch.Exception(() => socket.TcpKeepaliveIdle = 42);
357   - };
358   -
359   - It should_not_fail = () =>
360   - exception.ShouldBeNull();
  170 + protected override bool CheckVersion()
  171 + {
  172 + return ZmqVersion.Current.IsAtLeast(3);
  173 + }
  174 + }
361 175
362   -#if POSIX
363   - It should_return_the_given_value = () =>
  176 + public class TcpKeepaliveCnt : SocketOptionSetSuccessfully<int>
364 177 {
365   - if (ZmqVersion.Current.IsAtLeast(3))
366   - socket.TcpKeepaliveIdle.ShouldEqual(42);
367   - };
  178 +#if POSIX
  179 + public TcpKeepaliveCnt() : base(socket => socket.TcpKeepaliveCnt, 42) { }
368 180 #else
369   - It should_return_the_default_value_on_windows = () =>
370   - {
371   - if (ZmqVersion.Current.IsAtLeast(3))
372   - socket.TcpKeepaliveIdle.ShouldEqual(-1);
373   - };
  181 + public TcpKeepaliveCnt() : base(socket => socket.TcpKeepaliveCnt, 42, -1) { }
374 182 #endif
375   - }
376 183
377   - [Subject("Socket options")]
378   - class when_setting_the_tcp_keepalive_intvl_socket_option : using_req
379   - {
380   - Because of = () =>
  184 + protected override bool CheckVersion()
  185 + {
  186 + return ZmqVersion.Current.IsAtLeast(3);
  187 + }
  188 + }
  189 +
  190 + public class TcpKeepaliveIdle : SocketOptionSetSuccessfully<int>
381 191 {
382   - if (ZmqVersion.Current.IsAtLeast(3))
383   - exception = Catch.Exception(() => socket.TcpKeepaliveIntvl = 42);
384   - };
  192 +#if POSIX
  193 + public TcpKeepaliveIdle() : base(socket => socket.TcpKeepaliveIdle, 42) { }
  194 +#else
  195 + public TcpKeepaliveIdle() : base(socket => socket.TcpKeepaliveIdle, 42, -1) { }
  196 +#endif
385 197
386   - It should_not_fail = () =>
387   - exception.ShouldBeNull();
  198 + protected override bool CheckVersion()
  199 + {
  200 + return ZmqVersion.Current.IsAtLeast(3);
  201 + }
  202 + }
388 203
389   -#if POSIX
390   - It should_return_the_given_value = () =>
  204 + public class TcpKeepaliveIntvl : SocketOptionSetSuccessfully<int>
391 205 {
392   - if (ZmqVersion.Current.IsAtLeast(3))
393   - socket.TcpKeepaliveIntvl.ShouldEqual(42);
394   - };
  206 +#if POSIX
  207 + public TcpKeepaliveIntvl() : base(socket => socket.TcpKeepaliveIntvl, 42) { }
395 208 #else
396   - It should_return_the_default_value_on_windows = () =>
397   - {
398   - if (ZmqVersion.Current.IsAtLeast(3))
399   - socket.TcpKeepaliveIntvl.ShouldEqual(-1);
400   - };
  209 + public TcpKeepaliveIntvl() : base(socket => socket.TcpKeepaliveIntvl, 42, -1) { }
401 210 #endif
  211 + }
  212 +
  213 + public abstract class SocketOptionSetSuccessfully<TOption> : UsingSocket
  214 + {
  215 + private readonly Expression<Func<ZmqSocket, TOption>> _getter;
  216 + private readonly Expression<Action<ZmqSocket, TOption>> _setter;
  217 + private readonly TOption _value;
  218 + private readonly TOption _expected;
  219 +
  220 + private Exception _exception;
  221 +
  222 + protected SocketOptionSetSuccessfully(Expression<Func<ZmqSocket, TOption>> option, TOption value) : this(option, value, value) { }
  223 +
  224 + protected SocketOptionSetSuccessfully(Expression<Func<ZmqSocket, TOption>> option, TOption value, TOption expected) : this(option, value, expected, SocketType.REQ) { }
  225 +
  226 + protected SocketOptionSetSuccessfully(Expression<Func<ZmqSocket, TOption>> option, TOption value, TOption expected, SocketType socketType)
  227 + : base(socketType)
  228 + {
  229 + _getter = option;
  230 + _expected = expected;
  231 + _value = value;
  232 +
  233 + var memberExpression = option.Body as MemberExpression;
  234 +
  235 + if (memberExpression == null || !(memberExpression.Member is PropertyInfo))
  236 + {
  237 + throw new InvalidOperationException("Option expression must be simple getter.");
  238 + }
  239 +
  240 + var propertyInfo = (PropertyInfo)memberExpression.Member;
  241 + var setMethod = propertyInfo.GetSetMethod();
  242 +
  243 + _setter = (socket, val) => setMethod.Invoke(Socket, new object[] { val });
  244 + }
  245 +
  246 + protected virtual bool CheckVersion()
  247 + {
  248 + return true;
  249 + }
  250 +
  251 + [TestFixtureSetUp]
  252 + public void RunTest()
  253 + {
  254 + _exception = null;
  255 +
  256 + if (CheckVersion())
  257 + {
  258 + try
  259 + {
  260 + _setter.Compile().Invoke(Socket, _value);
  261 + }
  262 + catch (Exception e)
  263 + {
  264 + _exception = e;
  265 + }
  266 + }
  267 + }
  268 +
  269 + [Test]
  270 + public void ShouldSucceedWithoutException()
  271 + {
  272 + Assert.IsNull(_exception);
  273 + }
  274 +
  275 + [Test]
  276 + public void ShouldReturnTheGivenValue()
  277 + {
  278 + if (CheckVersion())
  279 + {
  280 + Assert.AreEqual(_expected, _getter.Compile().Invoke(Socket));
  281 + }
  282 + }
  283 + }
402 284 }
403 285 }
32 src/ZeroMQ.AcceptanceTests/ZmqSocketSpecs/SpecContext.cs
@@ -5,6 +5,38 @@
5 5 using Machine.Specifications;
6 6 using NUnit.Framework;
7 7
  8 + public class UsingSocket
  9 + {
  10 + private readonly SocketType _socketType;
  11 +
  12 + protected ZmqSocket Socket;
  13 + protected ZmqContext ZmqContext;
  14 +
  15 + public UsingSocket(SocketType socketType)
  16 + {
  17 + _socketType = socketType;
  18 + }
  19 +
  20 + [TestFixtureSetUp]
  21 + public void Initialize()
  22 + {
  23 + ZmqContext = ZmqContext.Create();
  24 + Socket = ZmqContext.CreateSocket(_socketType);
  25 + }
  26 +
  27 + [TestFixtureTearDown]
  28 + public void Cleanup()
  29 + {
  30 + Socket.Dispose();
  31 + ZmqContext.Dispose();
  32 + }
  33 + }
  34 +
  35 + public class UsingReq : UsingSocket
  36 + {
  37 + public UsingReq() : base(SocketType.REQ) { }
  38 + }
  39 +
8 40 public class UsingSocketPair
9 41 {
10 42 private readonly SocketType _senderType;

0 comments on commit 37a31fd

Please sign in to comment.
Something went wrong with that request. Please try again.