Ejemplo n.º 1
0
        public void Starting_and_stopping_and_starting_to_listen_for_connections_should_not_throw_any_errors()
        {
            // Given
            int port = new PortSetup(_logger).GetNextPort();
            var connectionListener = new ConnectionListener(_logger);

            // When
            connectionListener.ListenForConnectionsInANewThread(port);
            connectionListener.StopListening();

            connectionListener.ListenForConnectionsInANewThread(port);
            connectionListener.StopListening();

            // Then no error should occur
        }
Ejemplo n.º 2
0
        public void Stopping_listening_should_not_throw_an_error_if_we_are_not_listening()
        {
            // Given
            var connectionListener = new ConnectionListener(_logger);

            // When
            connectionListener.StopListening();

            // Then no error should occur
        }
Ejemplo n.º 3
0
        public void Can_stop_listening_for_connections_after_listening_has_started()
        {
            // Given
            int port = new PortSetup(_logger).GetNextPort();
            var connectionListener = new ConnectionListener(_logger);

            connectionListener.ListenForConnectionsInANewThread(port);

            // When
            _logger.Write <ConnectionListenerTest>("Stopping listening.");
            connectionListener.StopListening();
            // Then no error should occur
        }
Ejemplo n.º 4
0
        public void Listening_for_connections_twice_should_throw_an_error()
        {
            // Given
            int port = new PortSetup(_logger).GetNextPort();
            var connectionListener = new ConnectionListener(_logger);

            connectionListener.ListenForConnectionsInANewThread(port);

            // Then
            Assert.Throws <InvalidOperationException>(() =>
            {
                // When
                connectionListener.ListenForConnectionsInANewThread(port);
            });

            // Finally
            connectionListener.StopListening();
        }