当前位置: 首页>>代码示例>>C#>>正文


C# Common.WaitForResponse方法代码示例

本文整理汇总了C#中PubNubMessaging.Tests.Common.WaitForResponse方法的典型用法代码示例。如果您正苦于以下问题:C# Common.WaitForResponse方法的具体用法?C# Common.WaitForResponse怎么用?C# Common.WaitForResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PubNubMessaging.Tests.Common的用法示例。


在下文中一共展示了Common.WaitForResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ItShouldReturnDetailedHistory

    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;

      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;
      pubnub.DetailedHistory(channel, 1, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
      common.WaitForResponse();

      ParseResponse(common.Response, 0, 0, message);
    }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:30,代码来源:WhenDetailedHistoryIsRequested.cs

示例2: ItShouldReturnDetailedHistoryNoStore

        public void ItShouldReturnDetailedHistoryNoStore ()
        {
            Pubnub pubnub = new Pubnub (
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false
            );
            string channel = "hello_world_de1";
            string message = "Test Message No Store";

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

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

            //publish a test message. 
            pubnub.Publish (channel, message, false, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            common.DeliveryStatus = false;
            common.Response = null;
            //Thread.Sleep (2000);
            pubnub.DetailedHistory<string> (channel, 1, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse ();

            ParseResponseNoStore (common.Response.ToString(), message);
            pubnub.EndPendingRequests ();
        }
开发者ID:seeva92,项目名称:c-sharp,代码行数:32,代码来源:WhenDetailedHistoryIsRequested.cs

示例3: SubscribePublishAndParse

        void SubscribePublishAndParse (string message, Pubnub pubnub, Common common, string channel)
        {
            Random r = new Random ();
            channel = "hello_world_sub" + r.Next (1000);

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

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

            common.WaitForResponse ();

            if (common.Response != null) {
                object[] deserializedMessage = Common.Deserialize<object[]> (common.Response.ToString ());
                if (deserializedMessage != null) {
                    Assert.True (message.Equals (deserializedMessage [0].ToString ()));
                } else {
                    Assert.Fail ("Test not successful");
                }
            } else {
                Assert.Fail ("No response");
            }
            common.DeliveryStatus = false;
            common.Response = null;

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

            common.WaitForResponse (20);

            pubnub.EndPendingRequests ();

        }
开发者ID:hakangs,项目名称:c-sharp,代码行数:32,代码来源:WhenSubscribedToAChannel2.cs

示例4: ThenShouldReturnUnsubscribedMessage

    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");
      }    
    }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:30,代码来源:WhenUnsubscribedToAChannel.cs

示例5: ThenItShouldReturnTimeStampSSL

        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 ();
        }
开发者ID:hakangs,项目名称:c-sharp,代码行数:29,代码来源:WhenGetRequestServerTime.cs

示例6: ThenNonExistentChannelShouldReturnNotSubscribed

        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 ();
            }
            pubnub.EndPendingRequests ();
        }
开发者ID:seeva92,项目名称:c-sharp,代码行数:25,代码来源:WhenUnsubscribedToAChannel.cs

示例7: ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2

 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");
         }
 }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:34,代码来源:WhenAMessageIsPublished.cs

示例8: NullMessage

        public void NullMessage()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                                "",
                                "",
                                false
                            );
            string channel = "hello_world";
            string message = null;

            Common common = new Common();
            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");
                }
        }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:31,代码来源:WhenAMessageIsPublished.cs

示例9: ThenItShouldReturnTimeStamp

        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, common.DisplayReturnMessageDummy);
           
            common.WaitForResponse();

            IList<object> fields = common.Response as IList<object>;
            response = fields[0].ToString();
            Console.WriteLine("Response:" + response);
			Assert.False(("0").Equals(response));
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:27,代码来源:WhenGetRequestServerTime.cs

示例10: SendMultipleIntMessages

        public void SendMultipleIntMessages (int messageStart, int messageEnd, string channel, Pubnub pubnub)
        {
            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;   

            for (int i = messageStart; i < messageEnd; i++) {
                common.DeliveryStatus = false;
                string msg = i.ToString ();
                pubnub.Publish (channel, msg, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

                common.WaitForResponse ();

                Console.WriteLine ("Message # " + i.ToString () + " published");
            }
        }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:16,代码来源:WhenDetailedHistoryIsRequested.cs

示例11: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            Pubnub pubnub = new Pubnub(
               "demo",
               "demo",
               "",
               "",
               false
           );
            Common common = new Common();
            common.DeliveryStatus = false;
            common.Response = null;
            
            HereNow(pubnub, "IfHereNowIsCalledThenItShouldReturnInfo", common.DisplayReturnMessage);
            common.WaitForResponse();

            ParseResponse(common.Response);
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:18,代码来源:WhenAClientIsPresented.cs

示例12: ThenItShouldReturnReceivedMessage

        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]));
            }
        }
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:43,代码来源:WhenAClientIsPresented.cs

示例13: SubscribePublishAndParse

        void SubscribePublishAndParse (string message, Pubnub pubnub, Common common, string channel)
        {
            pubnub.Subscribe<string> (channel, common.DisplayReturnMessage, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy); 
            Thread.Sleep (1500);

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

            common.WaitForResponse ();

            if (common.Response != null) {
                object[] deserializedMessage = Common.Deserialize<object[]> (common.Response.ToString ());
                if (deserializedMessage != null) {
                    Assert.True (message.Equals(deserializedMessage [0].ToString ()));
                } else {
                    Assert.Fail ("Test not successful");
                }
            } else {
                Assert.Fail ("No response");
            }
        }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:20,代码来源:WhenSubscribedToAChannel2.cs

示例14: ThenLargeMessageShoudFailWithMessageTooLargeInfo

 public void ThenLargeMessageShoudFailWithMessageTooLargeInfo()
 {
     Pubnub pubnub = new Pubnub(
         Common.PublishKey,
         Common.SubscribeKey,
                         "",
                         "",
                         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, 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();
             Assert.AreEqual("Message Too Large", sent);
         } else
         {
             Assert.Fail("Null response");
         }
 }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:32,代码来源:WhenAMessageIsPublished.cs

示例15: Unsub

                private void Unsub(Common common, Pubnub pubnub, string channel)
                {
                    Common commonUnsubscribe = new Common();

                    common.DeliveryStatus = false;
                    common.Response = null;
                    pubnub.Unsubscribe<string>(channel, commonUnsubscribe.DisplayReturnMessageDummy, commonUnsubscribe.DisplayReturnMessageDummy, commonUnsubscribe.DisplayReturnMessage, common.DisplayReturnMessageDummy);

                    common.WaitForResponse();
                    string response = "";
                    if (common.Response == null)
                    {
                        Assert.Fail("Null response");
                    } else
                    {
                        object[] responseFields2 = Common.Deserialize<object[]>(common.Response.ToString());
                        int count = 0;
                        foreach (object item in responseFields2)
                        {
                            count++;
                            response = item.ToString();
                            UnityEngine.Debug.Log("Response:" + response);
                            if (count == 0){
                                Assert.True(item.ToString().Contains("leave"));
                            }
                        }
                                //Assert.True(responseFields2 [0].ToString().Contains("leave"));
                    }
                }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:29,代码来源:WhenUnsubscribedToAChannel.cs


注:本文中的PubNubMessaging.Tests.Common.WaitForResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。