public void Client_ParallelMessagesWithMetaData_Server() { Counter counter = new Counter(); ManualResetEvent mre = new ManualResetEvent(false); SimpleSockets.Server.MessageWithMetadataReceivedDelegate msgRec = (client, msg, metadata, type) => { counter.Count(); if (counter.GetCount == _numClients * _numMessages) { mre.Set(); } }; _server.MessageWithMetaDataReceived += msgRec; foreach (var client in _clients) { new Thread(() => SendMessageWithMetadata(client)).Start(); } // If it can't complete in 30 minutes fail mre.WaitOne(new TimeSpan(0, 30, 0)); _server.MessageWithMetaDataReceived -= msgRec; Assert.AreEqual((_numMessages * _numClients), counter.GetCount); // True if all messages have been received. }
public void Client_CustomMessage_Server() { string message = "This is a test custom header message."; var dictionary = new Dictionary <object, object>(); dictionary.Add("Test", "This is a test"); SimpleSockets.Server.MessageWithMetadataReceivedDelegate msgRec = (client, msg, head, type) => { Assert.AreEqual(message, msg); Assert.AreEqual(dictionary, head); }; using (var monitor = new EventMonitor(_server, "MessageWithMetaDataReceived", msgRec, Mode.MANUAL)) { _client.SendMessageWithMetadata(message, dictionary); monitor.Verify(); } }