Пример #1
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                isEncryptObjectPublished = false;
                Pubnub pubnub            = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "enigma", false);
                string channel           = "hello_my_channel";

                object message = new SecretCustomClass();

                messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

                PubnubUnitTest unitTest = new PubnubUnitTest();
                unitTest.TestClassName  = "WhenAMessageIsPublished";
                unitTest.TestCaseName   = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";
                pubnub.PubnubUnitTest   = unitTest;

                mrePublish = new ManualResetEvent(false);
                pubnub.Publish <string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
                mrePublish.WaitOne(60 * 1000);

                if (!isEncryptObjectPublished)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
                        pubnub.PubnubUnitTest = null;
                        pubnub = null;
                        TestComplete();
                    });
                }
                else
                {
                    mreDetailedHistory = new ManualResetEvent(false);
                    pubnub.DetailedHistory <string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                    mreDetailedHistory.WaitOne(60 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
                        pubnub.PubnubUnitTest = null;
                        pubnub = null;
                        TestComplete();
                    });
                }
            });
        }
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
                {
                    isEncryptObjectPublished = false;
                    Pubnub pubnub = new Pubnub("demo", "demo", "", "enigma", false);
                    string channel = "my/channel";
                    
                    object message = new SecretCustomClass();

                    messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

                    PubnubUnitTest unitTest = new PubnubUnitTest();
                    unitTest.TestClassName = "WhenAMessageIsPublished";
                    unitTest.TestCaseName = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";
                    pubnub.PubnubUnitTest = unitTest;

                    pubnub.Publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback);
                    mreEncryptObjectPublish.WaitOne(310 * 1000);

                    if (!isEncryptObjectPublished)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
                           TestComplete();
                       });
                    }
                    else
                    {
                        pubnub.DetailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback);
                        mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                       {
                           Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
                           TestComplete();
                       });
                    }
                });
        }
Пример #3
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "enigma", false);
            string channel = "hello_my_channel";

            object message = new SecretCustomClass();

            messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest = unitTest;

            pubnub.Publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
            mreEncryptObjectPublish.WaitOne(310 * 1000);

            if (!isEncryptObjectPublished)
            {
                Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }