public void Client_SendMessage_ServerShouldFireMessageReceivedEvent()
        {
            // Prepare
            _server = new ServerPipeline();
            _client = new ClientPipeline(_server.ServerId);

            string message   = null;
            var    autoEvent = new AutoResetEvent(false);

            _server.MessageReceivedEvent += (sender, args) =>
            {
                message = args.Message;
                autoEvent.Set();
            };

            _server.Start();
            _client.Start();

            // Act
            _client.SendMessage("Client's message");

            // Verify
            autoEvent.WaitOne();

            Assert.AreEqual("Client's message", message);
        }
        public void Client_Disconnect_ServerShouldFireClientDisconnectedEvent()
        {
            // Prepare
            var isDisconnected = false;

            _server = new ServerPipeline();

            _server.ClientDisconnectedEvent += (sender, args) =>
            {
                isDisconnected = true;
            };

            _server.Start();
            Assert.IsFalse(isDisconnected);

            _client = new ClientPipeline(_server.ServerId);
            _client.Start();

            // Act
            _client.Stop();
            _client = null;
            Thread.Sleep(100);

            // Verify
            Assert.IsTrue(isDisconnected);
        }