예제 #1
0
        public void UnbindAll_BeforeBindCall_DoesNothing()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            TestDelegate test = () => receiver.TerminateConnection();

            // Assert
            Assert.That(test, Throws.Nothing);

            // Cleanup
            receiver.Dispose();
        }
예제 #2
0
        public void IsConnected_BeforeBindIsCalled_IsFalse()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            var isConnected = receiver.IsConnected;

            // Assert
            Assert.That(isConnected, Is.False);

            // Cleanup
            receiver.Dispose();
        }
예제 #3
0
        public void Bind_WithNoAddresses_DoesNothing()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            TestDelegate test = () => receiver.InitializeConnection();

            // Assert
            Assert.That(test, Throws.Nothing);

            // Cleanup
            receiver.Dispose();
        }
예제 #4
0
        public void AddAddress_WithNullAddress_ThrowsArgumentNullException()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            TestDelegate addAddress = () => receiver.AddAddress(null);

            // Assert
            Assert.That(addAddress, Throws.ArgumentNullException);

            // Cleanup
            receiver.Dispose();
        }
예제 #5
0
        public void Remove_WithUnaddedAddress_DoesNothing()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            TestDelegate test = () => receiver.RemoveAddress(TcpAddress.Wildcard(5555));

            // Assert
            Assert.That(test, Throws.Nothing);

            // Cleanup
            receiver.Dispose();
        }
예제 #6
0
        public void Addresses_WhenNoAddressesAdded_IsEmpty()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            var any = receiver.Addresses.Any();

            // Assert
            Assert.That(any, Is.False);

            // Cleanup
            receiver.Dispose();
        }
예제 #7
0
        public void Bind_WhenCalled_SetsIsBound()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            // Act
            receiver.InitializeConnection();

            // Assert
            Assert.That(receiver.IsConnected, Is.True);

            // Cleanup
            receiver.TerminateConnection();
            receiver.Dispose();
        }
예제 #8
0
        public void AddAddress_WithNewAddress_AddsToAddresses()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);
            var address  = TcpAddress.Wildcard(5555);

            // Act
            receiver.AddAddress(address);

            // Assert
            CollectionAssert.Contains(receiver.Addresses, address);

            // Cleanup
            receiver.Dispose();
        }
예제 #9
0
        public void RemoveAllAddresses_WithAddedAddresses_IsConnectedFalse()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            receiver.AddAddress(TcpAddress.Wildcard(5555));

            // Act
            receiver.RemoveAllAddresses();

            // Assert
            Assert.That(receiver.IsConnected, Is.False);

            // Cleanup
            receiver.Dispose();
        }
예제 #10
0
        public void RemoveAllAddresses_WithAddedAddresses_ClearsAddresses()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            receiver.AddAddress(TcpAddress.Wildcard(5555));

            // Act
            receiver.RemoveAllAddresses();

            // Assert
            CollectionAssert.IsEmpty(receiver.Addresses);

            // Cleanup
            receiver.Dispose();
        }
예제 #11
0
        public void IsConnected_OnceBindIsCalled_IsTrue()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);

            receiver.InitializeConnection();

            // Act
            var isConnected = receiver.IsConnected;

            // Assert
            Assert.That(isConnected, Is.True);

            // Cleanup
            receiver.Dispose();
        }
예제 #12
0
        public void Remove_WithAddedAddress_RemovesAddress()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);
            var address  = TcpAddress.Wildcard(5555);

            receiver.AddAddress(address);

            // Act
            receiver.RemoveAddress(address);

            // Assert
            CollectionAssert.DoesNotContain(receiver.Addresses, address);

            // Cleanup
            receiver.Dispose();
        }
예제 #13
0
        public void AddAddress_WithAlreadyAddedAddress_DoesNotAddTwice()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);
            var address  = TcpAddress.Wildcard(5555);

            receiver.AddAddress(address);

            // Act
            receiver.AddAddress(address);

            // Assert
            Assert.That(receiver.Addresses, Has.Count.EqualTo(1));

            // Cleanup
            receiver.Dispose();
        }
예제 #14
0
        public void Addresses_WhenDisposed_ThrowsInvalidOperationException()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);
            var address  = TcpAddress.Wildcard(5555);

            receiver.Dispose();

            // Act
            void AddAddress() => receiver.AddAddress(address);

            // Assert
            Assert.That(AddAddress, Throws.TypeOf <InvalidOperationException>());

            // Cleanup
            socket.Dispose();
        }
예제 #15
0
        public void Remove_WithAddedAddress_IsConnectedTrue()
        {
            // Arrange
            var socket   = new RouterSocket();
            var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher);
            var address  = TcpAddress.Wildcard(5555);
            var address2 = TcpAddress.Wildcard(5556);

            receiver.AddAddress(address);
            receiver.AddAddress(address2);
            receiver.InitializeConnection();

            // Act
            receiver.RemoveAddress(address);

            // Assert
            Assert.That(receiver.IsConnected, Is.True);

            // Cleanup
            receiver.Dispose();
        }