本文整理汇总了C#中PubNubMessaging.Tests.PubnubUnitTest类的典型用法代码示例。如果您正苦于以下问题:C# PubnubUnitTest类的具体用法?C# PubnubUnitTest怎么用?C# PubnubUnitTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PubnubUnitTest类属于PubNubMessaging.Tests命名空间,在下文中一共展示了PubnubUnitTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled) return;
currentUnitTestCase = "Init";
receivedGrantMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init3";
pubnub.PubnubUnitTest = unitTest;
grantManualEvent = new ManualResetEvent(false);
pubnub.ChannelGroupGrantAccess<string>(channelGroupName, true, true, 20, ThenChannelGroupInitializeShouldReturnGrantMessage, DummySubscribeErrorCallback);
Thread.Sleep(1000);
grantManualEvent.WaitOne(310*1000);
grantManualEvent = new ManualResetEvent(false);
pubnub.ChannelGroupGrantAccess<string>(channelGroupName1, true, true, 20, ThenChannelGroupInitializeShouldReturnGrantMessage, DummySubscribeErrorCallback);
Thread.Sleep(1000);
grantManualEvent.WaitOne(310 * 1000);
grantManualEvent = new ManualResetEvent(false);
pubnub.ChannelGroupGrantAccess<string>(channelGroupName2, true, true, 20, ThenChannelGroupInitializeShouldReturnGrantMessage, DummySubscribeErrorCallback);
Thread.Sleep(1000);
grantManualEvent.WaitOne(310 * 1000);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedGrantMessage, "WhenSubscribedToAChannelGroup Grant access failed.");
}
示例2: ThenSubKeyLevelShouldReturnSuccess
public void ThenSubKeyLevelShouldReturnSuccess()
{
Debug.Log("Running ThenSubKeyLevelShouldReturnSuccess()");
currentUnitTestCase = "ThenSubKeyLevelShouldReturnSuccess";
receivedAuditMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAuditIsRequested";
unitTest.TestCaseName = "ThenSubKeyLevelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
if (PubnubCommon.PAMEnabled)
{
pubnub.AuditAccess<string>(AccessToSubKeyLevelCallback, DummyErrorCallback);
Thread.Sleep(1000);
auditManualEvent.WaitOne();
UUnitAssert.True(receivedAuditMessage, "WhenAuditIsRequested -> ThenSubKeyLevelShouldReturnSuccess failed.");
}
else
{
UUnitAssert.False(true, "PAM Not Enabled for WhenAuditIsRequested -> ThenSubKeyLevelShouldReturnSuccess");
}
}
示例3: ThenPresenceShouldReturnReceivedMessage
public void ThenPresenceShouldReturnReceivedMessage()
{
Debug.Log("Running ThenPresenceShouldReturnReceivedMessage()");
receivedPresenceMessage = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage, PresenceDummyMethodForConnectCallback);
Thread.Sleep(1000);
//since presence expects from stimulus from sub/unsub...
pubnub.Subscribe<string>(channel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback);
Thread.Sleep(1000);
subscribeManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback);
Thread.Sleep(1000);
unsubscribeManualEvent.WaitOne(2000);
presenceManualEvent.WaitOne(310 * 1000);
pubnub.EndPendingRequests();
UUnitAssert.True(receivedPresenceMessage, "Presence message not received");
}
示例4: ThenPresenceShouldReturnCustomUUID
public void ThenPresenceShouldReturnCustomUUID()
{
receivedCustomUUID = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnCustomUUID";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.Presence<string>(channel, ThenPresenceWithCustomUUIDShouldReturnMessage, PresenceUUIDDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
//since presence expects from stimulus from sub/unsub...
pubnub.SessionUUID = customUUID;
pubnub.Subscribe<string>(channel, DummyMethodForSubscribeUUID, SubscribeUUIDDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
subscribeUUIDManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribeUUID, UnsubscribeUUIDDummyMethodForConnectCallback, UnsubscribeUUIDDummyMethodForDisconnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
unsubscribeUUIDManualEvent.WaitOne(2000);
presenceUUIDManualEvent.WaitOne(310 * 1000);
pubnub.EndPendingRequests();
Assert.IsTrue(receivedCustomUUID, "Custom UUID not received");
}
示例5: ThenSubscribeShouldReturnReceivedMessage
public void ThenSubscribeShouldReturnReceivedMessage()
{
receivedMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenSubscribedToAChannel";
unitTest.TestCaseName = "ThenSubscribeShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.Subscribe<string>(channel, ReceivedMessageCallbackWhenSubscribed, SubscribeDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
pubnub.Publish<string>(channel, "Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage", dummyPublishCallback, DummyErrorCallback);
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
mePublish.WaitOne(manualResetEventsWaitTimeout);
meSubscribeNoConnect.WaitOne(manualResetEventsWaitTimeout);
pubnub.Unsubscribe<string>(channel, dummyUnsubscribeCallback, SubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummyErrorCallback);
meUnsubscribe.WaitOne(manualResetEventsWaitTimeout);
pubnub.EndPendingRequests();
Assert.IsTrue(receivedMessage,"WhenSubscribedToAChannel --> ThenItShouldReturnReceivedMessage Failed");
}
示例6: ThenPublishMpnsToastShouldReturnSuccess
public void ThenPublishMpnsToastShouldReturnSuccess()
{
receivedSuccessMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
string channel = "hello_my_channel";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenPushIsRequested";
unitTest.TestCaseName = "ThenPublishMpnsToastShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
mrePublish = new ManualResetEvent(false);
MpnsToastNotification toast = new MpnsToastNotification();
toast.text1 = "hardcode message";
Dictionary<string, object> dicToast = new Dictionary<string, object>();
dicToast.Add("pn_mpns", toast);
pubnub.EnableDebugForPushPublish = true;
pubnub.Publish<string>(channel, dicToast, PublishCallbackResult, DummyErrorCallback);
mrePublish.WaitOne(60 * 1000, false);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(receivedSuccessMessage, "Toast Publish Failed");
}
示例7: ThenChannelLevelShouldReturnSuccess
public void ThenChannelLevelShouldReturnSuccess ()
{
currentUnitTestCase = "ThenChannelLevelShouldReturnSuccess";
receivedAuditMessage = false;
Pubnub pubnub = new Pubnub (PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest ();
unitTest.TestClassName = "WhenAuditIsRequested";
unitTest.TestCaseName = "ThenChannelLevelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
if (PubnubCommon.PAMEnabled) {
pubnub.AuditAccess<string> (channel, AccessToChannelLevelCallback, DummyErrorCallback);
Thread.Sleep (1000);
auditManualEvent.WaitOne ();
Assert.True (receivedAuditMessage, "WhenAuditIsRequested -> ThenChannelLevelShouldReturnSuccess failed.");
} else {
Assert.Ignore ("PAM Not Enabled for WhenAuditIsRequested -> ThenChannelLevelShouldReturnSuccess");
}
}
示例8: ThenAddChannelShouldReturnSuccess
public void ThenAddChannelShouldReturnSuccess()
{
currentUnitTestCase = "ThenAddChannelShouldReturnSuccess";
receivedChannelGroupMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenChannelGroupIsRequested";
unitTest.TestCaseName = "ThenAddChannelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
channelGroupManualEvent = new ManualResetEvent(false);
string channelName = "hello_my_channel";
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName }, channelGroupName, ChannelGroupCRUDCallback, DummyErrorCallback);
channelGroupManualEvent.WaitOne(10 * 1000, false);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(receivedChannelGroupMessage, "WhenChannelGroupIsRequested -> ThenAddChannelShouldReturnSuccess failed.");
}
示例9: ThenPresenceShouldReturnReceivedMessage
public void ThenPresenceShouldReturnReceivedMessage()
{
receivedPresenceMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage, PresenceDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
//since presence expects from stimulus from sub/unsub...
pubnub.Subscribe<string>(channel, DummyMethodForSubscribe, SubscribeDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe, UnsubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
presenceManualEvent.WaitOne(manualResetEventsWaitTimeout);
pubnub.EndPendingRequests();
Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
}
示例10: CreateUnitTestInstance
public PubnubUnitTest CreateUnitTestInstance(string testClassName, string testCaseName)
{
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = testClassName;
unitTest.TestCaseName = testCaseName;
return unitTest;
}
示例11: ThenUnencryptPublishShouldReturnSuccessCodeAndInfo
public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
{
Debug.Log("Running ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()");
isUnencryptPublished = false;
Pubnub pubnub = new Pubnub("demo","demo","","",false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAMessageIsPublished";
unitTest.TestCaseName = "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
string message = messageForUnencryptPublish;
pubnub.Publish<string>(channel, message, ReturnSuccessUnencryptPublishCodeCallback);
mreUnencryptedPublish.WaitOne(310*1000);
if (!isUnencryptPublished)
{
UUnitAssert.True(isUnencryptPublished, "Unencrypt Publish Failed");
}
else
{
pubnub.DetailedHistory<string>(channel, -1, unEncryptPublishTimetoken, -1, false, CaptureUnencryptDetailedHistoryCallback);
mreUnencryptDetailedHistory.WaitOne(310 * 1000);
UUnitAssert.True(isUnencryptDetailedHistory, "Unable to match the successful unencrypt Publish");
}
}
示例12: ThenPresenceShouldReturnReceivedMessage
public void ThenPresenceShouldReturnReceivedMessage()
{
receivedPresenceMessage = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage);
//since presence expects from stimulus from sub/unsub...
pubnub.Subscribe<string>(channel, DummyMethodForSubscribe);
subscribeManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe);
unsubscribeManualEvent.WaitOne(2000);
presenceManualEvent.WaitOne(310 * 1000);
pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSub);
presenceUnsubscribeEvent.WaitOne();
Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
}
示例13: ThenPresenceShouldReturnCustomUUID
public void ThenPresenceShouldReturnCustomUUID()
{
receivedCustomUUID = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnCustomUUID";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
pubnub.Presence<string>(channel, ThenPresenceWithCustomUUIDShouldReturnMessage);
//since presence expects from stimulus from sub/unsub...
pubnub.SessionUUID = customUUID;
pubnub.Subscribe<string>(channel, DummyMethodForSubscribeUUID);
subscribeUUIDManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribeUUID);
unsubscribeUUIDManualEvent.WaitOne(2000);
presenceUUIDManualEvent.WaitOne(310 * 1000);
pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSubUUID);
presenceUnsubscribeUUIDEvent.WaitOne();
Assert.IsTrue(receivedCustomUUID, "Custom UUID not received");
}
示例14: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled) return;
receivedGrantMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.GrantAccess<string>(channel, true, true, 20, ThenUnsubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback);
Thread.Sleep(1000);
grantManualEvent.WaitOne();
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedGrantMessage, "WhenUnsubscribedToAChannel Grant access failed.");
}
示例15: ThenSubKeyLevelShouldReturnSuccess
public void ThenSubKeyLevelShouldReturnSuccess()
{
currentUnitTestCase = "ThenSubKeyLevelShouldReturnSuccess";
receivedAuditMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAuditIsRequested";
unitTest.TestCaseName = "ThenSubKeyLevelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
if (PubnubCommon.PAMEnabled)
{
auditManualEvent = new ManualResetEvent(false);
pubnub.AuditAccess<string>(AccessToSubKeyLevelCallback, DummyErrorCallback);
Thread.Sleep(1000);
auditManualEvent.WaitOne();
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedAuditMessage, "WhenAuditIsRequested -> ThenSubKeyLevelShouldReturnSuccess failed.");
}
else
{
Assert.Ignore("PAM Not Enabled for WhenAuditIsRequested -> ThenSubKeyLevelShouldReturnSuccess");
}
}