Exemple #1
0
        public void AddSender_BeforeRunning_DoesNotBindReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            // Act
            monitor.AddSender(sender);

            // Assert
            mockReceiver.Verify(m => m.InitializeConnection(), Times.Never);
        }
Exemple #2
0
        public void AddSender_WithNullReceiver_DoesNotThrow()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

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

            // Assert
            Assert.That(add, Throws.Nothing);
        }
Exemple #3
0
        public void AddSender_WithReceiver_AddsPollableSocketToPoller()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

            // Act
            monitor.AddSender(sender);

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

            monitor.AddSender(sender);

            // Act
            monitor.StartMonitoring();

            // Assert
            mockSender.Verify(m => m.InitializeConnection(), Times.Once);
        }
Exemple #5
0
        public void AddSender_AfterStopped_DoesNotBindReceiver()
        {
            // Arrange
            var monitor = new NetMQMonitor(poller);

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

            // Act
            monitor.AddSender(sender);

            // Assert
            mockReceiver.Verify(m => m.InitializeConnection(), Times.Never);
        }
Exemple #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);
        }
Exemple #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);
        }