Exemplo n.º 1
0
        public bool ConnectTest(Behaviour behaviour)
        {
            var connection = new TestJetConnection(behaviour);
            var peer       = new JetPeer(connection);

            peer.Connect(this.OnConnect, 1);
            Assert.AreEqual(this.connectCallbackCalled, true);
            return(this.connectCompleted);
        }
Exemplo n.º 2
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());
        }