示例#1
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Use: <program> host port");
                return;
            }
            StressingClient client = new StressingClient(args[0], args[1]);
            Thread dialogThread = null;
            try
            {
                client.Start();
                client.Client.Configuration.PingInterval = TimeSpan.FromSeconds(1);
                dialogThread = StatisticsDialog.On(client.Client);

                Console.WriteLine("Client started; press a key to stop");
                Console.ReadKey();
            }
            finally
            {
                if (dialogThread != null) { dialogThread.Abort(); }
                client.Stop();
                client.Dispose();
            }
            Console.WriteLine("Client shut down");
        }
示例#2
0
        public void StressTest()
        {
            TimeSpan duration = TimeSpan.FromSeconds(30);
            Console.WriteLine("Starting Stress Test ({0} seconds)", duration.TotalSeconds);
            server = new EchoingServer(serverPort);
            server.Start();

            clients = new List<StressingClient>();
            for (int i = 0; i < 5; i++)
            {
                StressingClient c = new StressingClient("127.0.0.1", serverPort.ToString());
                c.Start();
                clients.Add(c);
            }

            Thread.Sleep(duration);
            Assert.IsFalse(server.ErrorOccurred);
            foreach (StressingClient c in clients)
            {
                Assert.IsFalse(c.ErrorOccurred);
            }
        }