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


C# Tests.PubnubUnitTest类代码示例

本文整理汇总了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.");
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:34,代码来源:WhenSubscribedToAChannelGroup.cs

示例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");
            }

        }
开发者ID:TharinduMunasinge,项目名称:c-sharp,代码行数:28,代码来源:WhenAuditIsRequested.cs

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

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

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

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

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

示例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.");

        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:26,代码来源:WhenChannelGroupIsRequested.cs

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

示例10: CreateUnitTestInstance

 public PubnubUnitTest CreateUnitTestInstance(string testClassName, string testCaseName)
 {
   PubnubUnitTest unitTest = new PubnubUnitTest();
   unitTest.TestClassName = testClassName;
   unitTest.TestCaseName = testCaseName;
   return unitTest;
 }
开发者ID:Vlanta,项目名称:c-sharp,代码行数:7,代码来源:Common.cs

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

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

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

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

示例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");
            }

        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:31,代码来源:WhenAuditIsRequested.cs


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