コード例 #1
0
        public void ThenItShouldReturnReceivedMessage()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";

            Common.deliveryStatus = false;

            pubnub.presence(channel, Common.DisplayReturnMessage);
            while (!Common.deliveryStatus) ;

            string strResponse = "";
            if (Common.objResponse.Equals (null)) {
                Assert.Fail("Null response");
            }
            else
            {
                IList<object> fields = Common.objResponse as IList<object>;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(strResponse);
                    //Assert.IsNotEmpty(strResponse);
                }
                Assert.AreEqual(fields[2], "hello_world-pnpres");
            }
        }
コード例 #2
0
        public void ThenItShouldReturnReceivedMessage()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";

            bool responseStatus = false;
            List<object> lstHistory = null;

            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {

                if (e.PropertyName == "Presence")
                {
                    lstHistory = ((Pubnub)sender).Presence;

                    responseStatus = true;
                }
            };

            pubnub.presence(channel);
            while (!responseStatus) ;

            string strResponse = "";
            if (lstHistory.Equals (null)) {
                Assert.Fail("Null response");
            }
            else
            {
                foreach(object lst in lstHistory)
                {
                    strResponse = lst.ToString();
                    Console.WriteLine(strResponse);
                    //Assert.IsNotEmpty(strResponse);
                }
                Assert.AreEqual(lstHistory[2], "hello_world-pnpres");
            }
        }