public void TrySendMultipartBytesWithTimeoutTest()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                if (count == 0)
                {
                    Assert.AreEqual(TimeSpan.FromSeconds(1), timeout);
                    Assert.AreEqual(1, msg.Data.Length);
                    Assert.AreEqual(1, msg.Data[0]);
                    Assert.IsTrue(more);
                    count++;
                }
                else
                {
                    Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                    Assert.AreEqual(1, msg.Data.Length);
                    Assert.AreEqual(2, msg.Data[0]);
                    Assert.IsFalse(more);
                    count++;
                }

                return(true);
            });

            Assert.IsTrue(socket.TrySendMultipartBytes(TimeSpan.FromSeconds(1), new byte[] { 1 }, new byte[] { 2 }));
            Assert.AreEqual(2, count);
        }
        public void SendMultipartBytesTest()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                if (count == 0)
                {
                    Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                    Assert.AreEqual(1, msg.Data.Length);
                    Assert.AreEqual(1, msg.Data[0]);
                    Assert.IsTrue(more);
                    count++;
                }
                else
                {
                    Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                    Assert.AreEqual(1, msg.Data.Length);
                    Assert.AreEqual(2, msg.Data[0]);
                    Assert.IsFalse(more);
                    count++;
                }

                return true;
            });

            socket.SendMultipartBytes(new byte[] { 1 }, new byte[] { 2 });
            Assert.AreEqual(2, count);
        }
        public void TrySendFrameEmptyFailed()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.Zero, timeout);
                Assert.AreEqual(0, msg.Data.Length);
                Assert.IsFalse(more);
                return(false);
            });

            Assert.IsFalse(socket.TrySendFrameEmpty());
        }
        public void SendMoreFrameEmpty()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                Assert.AreEqual(0, msg.Data.Length);
                Assert.IsTrue(more);
                return(true);
            });

            socket.SendMoreFrameEmpty();
        }
        public void SendFrameEmpty()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                Assert.AreEqual(0, msg.Data.Length);
                Assert.IsFalse(more);
                return true;
            });

            socket.SendFrameEmpty();
        }
        public void TrySignalFailedTest()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.Zero, timeout);
                Assert.AreEqual(8, msg.Data.Length);

                long value = NetworkOrderBitsConverter.ToInt64(msg.Data);

                Assert.AreEqual(0x7766554433221100L, value);

                Assert.IsFalse(more);
                return(false);
            });

            Assert.IsFalse(socket.TrySignalOK());
        }
        public void SignalTest()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                Assert.AreEqual(8, msg.Data.Length);

                long value = NetworkOrderBitsConverter.ToInt64(msg.Data);

                Assert.AreEqual(0x7766554433221100L, value);

                Assert.IsFalse(more);
                return(true);
            });

            socket.SignalOK();
        }
        public void TrySendMultipartBytesWithTimeoutTestFailed()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.FromSeconds(1), timeout);
                Assert.AreEqual(1, msg.Data.Length);
                Assert.AreEqual(1, msg.Data[0]);
                Assert.IsTrue(more);
                count++;

                return(false);
            });

            Assert.IsFalse(socket.TrySendMultipartBytes(TimeSpan.FromSeconds(1), new byte[] { 1 }, new byte[] { 2 }));
            Assert.AreEqual(1, count);
        }
        public void TrySendMultipartMessageFailed()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.FromSeconds(0), timeout);
                Assert.AreEqual(1, msg.Data.Length);
                Assert.AreEqual(1, msg.Data[0]);
                Assert.IsTrue(more);
                count++;

                return(false);
            });

            NetMQMessage message = new NetMQMessage();

            message.Append(new byte[] { 1 });
            message.Append(new byte[] { 2 });

            Assert.IsFalse(socket.TrySendMultipartMessage(message));
            Assert.AreEqual(1, count);
        }
Пример #10
0
        public void SignalTest()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                Assert.AreEqual(8, msg.Data.Length);

                long value = NetworkOrderBitsConverter.ToInt64(msg.Data);

                Assert.AreEqual(0x7766554433221100L, value);

                Assert.IsFalse(more);
                return true;
            });

            socket.SignalOK();
        }
Пример #11
0
        public void TrySignalTest()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.Zero, timeout);
                Assert.AreEqual(8, msg.Data.Length);

                long value = NetworkOrderBitsConverter.ToInt64(msg.Data);

                Assert.AreEqual(0x7766554433221100L, value);

                Assert.IsFalse(more);
                return true;
            });

            Assert.IsTrue(socket.TrySignalOK());
        }
Пример #12
0
        public void TrySendMultipartMessageTest()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                if (count == 0)
                {
                    Assert.AreEqual(TimeSpan.FromSeconds(0), timeout);
                    Assert.AreEqual(1, msg.Data.Length);
                    Assert.AreEqual(1, msg.Data[0]);
                    Assert.IsTrue(more);
                    count++;
                }
                else
                {
                    Assert.AreEqual(SendReceiveConstants.InfiniteTimeout, timeout);
                    Assert.AreEqual(1, msg.Data.Length);
                    Assert.AreEqual(2, msg.Data[0]);
                    Assert.IsFalse(more);
                    count++;
                }

                return true;
            });

            NetMQMessage message = new NetMQMessage();
            message.Append(new byte[] {1});
            message.Append(new byte[] {2});

            Assert.IsTrue(socket.TrySendMultipartMessage(message));
            Assert.AreEqual(2, count);
        }
Пример #13
0
        public void TrySendMultipartMessageFailed()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.FromSeconds(0), timeout);
                Assert.AreEqual(1, msg.Data.Length);
                Assert.AreEqual(1, msg.Data[0]);
                Assert.IsTrue(more);
                count++;

                return false;
            });

            NetMQMessage message = new NetMQMessage();
            message.Append(new byte[] { 1 });
            message.Append(new byte[] { 2 });

            Assert.IsFalse(socket.TrySendMultipartMessage(message));
            Assert.AreEqual(1, count);
        }
Пример #14
0
        public void TrySendMultipartBytesWithTimeoutTestFailed()
        {
            int count = 0;

            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {

                Assert.AreEqual(TimeSpan.FromSeconds(1), timeout);
                Assert.AreEqual(1, msg.Data.Length);
                Assert.AreEqual(1, msg.Data[0]);
                Assert.IsTrue(more);
                count++;

                return false;
            });

            Assert.IsFalse(socket.TrySendMultipartBytes(TimeSpan.FromSeconds(1), new byte[] { 1 }, new byte[] { 2 }));
            Assert.AreEqual(1, count);
        }
Пример #15
0
        public void TrySendFrameEmptyFailed()
        {
            OutgoingSocketMock socket = new OutgoingSocketMock((ref Msg msg, TimeSpan timeout, bool more) =>
            {
                Assert.AreEqual(TimeSpan.Zero, timeout);
                Assert.AreEqual(0, msg.Data.Length);
                Assert.IsFalse(more);
                return false;
            });

            Assert.IsFalse(socket.TrySendFrameEmpty());
        }