Example #1
0
        public void Socket_Send_Receive_Multipart_Test(string endpoint)
        {
            using (var receiver = new ZmqSocket(ZmqContext.Current, ZmqSocketType.Rep))
                using (var senderContext = new ZmqContext())
                    using (var sender = (endpoint.StartsWith("inproc") ? ZmqContext.Current : senderContext).Socket(ZmqSocketType.Req))
                    {
                        receiver.Bind(endpoint);
                        sender.Connect(endpoint);

                        var message1 = MessageTests.GetTestData();
                        var message2 = MessageTests.GetTestData();
                        sender.Send(message1, ZmqSendReceiveFlags.SendMore);
                        sender.Send(message2);

                        using (var receivedMessage1 = new ZmqMessage())
                        {
                            receiver.Receive(receivedMessage1);
                            CollectionAssert.AreEqual(message1, receivedMessage1.ToArray());
                            Assert.IsTrue(receivedMessage1.HasMore);
                        }

                        using (var receivedMessage2 = new ZmqMessage())
                        {
                            receiver.Receive(receivedMessage2);
                            CollectionAssert.AreEqual(message2, receivedMessage2.ToArray());
                            Assert.IsFalse(receivedMessage2.HasMore);
                        }
                    }
        }
Example #2
0
        public void Message_Read_Write_Test()
        {
            var testData = GetTestData();

            using (var message = new ZmqMessage(TestMessageSize))
            {
                message.CopyFrom(testData);
                CollectionAssert.AreEqual(testData, message.ToArray());
            }
        }