public static void DetailedHistory_Decrypted_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "my_channel";
            pubnub.CIPHER_KEY = "enigma";
            string msg = "Test Message";

            Common.deliveryStatus = false;
            pubnub.publish(channel, msg, Common.DisplayReturnMessage);
            while (!Common.deliveryStatus) ;

            Common.deliveryStatus = false;
            pubnub.detailedHistory(channel, 1, Common.DisplayReturnMessage);
            while (!Common.deliveryStatus) ;
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            if (Common.objResponse.Equals(null))
            {
              Assert.Fail("Null response");
            }
            else
            {
                IList<object> fields = Common.objResponse as IList<object>;
                Console.WriteLine("fields[0]: " + fields[0]);
                Console.WriteLine("fields[1]: " + fields[1]);
                Assert.AreEqual(fields[0], msg);
            }
        }
        public void ItShouldReturnDetailedHistory()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";

            //pubnub.PropertyChanged += new PropertyChangedEventHandler(Pubnub_PropertyChanged);

            //publish a test message.
            pubnub.publish (channel, "Test message");
            bool responseStatus = false;

            object objHistory = null;

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

                if (e.PropertyName == "DetailedHistory")
                {
                    objHistory = ((Pubnub)sender).DetailedHistory;

                    responseStatus = true;
                }
            };

            pubnub.detailedHistory(channel, 1);

            while (!responseStatus) ;

            string strResponse = "";
            if (objHistory.Equals (null)) {
                Assert.Fail("Null response");
            }
            else
            {
                List<object> fields = (List<object>)objHistory;

                foreach(object lst in fields)
                {
                    strResponse = lst.ToString();
                    Console.WriteLine(strResponse);
                    Assert.IsNotEmpty(strResponse);
                }
            }
        }
        public void PublishAndHistory()
        {
            //demo init
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            //cipher key
            pubnub.CIPHER_KEY = "enigma";
            //channel
            string channel = "hello_world";
            //string message
            string strMsg = "yay!";
            //publish the message
            pubnub.publish(channel, strMsg);

            bool deliveryStatus = false;

            string strResponse = "empty";
            //create an event handler for the proertyChanged event.
            //This will be called when we get a response from the server
            pubnub.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "DetailedHistory")
                {
                    Console.WriteLine("\n*********** DetailedHistory Messages *********** ");
                    List<object> lstResponse  = (List<object>)((Pubnub)sender).DetailedHistory;
                    strResponse = lstResponse[0].ToString();
                    deliveryStatus = true;
                }
            };

            pubnub.detailedHistory(channel, 1);
            //wait till the deliveryStatus is true.
            //the variable is modified on the PropertyChanged event
            while (!deliveryStatus) ;

            Assert.AreEqual(strMsg, strResponse);
        }
        public static void DetailedHistory_Example()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "my_channel";
            pubnub.CIPHER_KEY = "";
            string msg = "Test Message";
            Common.deliveryStatus = false;
            pubnub.publish(channel, msg, Common.DisplayReturnMessage);
            while (!Common.deliveryStatus) ;

            Common.deliveryStatus = false;
            pubnub.detailedHistory(channel, 10, Common.DisplayReturnMessage);
            while (!Common.deliveryStatus) ;
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            if (Common.objResponse.Equals(null))
            {
              Assert.Fail("Null response");
            }
            else
            {
                IList<object> fields = Common.objResponse as IList<object>;

                foreach (object item in fields)
                {
                    string strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0}", strResponse));
                    Assert.IsNotEmpty(strResponse);
                }
            }
        }
        public static void TestEncryptedDetailedHistory()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false);
            string channel = "my_channel";
            pubnub.CIPHER_KEY = "enigma";

            int total_msg = 10;
            long starttime = Common.Timestamp(pubnub);
            Dictionary<long, string> inputs = new Dictionary<long, string>();
            for (int i = 0; i < total_msg / 2; i++)
            {
                string msg = i.ToString();
                pubnub.publish(channel, msg, Common.DisplayReturnMessage);
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long midtime = Common.Timestamp(pubnub);
            for (int i = total_msg / 2; i < total_msg; i++)
            {
                string msg = i.ToString();
                pubnub.publish(channel, msg, Common.DisplayReturnMessage);
                //long t = Timestamp();
                //inputs.Add(t, msg);
                Console.WriteLine("Message # " + i.ToString() + " published");
            }

            long endtime = Common.Timestamp(pubnub);
            while (!Common.deliveryStatus) ;

            pubnub.detailedHistory(channel, total_msg, Common.DisplayReturnMessage);
            Common.deliveryStatus = false;
            while (!Common.deliveryStatus) ;
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
            string strResponse = "";
            if (Common.objResponse.Equals(null))
            {
              Assert.Fail("Null response");
            }
            else
            {
                IList<object> fields = Common.objResponse as IList<object>;
                int j = 0;
                foreach (object item in fields)
                {
                    strResponse = item.ToString();
                    Console.WriteLine(String.Format("resp:{0} :: j: {1}", strResponse, j));
                    if(j<total_msg)
                        Assert.AreEqual(j.ToString(), strResponse);
                    j++;
                }
            }
        }
        public void ItShouldReturnDetailedHistory()
        {
            Pubnub pubnub = new Pubnub(
                    "demo",
                    "demo",
                    "",
                    "",
                    false
              );
              string channel = "hello_world";

              //pubnub.PropertyChanged += new PropertyChangedEventHandler(Pubnub_PropertyChanged);

              Common.deliveryStatus = false;
              //publish a test message.
              pubnub.publish(channel, "Test message", Common.DisplayReturnMessage);

              while (!Common.deliveryStatus)
            ;

              Common.deliveryStatus = false;
              pubnub.detailedHistory(channel, 1, 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);
              }
              }
        }