本文整理汇总了C#中PubNubMessaging.Tests.Common类的典型用法代码示例。如果您正苦于以下问题:C# Common类的具体用法?C# Common怎么用?C# Common使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Common类属于PubNubMessaging.Tests命名空间,在下文中一共展示了Common类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例2: 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);
}
示例3: 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 ();
}
示例4: 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");
}
}
示例5: 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");
}
}
示例6: 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 ();
}
示例7: 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));
}
示例8: 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);
}
示例9: 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 ();
}
示例10: 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");
}
}
示例11: 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);
}
示例12: NullMessage
public void NullMessage()
{
Pubnub pubnub = new Pubnub(
"demo",
"demo",
"",
"",
false
);
string channel = "hello_world";
string message = null;
Common common = new Common();
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);
}
示例13: 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();
}
}
示例14: 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);
}
示例15: 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");
}
}