Example #1
0
        private ZmqTransport CreateAndStartZmqTransport(string endPoint = null, Action <TransportMessage> onMessageReceived = null, string peerId = null, string environment = _environment)
        {
            var configurationMock = new Mock <IZmqTransportConfiguration>();

            configurationMock.SetupGet(x => x.InboundEndPoint).Returns(endPoint);
            configurationMock.SetupGet(x => x.WaitForEndOfStreamAckTimeout).Returns(1.Second());

            if (peerId == null)
            {
                peerId = $"Abc.Testing.{Guid.NewGuid():N}";
            }

            var transport = new ZmqTransport(configurationMock.Object, new ZmqSocketOptions(), new DefaultZmqOutboundSocketErrorHandler());

            transport.SetLogId(_transports.Count);

            transport.SocketOptions.SendTimeout = 500.Milliseconds();
            _transports.Add(transport);

            transport.Configure(new PeerId(peerId), environment);

            if (onMessageReceived != null)
            {
                transport.MessageReceived += onMessageReceived;
            }

            transport.Start();
            return(transport);
        }
Example #2
0
        public void should_not_crash_when_stopping_if_it_was_not_started()
        {
            var configurationMock = new Mock<IZmqTransportConfiguration>();
            configurationMock.SetupGet(x => x.WaitForEndOfStreamAckTimeout).Returns(100.Milliseconds());
            var transport = new ZmqTransport(configurationMock.Object, new ZmqSocketOptions());

            Assert.That(transport.Stop, Throws.Nothing);
        }
Example #3
0
        public void should_not_crash_when_stopping_if_it_was_not_started()
        {
            var configurationMock = new Mock <IZmqTransportConfiguration>();

            configurationMock.SetupGet(x => x.WaitForEndOfStreamAckTimeout).Returns(100.Milliseconds());
            var transport = new ZmqTransport(configurationMock.Object, new ZmqSocketOptions(), new DefaultZmqOutboundSocketErrorHandler());

            Assert.That(transport.Stop, Throws.Nothing);
        }
        private ZmqTransport CreateAndStartZmqTransport(string peerId, Action<TransportMessage> onMessageReceived = null)
        {
            var configurationMock = new Mock<IZmqTransportConfiguration>();
            var transport = new ZmqTransport(configurationMock.Object, new ZmqSocketOptions());
            transport.Configure(new PeerId(peerId), "test");
            transport.SocketOptions.SendTimeout = 5.Seconds();

            if (onMessageReceived != null)
                transport.MessageReceived += onMessageReceived;

            transport.Start();
            return transport;
        }
Example #5
0
        private ZmqTransport CreateAndStartZmqTransport(string peerId, Action <TransportMessage> onMessageReceived = null)
        {
            var configurationMock = new Mock <IZmqTransportConfiguration>();
            var transport         = new ZmqTransport(configurationMock.Object, new ZmqSocketOptions(), new DefaultZmqOutboundSocketErrorHandler());

            transport.Configure(new PeerId(peerId), "test");
            transport.SocketOptions.SendTimeout = 5.Seconds();

            if (onMessageReceived != null)
            {
                transport.MessageReceived += onMessageReceived;
            }

            transport.Start();
            return(transport);
        }