public void RunTest() { //start server Server target = new Server(); target.Run(); int numOfUsers = 50; List<player> players = new List<player>(); //create and login users for (int i = 0; i < numOfUsers; i++) { try { TcpClient client = new TcpClient(); client.Connect(ip, port); StreamWriter sender = new StreamWriter(client.GetStream()); players.Add(new player(i, client, sender)); } catch { Assert.Fail("Player " + i + " did not connect."); } } //move users around Random r = new Random(665); foreach (player p in players) { string output = "<1><" + r.Next(0, 300) + "><0>"; p.sender.WriteLine(output); p.sender.Flush(); } foreach (player p in players) { string output = "<1><0><0>"; p.sender.WriteLine(output); p.sender.Flush(); } //disconnect users foreach (player p in players) { p.client.GetStream().Close(); p.client.Close(); } Assert.IsTrue(true); }
static void Main(string[] args) { Server server = new Server(); server.Run(); }