Пример #1
0
 public void TearDown()
 {
     _server.Dispose();
     _client.Dispose();
     _server = null;
     _client = null;
 }
Пример #2
0
        public void Setup()
        {
            ManualResetEvent mre = new ManualResetEvent(false);
            var cert             = new X509Certificate2(new SocketHelper().GetCertFileContents(), "Password");

            _server = new SimpleSocketTcpSslListener(cert);
            _client = new SimpleSocketTcpSslClient(cert);

            new Thread(() => _server.StartListening(13000)).Start();

            ClientConnectedDelegate con = (client) =>
            {
                _clientid = client.Id;
                mre.Set();
            };

            _contract = new MessageContractImpl();
            _client.AddMessageContract(_contract);
            _server.AddMessageContract(_contract);

            _server.ClientConnected += con;

            _client.StartClient("127.0.0.1", 13000);

            mre.WaitOne(10000);
            _server.ClientConnected -= con;
        }
Пример #3
0
        public void Setup()
        {
            Counter          clientCounter = new Counter();
            ManualResetEvent mre           = new ManualResetEvent(false);

            _cert = new X509Certificate2(new SocketHelper().GetCertFileContents(), "Password");

            _server = new SimpleSocketTcpSslListener(_cert);

            new Thread(() => _server.StartListening(13000)).Start();

            ClientConnectedDelegate con = (client) =>
            {
                clientCounter.Count();
                if (clientCounter.GetCount == _numClients)
                {
                    mre.Set();
                }
            };


            _server.ClientConnected += con;

            for (var i = 0; i < _numClients; i++)
            {
                initClient();
            }


            mre.WaitOne(new TimeSpan(0, 20, 0));

            _server.ClientConnected -= con;

            Assert.AreEqual(_numClients, clientCounter.GetCount);
        }
Пример #4
0
        public void TearDown()
        {
            foreach (var client in _clients)
            {
                client.Dispose();
            }

            _server.Dispose();
            _server = null;
            _clients.Clear();
        }