Пример #1
0
 public void LoadTestMethod()
 {
     int[] questions = new int[] {1, 2, 3, 4, 5, 6, 7, 98, 100, 169, 239017};
     bool[] answers = new bool[] {false, true, true, false, true, false, true, false, false, false, true};
     int testClients = 300;
     Server.ServerProgram server = new Server.ServerProgram();
     try
     {
         server.Start(4);
         List<TestClient> clients = new List<TestClient>(testClients);
         for (int i = 0; i < testClients; ++i)
         {
             int idx = _random.Next(questions.Length - 1);
             var client = new TestClient(questions[idx], answers[idx]);
             clients.Add(client);
             client.Request();
         }
         foreach (var client in clients)
         {
             client.Join();
         }
         foreach (var client in clients)
         {
             Assert.IsTrue(client.GetResult());
         }
     }
     finally
     {
         server.Stop();
     }
     Trace.Write("finished = " + _ok);
     if (_exception != null)
     {
         throw new AssertFailedException("Exception in one of client threads", _exception);
     }
 }