Exemplo n.º 1
0
        public void HandleNewPacket()
        {
            var touch = new RemoteTouch();
            InputPacketsAnalyser analyser = CreateAnalyser(touch);
            analyser.HandleNewMessage(CreateTestPacket());

            Assert.True(touch.IsAvailable);
            Assert.AreEqual(touch.GetState(0), State.JustPressed);
            Assert.AreEqual(touch.GetState(1), State.Released);
            Assert.AreEqual(touch.GetPosition(4), new Point(0.5f, 0.3f));
        }
Exemplo n.º 2
0
 private InputPacketsAnalyser CreateAnalyser(RemoteTouch touch)
 {
     var analyser = new InputPacketsAnalyser();
     analyser.SetActiveTouch(touch);
     return analyser;
 }
Exemplo n.º 3
0
 public void RunCoverage()
 {
     var touch = new RemoteTouch();
     touch.Run();
 }
Exemplo n.º 4
0
        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();
            }
        }