Skip to content

Commit fd24ada

Browse files
author
Daniel Hyams
committed
additional unit test for correlate socket option
1 parent ff809bf commit fd24ada

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/NetMQ.Tests/ReqRepTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,37 @@ public void SingleResponderSendsCorrectMessagesToMultipleRequestors()
176176
}
177177
}
178178

179+
[Theory]
180+
[InlineData(false)]
181+
[InlineData(true)]
182+
public void ReplyIsForLatestRequestIfRelaxedAndCorrelateEnabled(bool correlate)
183+
{
184+
using (var rep = new ResponseSocket())
185+
using (var req = new RequestSocket())
186+
{
187+
var port = rep.BindRandomPort($"tcp://127.0.0.1");
188+
189+
req.Connect($"tcp://127.0.0.1:{port}");
190+
req.Options.Correlate = correlate;
191+
req.Options.Relaxed = true;
192+
193+
req.SendFrame("Request1");
194+
req.SendFrame("Request2");
195+
196+
rep.SendFrame(rep.ReceiveFrameString());
197+
rep.SendFrame(rep.ReceiveFrameString());
198+
199+
if (correlate)
200+
{
201+
Assert.Equal("Request2", req.ReceiveFrameString());
202+
}
203+
else
204+
{
205+
Assert.Equal("Request1", req.ReceiveFrameString());
206+
}
207+
}
208+
}
209+
179210
internal void RouterBounce(ref RouterSocket router)
180211
{
181212
bool more;

0 commit comments

Comments
 (0)