//[Test]
				public void Test0ForComplexMessage2 ()
				{
						Pubnub pubnub = new Pubnub (
								"demo",
								"demo",
								"",
								"enigma",
								false
						);
						string channel = "hello_world";
						//pubnub.NonSubscribeTimeout = int.Parse (operationTimeoutInSeconds);
						object message = new PubnubDemoObject ();
						Common common = new Common ();
						DeliveryStatus = false;
						pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2");
						pubnub.Publish<string>(channel, message, DisplayReturnMessageECM2, DisplayErrorMessageECM2);


						Pubnub pubnub2 = new Pubnub (
								"demo",
								"demo",
								"",
								"",
								true
						);
						object message2 = new PubnubDemoObject ();

						string json = Common.Serialize (message2);
						DeliveryStatus = false;
						pubnub2.PubnubUnitTest = common.CreateUnitTestInstance ("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl");


						pubnub2.Publish (channel, message2, DisplayReturnMessageECM2Ssl, DisplayErrorMessageECM2Ssl);
						//common.WaitForResponse ();

						Pubnub pubnub3 = new Pubnub (
								"demo",
								"demo",
								"",
								"",
								false
						);
						object message3 = new PubnubDemoObject ();
						//object message = new CustomClass2();

						string json3 = Common.Serialize (message3);

						pubnub3.PubnubUnitTest = common.CreateUnitTestInstance ("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2");
						pubnub3.Publish<string> (channel, message3, DisplayReturnMessage, DisplayErrorMessage);
				}
Ejemplo n.º 2
0
        public void ThenItShouldReturnSuccessCodeAndInfo()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );
            string channel = "hello_world";
            string message = "Pubnub API Usage Example";

            Common common = new Common();
            
            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfo");

            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage);
            //wait till the response is received from the server
            while (!common.DeliveryStatus) ;
            IList<object> fields = common.Response as IList<object>;
            string sent = fields[1].ToString();
            string one = fields[0].ToString();
            Assert.AreEqual("Sent", sent);
            Assert.AreEqual("1", one);
        }
Ejemplo n.º 3
0
        public void ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "enigma",
                false
                );
            string channel = "hello_world";
            object message = new PubnubDemoObject();

            Common common = new Common();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2");

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage);
            //wait till the response is received from the server
            while (!common.DeliveryStatus)
            {
                ;
            }
            IList <object> fields = common.Response as IList <object>;
            string         sent   = fields[1].ToString();
            string         one    = fields[0].ToString();

            Assert.True("Sent".Equals(sent));
            Assert.True("1".Equals(one));
        }
Ejemplo n.º 4
0
        public void ThenItShouldReturnSuccessCodeAndInfoWhenEncryptedAndSecretKeyed()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "secret",
                "enigma",
                false
                );
            string channel = "hello_world";
            string message = "Pubnub API Usage Example";

            Common common = new Common();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoWhenEncryptedAndSecretKeyed");

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage);
            //wait till the response is received from the server
            while (!common.DeliveryStatus)
            {
                ;
            }
            Console.WriteLine(common.Response.ToString());
            IList <object> fields = common.Response as IList <object>;
            string         sent   = fields[1].ToString();
            string         one    = fields[0].ToString();

            Assert.True("Sent".Equals(sent));
            Assert.True("1".Equals(one));
        }
Ejemplo n.º 5
0
        public void ThenItShouldReturnSuccessCodeAndInfo()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false
                );
            string channel = "hello_world";
            string message = "Pubnub API Usage Example";

            Common common = new Common();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfo");

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage);
            //wait till the response is received from the server
            common.WaitForResponse();
            if (common.Response != null)
            {
                IList <object> fields = common.Response as IList <object>;
                string         sent   = fields [1].ToString();
                string         one    = fields [0].ToString();
                Assert.True(("Sent").Equals(sent));
                Assert.True(("1").Equals(one));
            }
            else
            {
                Assert.Fail("Null response");
            }
        }
Ejemplo n.º 6
0
        public void ThenSubscribeShouldReturnConnectStatus()
        {
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenSubscribedToAChannel", "ThenSubscribeShouldReturnConnectStatus");

            string channel = "hello_world";

            pubnub.Subscribe <string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessage);

            while (!common.DeliveryStatus)
            {
                ;
            }

            Assert.True(ParseResponse(common.Response));

            /*if(ParseResponse(common.Response))
             * {
             *      Assert.NotNull(common.Response);
             * }
             * else
             * {
             *      Assert.Fail("Test failed");
             * }*/
        }
        public void ThenNonExistentChannelShouldReturnNotSubscribed()
        {
            Pubnub pubnub = new Pubnub(Common.PublishKey,
                                       Common.SubscribeKey,
                                       "", "", false);

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenUnsubscribedToAChannel", "ThenNonExistentChannelShouldReturnNotSubscribed");

            string channel = "hello_world";

            pubnub.Unsubscribe <string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage);
            common.WaitForResponse();

            Console.WriteLine("Response:" + common.Response);
            if (common.Response.ToString().ToLower().Contains("not subscribed"))
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 8
0
 public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl()
 {
   Pubnub pubnub = new Pubnub(
     "demo",
     "demo",
     "",
     "",
     true
     );
   string channel = "hello_world";
   object message = new PubnubDemoObject();
   //object message = new CustomClass2();
   
   string json = JsonConvert.SerializeObject(message);
   Common common = new Common();
   
   pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl");
   
   common.DeliveryStatus = false;
   common.Response = null;
   
   pubnub.Publish(channel, message, common.DisplayReturnMessage);
   //wait till the response is received from the server
   while (!common.DeliveryStatus);
   IList<object> fields = common.Response as IList<object>;
   string sent = fields[1].ToString();
   string one = fields[0].ToString();
   Assert.AreEqual("Sent", sent);
   Assert.AreEqual("1", one);
 }
        public void ThenNonExistentChannelShouldReturnNotSubscribed()
        {
            Pubnub pubnub = new Pubnub(Common.PublishKey,
                Common.SubscribeKey,
                "", "", false);

            Common common = new Common();
            common.DeliveryStatus = false;
            common.Response = null;
      
            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenUnsubscribedToAChannel", "ThenNonExistentChannelShouldReturnNotSubscribed");
      
            string channel = "hello_world";
      
            pubnub.Unsubscribe<string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage);
            common.WaitForResponse();

            Console.WriteLine("Response:" + common.Response);
            if (common.Response.ToString().ToLower().Contains("not subscribed"))
                {
                    Assert.Pass();
                } else
                {
                    Assert.Fail();
                }
        }
Ejemplo n.º 10
0
        public void ThenItShouldReturnTimeStampSSL ()
        {
            Pubnub pubnub = new Pubnub (
                                Common.PublishKey,
                                Common.SubscribeKey,
                                "",
                                "",
                                true
                            );

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");
            ;

            string response = "";

            pubnub.Time (common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            IList<object> fields = common.Response as IList<object>;
            response = fields [0].ToString ();
            Console.WriteLine ("Response:" + response);
            Assert.AreNotEqual ("0", response);
            pubnub.EndPendingRequests ();
        }
Ejemplo n.º 11
0
		public void ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"enigma",
				false
				);
			string channel = "hello_world";
			object message = new PubnubDemoObject();
			
			Common common = new Common();
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2");
			
			common.DeliveryStatus = false;
			common.Response = null;
			
			pubnub.Publish(channel, message, common.DisplayReturnMessage);
			//wait till the response is received from the server
			while (!common.DeliveryStatus) ;
			IList<object> fields = common.Response as IList<object>;
			string sent = fields[1].ToString();
			string one = fields[0].ToString();
			Assert.True("Sent".Equals(sent));
			Assert.True("1".Equals(one));
		}
Ejemplo n.º 12
0
        public void ThenShouldReturnUnsubscribedMessageSSL ()
        {
            Pubnub pubnub = new Pubnub (Common.PublishKey,
                          Common.SubscribeKey, "", "", true);

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenUnsubscribedToAChannel", "ThenShouldReturnUnsubscribedMessage");

            string channel = "hello_world2";

            pubnub.Subscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.Unsubscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse ();

            if (common.Response.ToString ().Contains ("Unsubscribed from")) {
                Console.WriteLine ("Response:" + common.Response);
                Assert.Pass ();
            } else {
                Assert.Fail ();
            }    
            pubnub.EndPendingRequests ();
        }
        public void ItShouldReturnDetailedHistory ()
        {
            GC.Collect ();
            Pubnub pubnub = new Pubnub (
                          Common.PublishKey,
                          Common.SubscribeKey,
                          "",
                          "",
                          false
                      );
            string channel = "hello_world_de1";
            string message = "Test Message";
      
            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "ItShouldReturnDetailedHistory");
      
            //publish a test message. 
            pubnub.Publish (channel, message, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
      
            common.WaitForResponse ();

            common.DeliveryStatus = false;
            common.Response = null;
            Thread.Sleep (1000);
            pubnub.DetailedHistory (channel, 1, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse ();

            ParseResponse (common.Response, 0, 0, message);
            pubnub.EndPendingRequests ();
        }
Ejemplo n.º 14
0
        public void DetailedHistoryExample()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false);
            string channel = "hello_world";

            string message = "Test Message";

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested", "DetailHistoryCount10ReturnsRecords");

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.DetailedHistory(channel, 10, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse();
            Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");

            ParseResponse(common.Response, 0, 0, "");
        }
        public void ThenItShouldReturnTimeStampSSL()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                true
                );

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");
            ;

            string response = "";

            pubnub.Time(common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse();

            IList <object> fields = common.Response as IList <object>;

            response = fields [0].ToString();
            Console.WriteLine("Response:" + response);
            Assert.AreNotEqual("0", response);
            pubnub.EndPendingRequests();
        }
Ejemplo n.º 16
0
        //[Test]
        public void ThenMultiSubscribeShouldReturnConnectStatus()
        {
            Pubnub pubnub = new Pubnub(Common.PublishKey,
                                       Common.SubscribeKey,
                                       "", "", false);

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenSubscribedToAChannel", "ThenMultiSubscribeShouldReturnConnectStatus");

            string channel1 = "testChannel1";

            pubnub.Subscribe <string> (channel1, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse();

            bool receivedChannel1ConnectMessage = ParseResponse(common.Response);

            common.DeliveryStatus = false;
            common.Response       = null;

            string channel2 = "testChannel2";

            pubnub.Subscribe <string> (channel2, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse();

            bool receivedChannel2ConnectMessage = ParseResponse(common.Response);

            Assert.True(receivedChannel1ConnectMessage && receivedChannel2ConnectMessage);
            pubnub.EndPendingRequests();
        }
Ejemplo n.º 17
0
		public void ThenItShouldReturnTimeStamp()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"",
				false
				);
			
			Common common = new Common();
			common.DeliveryStatus = false;
			common.Response = null;
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");;
			
			string response = "";
			
			pubnub.Time(common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			
			IList<object> fields = common.Response as IList<object>;
			response = fields[0].ToString();
			Console.WriteLine("Response:" + response);
			Assert.AreNotEqual("0",response);
		}
 public void ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2()
 {
     Pubnub pubnub = new Pubnub(
         Common.PublishKey,
         Common.SubscribeKey,
                       "",
                       "enigma",
                       false
                   );
     string channel = "hello_world";
     object message = new PubnubDemoObject();
   
     Common common = new Common();
   
     pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2");
   
     common.DeliveryStatus = false;
     common.Response = null;
   
     pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage);
     //wait till the response is received from the server
     common.WaitForResponse();
     if (common.Response != null)
         {
             IList<object> fields = common.Response as IList<object>;
             string sent = fields [1].ToString();
             string one = fields [0].ToString();
             Assert.AreEqual("Sent", sent);
             Assert.AreEqual("1", one);
         } else
         {
             Assert.Fail("Null response");
         }
 }
Ejemplo n.º 19
0
    public void ThenShouldReturnUnsubscribedMessage()
    {
      Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
      
      Common common = new Common();
      common.DeliveryStatus = false;
      common.Response = null;
      
      pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenUnsubscribedToAChannel", "ThenShouldReturnUnsubscribedMessage");
      
      string channel = "hello_world";

      pubnub.Subscribe<string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

      common.WaitForResponse();
      common.DeliveryStatus = false;
      common.Response = null;

      pubnub.Unsubscribe<string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
      common.WaitForResponse();

      if (common.Response.ToString().Contains ("Unsubscribed from")) {
        Console.WriteLine("Response:" + common.Response);
		Assert.NotNull(common.Response);
      }
      else
      {
		Assert.Fail("ThenShouldReturnUnsubscribedMessage failed");
      }    
    }
Ejemplo n.º 20
0
        public void ThenShouldReturnUnsubscribedMessage()
        {
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenUnsubscribedToAChannel", "ThenShouldReturnUnsubscribedMessage");

            string channel = "hello_world";

            pubnub.Subscribe <string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse();
            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Unsubscribe <string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse();

            if (common.Response.ToString().Contains("Unsubscribed from"))
            {
                Console.WriteLine("Response:" + common.Response);
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
		public void ItShouldReturnDetailedHistory()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"",
				false
				);
			string channel = "hello_world";
			string message = "Test message";
			
			Common common = new Common();
			common.DeliveryStatus = false;
			common.Response = null;
			
			//publish a test message. 
			pubnub.Publish(channel, message, common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus); 
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested" ,"ItShouldReturnDetailedHistory");
			
			common.DeliveryStatus = false;
			common.Response = null;
			pubnub.DetailedHistory(channel, 1, common.DisplayReturnMessage);
			while (!common.DeliveryStatus);
			
			ParseResponse(common.Response, 0, 0, message);
		}
Ejemplo n.º 22
0
        public void ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "enigma",
                false
                );
            string channel = "hello_world";
            object message = new PubnubDemoObject();

            Common common = new Common();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2");

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage);
            //wait till the response is received from the server
            common.WaitForResponse();
            if (common.Response != null)
            {
                IList <object> fields = common.Response as IList <object>;
                string         sent   = fields [1].ToString();
                string         one    = fields [0].ToString();
                Assert.AreEqual("Sent", sent);
                Assert.AreEqual("1", one);
            }
            else
            {
                Assert.Fail("Null response");
            }
        }
Ejemplo n.º 23
0
        public void ThenItShouldReturnReceivedMessageCipher()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "enigma",
                false);
            string channel = "hello_world";

            Common common = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenSubscribedToAChannel", "ThenSubscribeShouldReturnReceivedMessageCipher");

            string message = "Test Message";

            pubnub.Subscribe(channel, common.DisplayReturnMessage, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy);
            Thread.Sleep(3000);

            pubnub.Publish(channel, message, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy);

            common.WaitForResponse();

            if (common.Response != null)
            {
                IList <object> fields = common.Response as IList <object>;

                if (fields [0] != null)
                {
                    var myObjectArray = (from item in fields select item as object).ToArray();
                    Console.WriteLine("Response:" + myObjectArray[0].ToString());
                    Assert.True((message).Equals(myObjectArray[0].ToString()));

                    /*var myObjectArray = (from item in fields select item as object).ToArray ();
                     *
                     * IList<object> enumerable = myObjectArray [0] as IList<object>;
                     * if ((enumerable != null) && (enumerable.Count > 0))
                     * {
                     *  Console.WriteLine ("Response:" + enumerable[0].ToString ());
                     *  Assert.AreEqual(message, enumerable[0].ToString());
                     * }
                     * else
                     * {
                     * Assert.Fail("Test not successful");
                     * }*/
                }
                else
                {
                    Assert.Fail("Test not successful");
                }
            }
            else
            {
                Assert.Fail("No response");
            }
        }
Ejemplo n.º 24
0
 public void ThenItShouldReturnReceivedMessageForComplexMessage () 
 {
     
     Pubnub pubnub = new Pubnub (
         "demo",
         "demo",
         "",
         "",
         false);
     string channel = "hello_world";
     
     Common common = new Common();
     common.DeliveryStatus = false;
     common.Response = null;
     
     pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenSubscribedToAChannel", "ThenItShouldReturnReceivedMessageForComplexMessage");
     
     pubnub.Subscribe (channel, common.DisplayReturnMessage, common.DisplayReturnMessageDummy); 
     Thread.Sleep(3000);
     
     CustomClass message = new CustomClass();
     
     pubnub.Publish (channel, (object)message, common.DisplayReturnMessageDummy);
     
     //cm.deliveryStatus = false;
     while (!common.DeliveryStatus);
     
     if (common.Response != null) {
         IList<object> fields = common.Response as IList<object>;
         
         if (fields [0] != null)
         {
             var myObjectArray = (from item in fields select item as object).ToArray ();
             Console.WriteLine ("Response:" + myObjectArray[0].ToString ());
             CustomClass cc = JsonConvert.DeserializeObject<CustomClass>(myObjectArray[0].ToString());
             if(cc.bar.SequenceEqual(message.bar) && cc.foo.Equals(message.foo))
             {
                 Assert.Pass("Complex message test successful");
             }
             else
             {
                 Assert.Fail("Complex message test not successful");
             }
         }
         else
         {
             Assert.Fail("No response");
         }
     }
     else
     {
         Assert.Fail("No response");
     }
 }
Ejemplo n.º 25
0
        public void ThenItShouldReturnReceivedMessage()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false
                );
            string channel = "hello_world2";
            Common common  = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnReceivedMessage");

            pubnub.Presence <string> (channel, common.DisplayReturnMessage, common.DisplayReturnMessage, common.DisplayErrorMessage);
            Thread.Sleep(1500);
            Common commonSubscribe = new Common();

            common.DeliveryStatus = false;
            common.Response       = null;

            pubnub.Subscribe <string> (channel, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayErrorMessage);

            commonSubscribe.DeliveryStatus = false;
            commonSubscribe.Response       = null;

            common.WaitForResponse(30);

            string response = "";

            if (common.Response == null)
            {
                Assert.Fail("Null response");
            }
            else
            {
                //IList<object> responseFields = common.Response as IList<object>;
                object[] serializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(common.Response.ToString()).ToArray();

                /*foreach (object item in responseFields) {
                 *  response = item.ToString ();
                 *  Console.WriteLine ("Response:" + response);
                 *  //Assert.IsNotEmpty(strResponse);
                 * }
                 * Assert.True (("hello_world").Equals (responseFields [2]));*/
                Assert.True(("hello_world2").Equals(serializedMessage [2]));
            }
            pubnub.EndPendingRequests();
        }
Ejemplo n.º 26
0
        public void ThenPresenceShouldReturnCustomUUID()
        {
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            Common commonHereNow = new Common();

            commonHereNow.DeliveryStatus = false;
            commonHereNow.Response       = null;

            Common commonSubscribe = new Common();

            commonSubscribe.DeliveryStatus = false;
            commonSubscribe.Response       = null;

            pubnub.PubnubUnitTest = commonHereNow.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnCustomUUID");;
            pubnub.SessionUUID    = "CustomSessionUUIDTest";

            string channel = "hello_world";

            pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessage);

            while (!commonSubscribe.DeliveryStatus)
            {
                ;
            }

            pubnub.HereNow <string>(channel, commonHereNow.DisplayReturnMessage);

            while (!commonHereNow.DeliveryStatus)
            {
                ;
            }
            if (commonHereNow.Response != null)
            {
                object[]   serializedMessage = JsonConvert.DeserializeObject <object[]>(commonHereNow.Response.ToString());
                JContainer dictionary        = serializedMessage[0] as JContainer;
                var        uuid = dictionary["uuids"].ToString();
                if (uuid != null)
                {
                    Assert.True(uuid.Contains(pubnub.SessionUUID));
                }
                else
                {
                    Assert.Fail("Custom uuid not found.");
                }
            }
            else
            {
                Assert.Fail("Null response");
            }
        }
Ejemplo n.º 27
0
       public void ThenItShouldReturnReceivedMessage () 
       {

          Pubnub pubnub = new Pubnub (
                "demo",
                "demo",
                "",
                "",
                false);
          string channel = "hello_world";

          Common common = new Common();
          common.DeliveryStatus = false;
          common.Response = null;

          pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenSubscribedToAChannel", "ThenSubscribeShouldReturnReceivedMessage");

          pubnub.Subscribe (channel, common.DisplayReturnMessage); 
          Thread.Sleep(3000);

          string message = "Test Message";

          pubnub.Publish (channel, message, common.DisplayReturnMessageDummy);

          //cm.deliveryStatus = false;
          while (!common.DeliveryStatus);
             if (common.Response != null) {
                IList<object> fields = common.Response as IList<object>;

                if (fields [0] != null)
                {
                    var myObjectArray = (from item in fields select item as object).ToArray ();
                    Console.WriteLine ("Response:" + myObjectArray[0].ToString ());
                    Assert.AreEqual(message, myObjectArray[0].ToString());
                }
                else
                {
                    Assert.Fail("No response");
                }
             }
            else
            {
              Assert.Fail("No response");
            }
       }
Ejemplo n.º 28
0
		public void TestForComplexMessageCipherSecret ()
        {
            Pubnub pubnub = new Pubnub (
                                Common.PublishKey,
                                Common.SubscribeKey,
                                Common.SecretKey,
                                "enigma",
                                false);
            string channel = "hello_world";

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenSubscribedToAChannel", "ThenItShouldReturnReceivedMessageForComplexMessage");

            SubscribePublishAndParseComplex (pubnub, common, channel);
        }
Ejemplo n.º 29
0
        public void ThenItShouldReturnReceivedMessage()
        {
            Pubnub pubnub = new Pubnub(
              "demo",
              "demo",
              "",
              "",
              false
              );
            string channel = "hello_world";
            Common commonPresence = new Common();
            commonPresence.DeliveryStatus = false;
            commonPresence.Response = null;
            
            pubnub.PubnubUnitTest = commonPresence.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnReceivedMessage");
            
            pubnub.Presence(channel, commonPresence.DisplayReturnMessage, commonPresence.DisplayReturnMessageDummy, commonPresence.DisplayReturnMessageDummy);
            
            Common commonSubscribe = new Common();
            commonSubscribe.DeliveryStatus = false;
            commonSubscribe.Response = null;
            
            pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayReturnMessageDummy, commonPresence.DisplayReturnMessageDummy);
            //while (!commonSubscribe.DeliveryStatus) ;
            
            commonPresence.WaitForResponse(30);
            
            string response = "";
            if (commonPresence.Response == null) {
              Assert.Fail("Null response");
            }
            else
            {
              IList<object> responseFields = commonPresence.Response as IList<object>;
              foreach (object item in responseFields)
              {
                response = item.ToString();
                Console.WriteLine("Response:" + response);
                //Assert.IsNotEmpty(strResponse);
              }
			  Assert.True (("hello_world").Equals(responseFields[2]));
            }
        }
Ejemplo n.º 30
0
        public void ThenItShouldReturnReceivedMessage ()
        {

            Pubnub pubnub = new Pubnub (
                                Common.PublishKey,
                                Common.SubscribeKey,
                                "",
                                "",
                                false);
            string channel = "hello_world";

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            string message = "Test Message";

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenSubscribedToAChannel", "ThenSubscribeShouldReturnReceivedMessage");

            SubscribePublishAndParse (message, pubnub, common, channel);
        }
		public void TestUnencryptedSecretDetailedHistoryParams()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"secretkey",
				"",
				false);
			
			string channel = "hello_world";
			
			int totalMessages = 10;
			
			Common common = new Common();
			common.DeliveryStatus = false;
			common.Response = null;        
			
			long starttime = common.Timestamp(pubnub);
			
			SendMultipleIntMessages(0, totalMessages/2, channel, pubnub);
			
			long midtime = common.Timestamp(pubnub);
			
			SendMultipleIntMessages(totalMessages/2, totalMessages, channel, pubnub);
			
			long endtime = common.Timestamp(pubnub);
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested" ,"TestUnencryptedSecretDetailedHistoryParams1");
			
			common.DeliveryStatus = false;
			common.Response = null;
			Console.WriteLine("DetailedHistory with start & end");
			
			pubnub.DetailedHistory(channel, starttime, midtime, totalMessages / 2, true, common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			
			Console.WriteLine("DetailedHistory with start & reverse = true");
			
			ParseResponse(common.Response, 0, totalMessages/2, "");
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested" ,"TestUnencryptedSecretDetailedHistoryParams2");
			
			common.DeliveryStatus = false;
			common.Response = null;
			pubnub.DetailedHistory(channel, midtime, -1, totalMessages / 2, true, common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			
			Console.WriteLine("DetailedHistory with start & reverse = false");
			
			ParseResponse(common.Response, totalMessages/2, totalMessages, "");
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested" ,"TestUnencryptedSecretDetailedHistoryParams3");
			
			common.DeliveryStatus = false;
			common.Response = null;
			pubnub.DetailedHistory(channel, midtime, -1, totalMessages / 2, false, common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			
			Console.WriteLine("\n******* DetailedHistory Messages Received ******* ");
			
			ParseResponse(common.Response, 0, totalMessages/2, "");
		}
		public void DetailedHistoryDecryptedExample()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"enigma",
				false);
			string channel = "hello_world";
			
			string message = "Test Message";
			
			Common common = new Common();
			common.DeliveryStatus = false;
			common.Response = null;
			
			pubnub.Publish(channel, message, common.DisplayReturnMessage);
			while (!common.DeliveryStatus) ;
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested", "DetailedHistoryDecryptedExample");
			
			common.DeliveryStatus = false;
			common.Response = null;
			
			pubnub.DetailedHistory(channel, 1, common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
			
			ParseResponse(common.Response, 0, 0, message);
		}
		public void TestEncryptedDetailedHistory()
		{
			Pubnub pubnub = new Pubnub(
				"demo",
				"demo",
				"",
				"enigma",
				false);
			string channel = "hello_world";
			
			int totalMessages = 10;
			
			Common common = new Common();
			common.DeliveryStatus = false;
			common.Response = null;
			
			long starttime = common.Timestamp(pubnub);
			
			SendMultipleIntMessages(0, totalMessages, channel, pubnub);
			
			long midtime = common.Timestamp(pubnub);
			
			SendMultipleIntMessages(totalMessages, totalMessages/2, channel, pubnub);
			
			long endtime = common.Timestamp(pubnub);
			while (!common.DeliveryStatus) ;
			
			pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested", "TestEncryptedDetailedHistory");
			
			common.Response = null;
			common.DeliveryStatus = false;
			
			pubnub.DetailedHistory(channel, totalMessages, common.DisplayReturnMessage);
			
			while (!common.DeliveryStatus) ;
			Console.WriteLine("\n*********** DetailedHistory Messages Received*********** ");
			
			ParseResponse(common.Response, 0, totalMessages, "");
		}
				//[Test]
                public void TestUnsubscribePresenceSSL()
                {
                    Pubnub pubnub = new Pubnub(
						Common.PublishKey,
						Common.SubscribeKey,                        
						"",
                        "",
                        true
                    );
                    string channel = "hello_world3";
                    Common common = new Common();
                    common.DeliveryStatus = false;
                    common.Response = null;

                    pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnReceivedMessage");

                    pubnub.Presence<string>(channel, common.DisplayReturnMessage, common.DisplayReturnMessage, common.DisplayErrorMessage);
					common.WaitForResponse();
                    Common commonSubscribe = new Common();
                    common.DeliveryStatus = false;
                    common.Response = null;

                    pubnub.Subscribe<string>(channel, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayErrorMessage);

                    commonSubscribe.DeliveryStatus = false;
                    commonSubscribe.Response = null;


                    common.WaitForResponse();

                    string response = "";
                    if (common.Response == null)
                    {
                        Assert.Fail("Null response");
                    } else
                    {
                        //IList<object> responseFields = common.Response as IList<object>;
                        object[] responseFields = Common.Deserialize<object[]>(common.Response.ToString());
                        if (channel.Equals(responseFields [2]))
                        {
                            Unsub(common, pubnub, channel);
                        }
                    }
                }
Ejemplo n.º 35
0
        public void ThenSubscribeShouldReturnConnectStatus ()
        {
            Pubnub pubnub = new Pubnub (Common.PublishKey,
                                Common.SubscribeKey,
                                "", "", false);

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenSubscribedToAChannel", "ThenSubscribeShouldReturnConnectStatus");

            string channel = "hello_world";

            pubnub.Subscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();         

            if (ParseResponse (common.Response)) {
                Assert.Pass ("Connected and status code received");
            } else {
                Assert.Fail ("Test failed");
            }
            pubnub.EndPendingRequests ();
        }
Ejemplo n.º 36
0
        public void ThenPresenceShouldReturnCustomUUID()
        {
          Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
          
          Common commonHereNow = new Common();
          commonHereNow.DeliveryStatus = false;
          commonHereNow.Response = null;

          Common commonSubscribe = new Common();
          commonSubscribe.DeliveryStatus = false;
          commonSubscribe.Response = null;

          pubnub.PubnubUnitTest = commonHereNow.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnCustomUUID");;
          pubnub.SessionUUID = "CustomSessionUUIDTest";
          
          string channel = "hello_world";

          pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayReturnMessage);
            
          //while (!commonSubscribe.DeliveryStatus);
          commonSubscribe.WaitForResponse();

          pubnub.HereNow<string>(channel, commonHereNow.DisplayReturnMessage, commonHereNow.DisplayReturnMessage);

          //while (!commonHereNow.DeliveryStatus);
          commonHereNow.WaitForResponse();
          if (commonHereNow.Response!= null)
          {
#if (USE_JSONFX)
              IList<object> fields = new JsonFXDotNet ().DeserializeToObject (commonHereNow.Response.ToString ()) as IList<object>;
              if (fields [0] != null)
              {
                  bool result = false;
                  Dictionary<string, object> message = (Dictionary<string, object>)fields [0];
                  foreach (KeyValuePair<String, object> entry in message)
                  {
                      Console.WriteLine("value:" + entry.Value + "  " + "key:" + entry.Key);
                      Type valueType = entry.Value.GetType();
                      var expectedType = typeof(string[]);
                      if (valueType.IsArray && expectedType.IsAssignableFrom(valueType))
                      {
                        List<string> uuids = new List<string>(entry.Value as string[]);
                        if(uuids.Contains(pubnub.SessionUUID )){
                            result= true;
                            break;
                        }
                      }
                  }
                  Assert.True(result);
              } 
              else
              {
                Assert.Fail("Null response");
              }
#else
              object[] serializedMessage = JsonConvert.DeserializeObject<object[]>(commonHereNow.Response.ToString());
              JContainer dictionary = serializedMessage[0] as JContainer;
              var uuid = dictionary["uuids"].ToString();
              if (uuid != null)
              {
                  Assert.True(uuid.Contains(pubnub.SessionUUID));
              } else {
                  Assert.Fail("Custom uuid not found.");
              }
#endif
          } else {
              Assert.Fail("Null response");
          }

        }
        public void TestEncryptedDetailedHistorySSL ()
        {
            Pubnub pubnub = new Pubnub (
                          Common.PublishKey,
                          Common.SubscribeKey,
                          "",
                          "enigma",
                          true);
            string channel = "hello_world_de15";

            int totalMessages = 10;

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            long starttime = common.Timestamp (pubnub);

            SendMultipleIntMessages (0, totalMessages, channel, pubnub);

            long midtime = common.Timestamp (pubnub);

            SendMultipleIntMessages (totalMessages, totalMessages / 2, channel, pubnub);

            long endtime = common.Timestamp (pubnub);
            common.WaitForResponse ();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "TestEncryptedDetailedHistory");

            common.Response = null;
            common.DeliveryStatus = false;
            Thread.Sleep (1000);
            pubnub.DetailedHistory (channel, totalMessages, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();
            Console.WriteLine ("\n*********** DetailedHistory Messages Received*********** ");

            ParseResponse (common.Response, 0, totalMessages, "");
            pubnub.EndPendingRequests ();
        }
        public void TestUnencryptedSecretDetailedHistoryParams ()
        {
            Pubnub pubnub = new Pubnub (
                          Common.PublishKey,
                          Common.SubscribeKey,
                          Common.SecretKey,
                          "",
                          false);

            string channel = "hello_world_de5";

            int totalMessages = 10;

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;        

            long starttime = common.Timestamp (pubnub);

            SendMultipleIntMessages (0, totalMessages / 2, channel, pubnub);

            long midtime = common.Timestamp (pubnub);

            SendMultipleIntMessages (totalMessages / 2, totalMessages, channel, pubnub);

            long endtime = common.Timestamp (pubnub);

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "TestUnencryptedSecretDetailedHistoryParams1");

            common.DeliveryStatus = false;
            common.Response = null;
            Console.WriteLine ("DetailedHistory with start & end");
            Thread.Sleep (1000);
            pubnub.DetailedHistory (channel, starttime, midtime, totalMessages / 2, true, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            Console.WriteLine ("DetailedHistory with start & reverse = true");

            ParseResponse (common.Response, 0, totalMessages / 2, "");

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "TestUnencryptedSecretDetailedHistoryParams2");

            common.DeliveryStatus = false;
            common.Response = null;
            Thread.Sleep (1000);
            pubnub.DetailedHistory (channel, midtime, -1, totalMessages / 2, true, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            Console.WriteLine ("DetailedHistory with start & reverse = false");

            ParseResponse (common.Response, totalMessages / 2, totalMessages, "");

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "TestUnencryptedSecretDetailedHistoryParams3");

            common.DeliveryStatus = false;
            common.Response = null;
            Thread.Sleep (1000);
            pubnub.DetailedHistory (channel, midtime, -1, totalMessages / 2, false, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            Console.WriteLine ("\n******* DetailedHistory Messages Received ******* ");

            ParseResponse (common.Response, 0, totalMessages / 2, "");
            pubnub.EndPendingRequests ();
        }
        public void DetailedHistoryDecryptedExample ()
        {
            Pubnub pubnub = new Pubnub (
                          Common.PublishKey,
                          Common.SubscribeKey,
                          "",
                          "enigma",
                          false);
            string channel = "hello_world_de3";

            string message = "Test Message";

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.Publish (channel, message, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse ();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "DetailedHistoryDecryptedExample");

            common.DeliveryStatus = false;
            common.Response = null;
            Thread.Sleep (1000);
            pubnub.DetailedHistory (channel, 1, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();
            Console.WriteLine ("\n*********** DetailedHistory Messages Received*********** ");

            ParseResponse (common.Response, 0, 0, message);
            pubnub.EndPendingRequests ();
        }
Ejemplo n.º 40
0
        public void ThenPresenceShouldReturnCustomUUID()
        {
          Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
          
          Common commonHereNow = new Common();
          commonHereNow.DeliveryStatus = false;
          commonHereNow.Response = null;

          Common commonSubscribe = new Common();
          commonSubscribe.DeliveryStatus = false;
          commonSubscribe.Response = null;

          pubnub.PubnubUnitTest = commonHereNow.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnCustomUUID");;
          pubnub.SessionUUID = "CustomSessionUUIDTest";
          
          string channel = "hello_world";

          pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessageDummy, commonSubscribe.DisplayReturnMessage);
            
          while (!commonSubscribe.DeliveryStatus);

          pubnub.HereNow<string>(channel, commonHereNow.DisplayReturnMessage);

          while (!commonHereNow.DeliveryStatus);
          if (commonHereNow.Response!= null)
          {
              object[] serializedMessage = JsonConvert.DeserializeObject<object[]>(commonHereNow.Response.ToString());
              JContainer dictionary = serializedMessage[0] as JContainer;
              var uuid = dictionary["uuids"].ToString();
              if (uuid != null)
              {
                  Assert.True(uuid.Contains(pubnub.SessionUUID));
              } else {
                  Assert.Fail("Custom uuid not found.");
              }
          } else {
              Assert.Fail("Null response");
          }
        }
Ejemplo n.º 41
0
 public void ThenLargeMessageShoudFailWithMessageTooLargeInfo(){
     Pubnub pubnub = new Pubnub(
         "demo",
         "demo",
         "",
         "",
         false
         );
     string channel = "hello_world";
     string messageLarge2K = "This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. ";
     
     Common common = new Common();
     
     pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenLargeMessageShoudFailWithMessageTooLargeInfo");
     
     common.DeliveryStatus = false;
     common.Response = null;
     
     pubnub.Publish(channel, messageLarge2K, common.DisplayReturnMessage);
     //wait till the response is received from the server
     while (!common.DeliveryStatus) ;
     IList<object> fields = common.Response as IList<object>;
     string sent = fields[1].ToString();
     Assert.AreEqual("Message Too Large", sent);
 }        
Ejemplo n.º 42
0
        public void ThenDuplicateChannelShouldReturnAlreadySubscribed ()
        {
            Pubnub pubnub = new Pubnub (Common.PublishKey,
                                Common.SubscribeKey,
                                "", "", false);

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenSubscribedToAChannel", "ThenDuplicateChannelShouldReturnAlreadySubscribed");

            string channel = "testChannel";

            pubnub.Subscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy);
            Thread.Sleep (100);

            pubnub.Subscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage);
            common.WaitForResponse ();  

            Console.WriteLine ("Response:" + common.Response);
            if (common.Response.ToString ().ToLower ().Contains ("already subscribed")) {
                Assert.Pass ("Test passed");
            } else {
                Assert.Fail ("Test failed");
            }
            pubnub.EndPendingRequests ();
        }
Ejemplo n.º 43
0
        //[Test]
        public void ThenMultiSubscribeShouldReturnConnectStatusSSL ()
        {
            Pubnub pubnub = new Pubnub (Common.PublishKey,
                                Common.SubscribeKey,
                                "", "", true);

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenSubscribedToAChannel", "ThenMultiSubscribeShouldReturnConnectStatus");

            string channel1 = "testChannel1";
            pubnub.Subscribe<string> (channel1, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            bool receivedChannel1ConnectMessage = ParseResponse (common.Response);
            common.DeliveryStatus = false;
            common.Response = null;

            string channel2 = "testChannel2";
            pubnub.Subscribe<string> (channel2, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse (); 

            bool receivedChannel2ConnectMessage = ParseResponse (common.Response);

            if (receivedChannel1ConnectMessage && receivedChannel2ConnectMessage) {
                Assert.Pass ("Connected and status code received");
            } else {
                Assert.Fail ("Test failed");
            }
        }