public void Ssl_Client_ParallelMessages_Server()
        {
            Counter counter = new Counter();

            ManualResetEvent mre = new ManualResetEvent(false);


            SimpleSockets.Server.MessageReceivedDelegate msgRec = (client, msg) => {
                counter.Count();

                if (counter.GetCount == _numClients * _numMessages)
                {
                    mre.Set();
                }
            };

            _server.MessageReceived += msgRec;

            foreach (var client in _clients)
            {
                new Thread(() => SendMessages(client, false)).Start();
            }

            // If it can't complete in 30 minutes fail
            mre.WaitOne(new TimeSpan(0, 30, 0));

            _server.MessageReceived -= msgRec;
            Assert.AreEqual((_numMessages * _numClients), counter.GetCount);             // True if all messages have been received.
        }
Exemple #2
0
        public void Client_Message_Server()
        {
            string message = "This is a test message.";

            SimpleSockets.Server.MessageReceivedDelegate msgRec = (client, msg) => {
                Assert.AreEqual(message, msg);
            };

            using (var monitor = new EventMonitor(_server, "MessageReceived", msgRec, Mode.MANUAL))
            {
                _client.SendMessage(message);
                monitor.Verify();
            }
        }