public void Client_ConnectMultipleClientsToServer_ConnectionsSucceed() { var port = Network.GetTcpPort(); var uriString = string.Format("http://localhost:{0}", port); var uri = new Uri(uriString); var applicationContext = Substitute.For<IApplicationContext>(); using (var server = new Server.Server(uri)) { server.Start(applicationContext); var clients = new List<Client.Client>(); const int NumClients = 100; var clientReceivedMessageCount = 0; for (var i = 0; i < NumClients; i++) { var client = new Client.Client(uri); client.OnMessage += (sender, eventArgs) => clientReceivedMessageCount++; var connected = client.Connect(Client.Enums.TransportType.ServerSentEvents); Assert.IsTrue(connected); clients.Add(client); } Assert.AreEqual(NumClients, clients.Count); server.SendMessage("x"); foreach (var client in clients) { client.Dispose(); } // Probably won't receive all messages - no sleep or synchronisation implemented to ensure exactly NumClients messages Assert.IsTrue(clientReceivedMessageCount > 0); Assert.IsTrue(clientReceivedMessageCount <= NumClients); } }