示例#1
0
 private InputPacketsAnalyser CreateAnalyser(RemoteTouch touch)
 {
     var analyser = new InputPacketsAnalyser();
     analyser.SetActiveTouch(touch);
     return analyser;
 }
        private void RunTestCodeWithServerAndClientConnection(TestCodeDelegate deleg)
        {
            var mouse = new RemoteMouse();
            var touch = new RemoteTouch();
            var keyboard = new RemoteKeyboard();
            var analyser = new InputPacketsAnalyser();
            analyser.SetActiveMouse(mouse);
            analyser.SetActiveTouch(touch);
            analyser.SetActiveKeyboard(keyboard);
            var server = new RemoteServer(analyser, TestPort);
            RemoteClient client = CreateTestClient();
            Task connection = client.ConnectToServerAsync();
            connection.Wait();

            var data = new TestObjects
            { Client = client, Mouse = mouse, Touch = touch, Keyboard = keyboard };
            server.Received += delegate
            {
                data.NumberOfReceivedMessages++;
            };

            try
            {
                if (deleg != null)
                    deleg(data);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
            finally
            {
                client.Dispose();
                server.Dispose();
            }
        }