public void InvalidOriginTest()
        {
            var client = new ClientSocket(new ExtendedClientHandshake()
            {
                Origin = "not test project",
                Host = "localhost:8181",
                ResourcePath = "/test"
            });
            Thread.Sleep(1000); // allow the socket some time to connect

            Assert.IsFalse(TestSocket.ConnectedCalled, "socket connected with wrong origin");
        }
        public void ConnectTest()
        {
            var client = new ClientSocket(new ExtendedClientHandshake()
            {
                Origin = "testproject",
                Host = "localhost:8181",
                ResourcePath = "/test"
            });
            Thread.Sleep(1000); // allow the socket some time to connect

            Assert.IsTrue(TestSocket.ConnectedCalled, "sokcet didn't connect");
        }
 public void Ecco()
 {
     var client = new ClientSocket(new ExtendedClientHandshake()
     {
         Origin = "testproject",
         Host = "localhost:8181",
         ResourcePath = "/ecco"
     });
     var msg = "hvad drikker møller";
     client.Send(msg);
     var answer = client.Receive();
     Assert.AreEqual(msg, answer, "didn't ecco right");
 }
        public void InvalidChallengeTest()
        {
            // challenge that will (most likely) not fit with the keys of the handshake
            var challenge = new ArraySegment<byte>(new byte[] {1,3,3,4,5,6,7,8});

            var hs = new ExtendedClientHandshake()
                {
                    Origin = "testproject",
                    Host = "localhost:8181",
                    ResourcePath = "/test",
                    ChallengeBytes = challenge // wrong challenge
                };

            hs.ChallengeBytes = challenge;
            var client = new ClientSocket(hs);
            Thread.Sleep(1000);

            Assert.IsTrue(TestSocket.DisconnectedCalled, "socket didn't disconnect when it should have");
        }
        public void SendMuch()
        {
            var client = new ClientSocket(new ExtendedClientHandshake()
            {
                Origin = "testproject",
                Host = "localhost:8181",
                ResourcePath = "/send"
            });

            SendToMe.Count = 1000 * 1000;

            client.Send(new String('y', SendToMe.Count));
            Thread.Sleep(1000);
            Assert.IsTrue(SendToMe.Passed, "didn't send much right");
        }
        public void Receive()
        {
            var client = new ClientSocket(new ExtendedClientHandshake()
            {
                Origin = "testproject",
                Host = "localhost:8181",
                ResourcePath = "/get"
            });

            var answer = client.Receive();
            Assert.AreEqual(answer.Length, GetFromMe.Count, "didn't receive right");
        }
        public void NoPathTest()
        {
            var client = new ClientSocket(new ExtendedClientHandshake()
            {
                Origin = "testproject",
                Host = "localhost:8181",
                ResourcePath = "not /test" // path not registered
            });
            Thread.Sleep(1000); // allow the socket some time to connect

            Assert.IsFalse(TestSocket.ConnectedCalled, "socket connected with wrong path");
        }