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


C# Common.CreateUnitTestInstance方法代码示例

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


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

示例1: Test0ForComplexMessage2

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

示例2: ThenItShouldReturnSuccessCodeAndInfo

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

示例3: ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl

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

示例4: 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();
                }
        }
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:26,代码来源:WhenUnsubscribedToAChannel.cs

示例5: ItShouldReturnDetailedHistory

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

示例6: 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;
			
			//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);
		}
开发者ID:primohit,项目名称:pubnub-api,代码行数:30,代码来源:WhenDetailedHistoryIsRequested.cs

示例7: 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

示例8: 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

示例9: ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2

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

示例10: ThenShouldReturnUnsubscribedMessageSSL

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

示例11: 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);
			
			while (!common.DeliveryStatus) ;
			
			IList<object> fields = common.Response as IList<object>;
			response = fields[0].ToString();
			Console.WriteLine("Response:" + response);
			Assert.AreNotEqual("0",response);
		}
开发者ID:Vlanta,项目名称:c-sharp,代码行数:27,代码来源:WhenGetRequestServerTime.cs

示例12: 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

示例13: ThenItShouldReturnReceivedMessageForComplexMessage

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

示例14: ThenItShouldReturnReceivedMessage

       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");
            }
       }
开发者ID:primohit,项目名称:pubnub-api,代码行数:45,代码来源:WhenSubscribedToAChannel.cs

示例15: TestForComplexMessageCipherSecret

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


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