示例#1
0
        public void AddPublisher_BeforeRunning_DoesNotBindReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            // Act
            monitor.AddPublisher(publisher);

            // Assert
            mockPublisher.Verify(m => m.InitializeConnection(), Times.Never);
        }
示例#2
0
        public void AddPublisher_WithReceiver_AddsPollableSocketToPoller()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            // Act
            monitor.AddPublisher(publisher);

            // Assert
            mockPoller.Verify(m => m.Add(It.IsIn(pollableSocket)), Times.Once);
        }
示例#3
0
        public void AddPublisher_WithNullReceiver_DoesNotThrow()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            // Act
            TestDelegate add = () => monitor.AddPublisher(null);

            // Assert
            Assert.That(add, Throws.Nothing);
        }
示例#4
0
        public void StartMonitor_WithPublisherAdded_BindsReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.AddPublisher(publisher);

            // Act
            monitor.StartMonitoring();

            // Assert
            mockPublisher.Verify(m => m.InitializeConnection(), Times.Once);
        }
示例#5
0
        public void AddPublisher_AfterStopped_DoesNotBindReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.StartMonitoring();
            monitor.StopMonitoring();

            // Act
            monitor.AddPublisher(publisher);

            // Assert
            mockPublisher.Verify(m => m.InitializeConnection(), Times.Never);
        }
示例#6
0
        public void StopMonitoring_BeforeStarted_DoesNothing()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.AddSender(sender);
            monitor.AddReceiver(receiver);
            monitor.AddPublisher(publisher);
            monitor.AddSubscriber(subscriber);

            // Act
            monitor.StopMonitoring();

            // Assert
            mockPoller.Verify(m => m.StopAsync(), Times.Never);
            mockSender.Verify(m => m.TerminateConnection(), Times.Never);
            mockReceiver.Verify(m => m.TerminateConnection(), Times.Never);
            mockPublisher.Verify(m => m.InitializeConnection(), Times.Never);
            mockSubscriber.Verify(m => m.InitializeConnection(), Times.Never);
        }
示例#7
0
        public void StartMonitor_WhenRunning_DoesNotRecallStartMethods()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.StartMonitoring();
            monitor.AddSender(sender);
            monitor.AddReceiver(receiver);
            monitor.AddPublisher(publisher);
            monitor.AddSubscriber(subscriber);

            // Act
            monitor.StartMonitoring();

            // Assert
            mockPoller.Verify(m => m.RunAsync(), Times.Once);
            mockSender.Verify(m => m.InitializeConnection(), Times.Once);
            mockReceiver.Verify(m => m.InitializeConnection(), Times.Once);
            mockPublisher.Verify(m => m.InitializeConnection(), Times.Once);
            mockSubscriber.Verify(m => m.InitializeConnection(), Times.Once);
        }