Exemplo n.º 1
0
        public void SetTestOnOwnState()
        {
            JValue  stateValue = new JValue(12);
            JObject message    = peer.AddState(TestSetConnection.successPath, stateValue, this.OnSet, this.AddResponseCallback, 3000);

            Assert.Throws <ArgumentException>(delegate
            {
                message = peer.Set(TestSetConnection.successPath, stateValue, this.SetResponseCallback, 3000, 0.0);
            }, "Setting a state that is owned by the peer didn't failed");
        }
Exemplo n.º 2
0
        public void SetTestOnOwnState()
        {
            peer = new JetPeer(new TestSetCallbackConnection());
            JValue  stateValue = new JValue(12);
            JObject message    = peer.AddState(TestSetCallbackConnection.successPath, stateValue, this.OnSet, this.AddResponseCallback, 3000);

            Assert.Throws <ArgumentException>(
                delegate
            {
                JValue newValue = new JValue(13);
                peer.Set(TestSetCallbackConnection.successPath, newValue, this.AddResponseCallback, 3000, 0.0);
            },
                "no exception thrown when setting own state");
        }
Exemplo n.º 3
0
        public void RemoveStatesWhenDisconnect()
        {
            const string state = "theState";

            var connection = new TestJetConnection(Behaviour.ConnectionSuccess);
            var peer       = new JetPeer(connection);

            peer.Connect(this.OnConnect, 1);
            JValue stateValue = new JValue(12);

            peer.AddState(state, stateValue, this.OnSet, this.OnResponse, 3000);
            peer.Disconnect();
            Assert.AreEqual(0, peer.NumberOfRegisteredStateCallbacks());
            string removeJson = connection.messages[1];
            JToken json       = JToken.Parse(removeJson);
            JToken method     = json["method"];

            Assert.AreEqual("remove", method.ToString());
            JToken parameters = json["params"];
            JToken path       = parameters["path"];

            Assert.AreEqual(state, path.ToString());
        }