Exemplo n.º 1
0
        public void StartMonitoring_BeforeStarted_RunsPoller()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            // Act
            monitor.StartMonitoring();

            // Assert
            mockPoller.Verify(m => m.RunAsync(), Times.Once);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void StopMonitoring_WhenRunning_StopsPoller()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.StartMonitoring();

            // Act
            monitor.StopMonitoring();

            // Assert
            mockPoller.Verify(m => m.StopAsync(), Times.Once);
        }
Exemplo n.º 4
0
        public void StartMonitor_WithSubscriberAdded_ConnectsReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.AddSubscriber(subscriber);

            // Act
            monitor.StartMonitoring();

            // Assert
            mockSubscriber.Verify(m => m.InitializeConnection(), Times.Once);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void AddReceiver_AfterStarted_BindsReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.StartMonitoring();

            // Act
            monitor.AddReceiver(receiver);

            // Assert
            mockReceiver.Verify(m => m.InitializeConnection(), Times.Once);
        }
Exemplo n.º 7
0
        public void StopMonitoring_WithSubscriberAdded_UnbindsReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.AddSubscriber(subscriber);
            monitor.StartMonitoring();

            // Act
            monitor.StopMonitoring();

            // Assert
            mockSubscriber.Verify(m => m.TerminateConnection(), Times.Once);
        }
Exemplo n.º 8
0
        public void StopMonitoring_WithSenderAdded_DisconnectsSender()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            monitor.AddSender(sender);
            monitor.StartMonitoring();

            // Act
            monitor.StopMonitoring();

            // Assert
            mockSender.Verify(m => m.TerminateConnection(), Times.Once);
        }
Exemplo n.º 9
0
        public void AddSubscriber_AfterStopped_DoesNotBindReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

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

            // Act
            monitor.AddSubscriber(subscriber);

            // Assert
            mockSubscriber.Verify(m => m.InitializeConnection(), Times.Never);
        }