示例#1
0
        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");
        }
示例#2
0
        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");
        }
示例#3
0
 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");
 }
示例#4
0
        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");
        }
示例#5
0
        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");
        }
示例#6
0
        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");
        }
示例#7
0
        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");
        }