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));
		}
 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);
 }
Exemple #3
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");
            }
        }
 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");
         }
 }
 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);
 }
Exemple #6
0
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
            isComplexObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "my/channel";
            object message = new PubnubDemoObject();

            messageComplexObjectForPublish = JsonConvert.SerializeObject(message);

            pubnub.Publish <string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback);
            mreComplexObjectPublish.WaitOne(310 * 1000);

            if (!isComplexObjectPublished)
            {
                Assert.IsTrue(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback);
                mreComplexObjectDetailedHistory.WaitOne(310 * 1000);
                Assert.IsTrue(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
        }
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
            isComplexObjectPublished = false;
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";
            object message = new PubnubDemoObject();

            messageComplexObjectForPublish = pubnub.JsonPluggableLibrary.SerializeToJsonString(message);

            pubnub.Publish <string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback, DummyErrorCallback);
            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
            mreComplexObjectPublish.WaitOne(manualResetEventsWaitTimeout);

            if (!isComplexObjectPublished)
            {
                Assert.IsTrue(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                Console.WriteLine("WhenAMessageIsPublished-ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo - Publish OK. Now checking detailed history");
                pubnub.DetailedHistory <string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback, DummyErrorCallback);
                mreComplexObjectDetailedHistory.WaitOne(manualResetEventsWaitTimeout);
                Assert.IsTrue(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
        }
Exemple #8
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));
        }
        public IEnumerator Start()
        {
            CommonIntergrationTests common = new CommonIntergrationTests ();

            object message = new PubnubDemoObject ();

            yield return StartCoroutine(common.DoPublishAndParse(SslOn, this.name, message, "Sent", AsObject, WithCipher));
            UnityEngine.Debug.Log (string.Format("{0}: After StartCoroutine", this.name));
            yield return new WaitForSeconds (CommonIntergrationTests.WaitTimeBetweenCalls);
        }
        public IEnumerator Start()
        {
            CommonIntergrationTests common = new CommonIntergrationTests();

            object message = new PubnubDemoObject();

            yield return(StartCoroutine(common.DoPublishAndParse(SslOn, this.name, message, "Sent", AsObject, WithCipher)));

            UnityEngine.Debug.Log(string.Format("{0}: After StartCoroutine", this.name));
            yield return(new WaitForSeconds(CommonIntergrationTests.WaitTimeBetweenCalls));
        }
        //[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);
        }
 public IEnumerator Start()
 {
     if (CommonIntergrationTests.TestingUsingMiniJSON) {
         UnityEngine.Debug.Log (string.Format ("{0}: Ignored for MiniJSON", this.name));
         IntegrationTest.Pass ();
     } else {
         object Message = new PubnubDemoObject ();
         CommonIntergrationTests common = new CommonIntergrationTests ();
         yield return StartCoroutine (common.DoSubscribeThenPublishAndParse (SslOn, this.name, AsObject, CipherOn, Message, "\"VersionID\":3.4", true));
         UnityEngine.Debug.Log (string.Format ("{0}: After StartCoroutine", this.name));
         yield return new WaitForSeconds (CommonIntergrationTests.WaitTimeBetweenCalls);
     }
 }
        //[Test]
        public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false
                );
            string channel = "hello_world";
            object message = new PubnubDemoObject();
            //object message = new CustomClass2();

            string json   = Common.Serialize(message);
            Common common = new Common();

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2");
            DeliveryStatus        = false;
            pubnub.Publish <string> (channel, message, DisplayReturnMessage, DisplayErrorMessage);
            //wait till the response is received from the server
            common.WaitForResponse();
            //while (!DeliveryStatus)
            //;
            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");
            }

            /*if (Response != null) {
             #if(!UNITY_ANDROID)
             *              IList<object> fields = Response as IList<object>;
             #else
             *              UnityEngine.Debug.Log ("cm2: " + Response.ToString ());
             *              IList<object> fields = Response as IList<object>;
             #endif
             *              string sent = fields [1].ToString ();
             *              string one = fields [0].ToString ();
             *              Assert.AreEqual ("Sent", sent);
             *              Assert.AreEqual ("1", one);
             * } else {
             *              Assert.Fail ("Null response");
             * }*/
        }
				//[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);
				}
        public IEnumerator Start()
        {
            if (CommonIntergrationTests.TestingUsingMiniJSON)
            {
                UnityEngine.Debug.Log(string.Format("{0}: Ignored for MiniJSON", this.name));
                IntegrationTest.Pass();
            }
            else
            {
                object Message = new PubnubDemoObject();
                CommonIntergrationTests common = new CommonIntergrationTests();
                yield return(StartCoroutine(common.DoSubscribeThenPublishAndParse(SslOn, this.name, AsObject, CipherOn, Message, "\"VersionID\":3.4", true)));

                UnityEngine.Debug.Log(string.Format("{0}: After StartCoroutine", this.name));
                yield return(new WaitForSeconds(CommonIntergrationTests.WaitTimeBetweenCalls));
            }
        }
Exemple #16
0
        public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                true
                );
            string channel = "hello_world";
            object message = new PubnubDemoObject();
            //object message = new CustomClass2();

            string json   = Common.Serialize(message);
            Common common = new Common();

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

            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(45);
            if (common.Response != null)
            {
                Console.WriteLine(" common.Response" + common.Response);
                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");
            }
            pubnub.EndPendingRequests();
        }
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
            Debug.Log("Running ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()");
            isComplexObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            if (pubnub.PubnubUnitTest != null)
            {
                Debug.Log("** ATTENTION ** : TEST CASE = \"ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo\" cannot run with local unit test stubs. You can run this test case with pubnub.PubnubUnitTest = null  ");
                return;
            }

            string channel = "hello_my_channel";
            object message = new PubnubDemoObject();

            messageComplexObjectForPublish = new JsonFXDotNet().SerializeToJsonString(message);
            Debug.Log("messageComplexObjectForPublish = " + messageComplexObjectForPublish);
            pubnub.Publish <string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback, DummyErrorCallback);
            mreComplexObjectPublish.WaitOne(310 * 1000);
            Thread.Sleep(1000);

            if (!isComplexObjectPublished)
            {
                UUnitAssert.True(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback, DummyErrorCallback);
                mreComplexObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
        }
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
			Debug.Log("Running ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()");
            isComplexObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
			
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest = unitTest;
			
			if (pubnub.PubnubUnitTest != null)
			{
				Debug.Log("** ATTENTION ** : TEST CASE = \"ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo\" cannot run with local unit test stubs. You can run this test case with pubnub.PubnubUnitTest = null  ");
				return;
			}

            string channel = "hello_my_channel";
            object message = new PubnubDemoObject();
			messageComplexObjectForPublish = new JsonFXDotNet().SerializeToJsonString(message);
			Debug.Log("messageComplexObjectForPublish = " + messageComplexObjectForPublish);
            pubnub.Publish<string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback, DummyErrorCallback);
            mreComplexObjectPublish.WaitOne(310 * 1000);
			Thread.Sleep(1000);

            if (!isComplexObjectPublished)
            {
                UUnitAssert.True(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory<string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback, DummyErrorCallback);
                mreComplexObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
        }
 public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl ()
 {
     Pubnub pubnub = new Pubnub (
         Common.PublishKey,
         Common.SubscribeKey,
                       "",
                       "",
                       true
                   );
     string channel = "hello_world";
     object message = new PubnubDemoObject ();
     //object message = new CustomClass2();
   
     string json = Common.Serialize (message);
     Common common = new Common ();
   
     pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl");
   
     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 (45);
     if (common.Response != null) {
         Console.WriteLine (" common.Response"+common.Response);
         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");
     }
 }
				//[Test]
				public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2 ()
				{
						Pubnub pubnub = new Pubnub (
								Common.PublishKey,
								Common.SubscribeKey,
								                "",
								                "",
								                false
						                );
						string channel = "hello_world";
						object message = new PubnubDemoObject ();
						//object message = new CustomClass2();

						string json = Common.Serialize (message);
						Common common = new Common ();

						pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2");
						DeliveryStatus = false;
						pubnub.Publish<string> (channel, message, DisplayReturnMessage, DisplayErrorMessage);
						//wait till the response is received from the server
						common.WaitForResponse ();
						//while (!DeliveryStatus)
						//; 
						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");
						}
						/*if (Response != null) {
								#if(!UNITY_ANDROID)
								IList<object> fields = Response as IList<object>;
								#else
								UnityEngine.Debug.Log ("cm2: " + Response.ToString ());
								IList<object> fields = Response as IList<object>;
								#endif
								string sent = fields [1].ToString ();
								string one = fields [0].ToString ();
								Assert.AreEqual ("Sent", sent);
								Assert.AreEqual ("1", one);
						} else {
								Assert.Fail ("Null response");
						}*/

				}
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
			Debug.Log("Running ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()");
            isComplexObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest = unitTest;

            string channel = "my/channel";
            object message = new PubnubDemoObject();
			messageComplexObjectForPublish = JsonConvert.SerializeObject(message);
			Debug.Log("Serialized message in ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo() = " + messageComplexObjectForPublish);

            pubnub.Publish<string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback);
            mreComplexObjectPublish.WaitOne(310 * 1000);

            if (!isComplexObjectPublished)
            {
                UUnitAssert.True(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory<string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback);
                mreComplexObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
        }
Exemple #22
0
        public static void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
            server.ClearRequests();

            bool receivedPublishMessage = false;
            long publishTimetoken       = 0;

            string channel = "hello_my_channel";
            object message = new PubnubDemoObject();

            PNConfiguration config = new PNConfiguration
            {
                PublishKey   = PubnubCommon.PublishKey,
                SubscribeKey = PubnubCommon.SubscribeKey,
                Uuid         = "mytestuuid4",
                Secure       = false
            };

            server.RunOnHttps(false);

            pubnub = createPubNubInstance(config);

            string expected = "[1, \"Sent\", \"14715459088445832\"]";

            server.AddRequest(new Request()
                              .WithMethod("GET")
                              .WithPath(String.Format("/publish/{0}/{1}/0/{2}/0/%7B%22VersionID%22:3.4%2C%22Timetoken%22:%2213601488652764619%22%2C%22OperationName%22:%22Publish%22%2C%22Channels%22:%5B%22ch1%22%5D%2C%22DemoMessage%22:%7B%22DefaultMessage%22:%22~!%40%23%24%25%5E%26*()_%2B%20%601234567890-%3D%20qwertyuiop%5B%5D%5C%5C%20%7B%7D%7C%20asdfghjkl%3B'%20:%5C%22%20zxcvbnm%2C.%2F%20%3C%3E%3F%20%22%7D%2C%22CustomMessage%22:%7B%22DefaultMessage%22:%22Welcome%20to%20the%20world%20of%20Pubnub%20for%20Publish%20and%20Subscribe.%20Hah!%22%7D%2C%22SampleXml%22:%5B%7B%22ID%22:%22ABCD123%22%2C%22Name%22:%7B%22First%22:%22John%22%2C%22Middle%22:%22P.%22%2C%22Last%22:%22Doe%22%7D%2C%22Address%22:%7B%22Street%22:%22123%20Duck%20Street%22%2C%22City%22:%22New%20City%22%2C%22State%22:%22New%20York%22%2C%22Country%22:%22United%20States%22%7D%7D%2C%7B%22ID%22:%22ABCD456%22%2C%22Name%22:%7B%22First%22:%22Peter%22%2C%22Middle%22:%22Z.%22%2C%22Last%22:%22Smith%22%7D%2C%22Address%22:%7B%22Street%22:%2212%20Hollow%20Street%22%2C%22City%22:%22Philadelphia%22%2C%22State%22:%22Pennsylvania%22%2C%22Country%22:%22United%20States%22%7D%7D%5D%7D", PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, channel))
                              .WithParameter("pnsdk", PubnubCommon.EncodedSDK)
                              .WithParameter("requestid", "myRequestId")
                              .WithParameter("uuid", config.Uuid)
                              .WithResponse(expected)
                              .WithStatusCode(System.Net.HttpStatusCode.OK));

            manualResetEventWaitTimeout = 310 * 1000;

            ManualResetEvent publishManualEvent = new ManualResetEvent(false);

            pubnub.Publish().Channel(channel).Message(message)
            .Async(new PNPublishResultExt((r, s) =>
            {
                if (r != null && s.StatusCode == 200 && !s.Error)
                {
                    publishTimetoken       = r.Timetoken;
                    receivedPublishMessage = true;
                }
                publishManualEvent.Set();
            }));
            publishManualEvent.WaitOne(manualResetEventWaitTimeout);

            if (!receivedPublishMessage)
            {
                Assert.IsTrue(receivedPublishMessage, "Complex Object Publish Failed");
            }
            else
            {
                receivedPublishMessage = false;

                if (!PubnubCommon.EnableStubTest)
                {
                    Thread.Sleep(1000);
                }

                expected = Resource.ComplexMessage;

                server.AddRequest(new Request()
                                  .WithMethod("GET")
                                  .WithPath(String.Format("/v2/history/sub-key/{0}/channel/{1}", PubnubCommon.SubscribeKey, channel))
                                  .WithParameter("count", "100")
                                  .WithParameter("end", "14715459088445832")
                                  .WithParameter("include_token", "true")
                                  .WithParameter("pnsdk", PubnubCommon.EncodedSDK)
                                  .WithParameter("requestid", "myRequestId")
                                  .WithParameter("uuid", config.Uuid)
                                  .WithResponse(expected)
                                  .WithStatusCode(System.Net.HttpStatusCode.OK));

                Console.WriteLine("WhenAMessageIsPublished-ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo - Publish OK. Now checking detailed history");

                ManualResetEvent historyManualEvent = new ManualResetEvent(false);

                pubnub.History().Channel(channel)
                .End(PubnubCommon.EnableStubTest ? 14715459088445832 : publishTimetoken)
                .Reverse(false)
                .IncludeTimetoken(true)
                .Async(new PNHistoryResultExt(
                           (r, s) =>
                {
                    Console.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
                    receivedPublishMessage = true;
                    historyManualEvent.Set();
                }));

                historyManualEvent.WaitOne(manualResetEventWaitTimeout);

                Assert.IsTrue(receivedPublishMessage, "Unable to match the successful unencrypt object Publish");
            }
            pubnub.Destroy();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
        }
        public void ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
        {
            isComplexObjectPublished = false;
            pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest = unitTest;

            string channel = "hello_my_channel";
            object message = new PubnubDemoObject();
            messageComplexObjectForPublish = pubnub.JsonPluggableLibrary.SerializeToJsonString(message);

            pubnub.Publish<string>(channel, message, ReturnSuccessComplexObjectPublishCodeCallback, DummyErrorCallback);
            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 310 * 1000 : 310 * 1000;
            mreComplexObjectPublish.WaitOne(manualResetEventsWaitTimeout);

            Thread.Sleep (1000);
            if (!isComplexObjectPublished)
            {
                Assert.IsTrue(isComplexObjectPublished, "Complex Object Publish Failed");
            }
            else
            {
                Console.WriteLine("WhenAMessageIsPublished-ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo - Publish OK. Now checking detailed history");
                pubnub.DetailedHistory<string>(channel, -1, complexObjectPublishTimetoken, -1, false, CaptureComplexObjectDetailedHistoryCallback, DummyErrorCallback);
                mreComplexObjectDetailedHistory.WaitOne(manualResetEventsWaitTimeout);

                Assert.IsTrue(isComplexObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
            }
            pubnub.EndPendingRequests();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
        }