Example #1
0
        public void TestMyObjectDecryption()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                PubnubCrypto pc = new PubnubCrypto("enigma");
                //Deserialized
                string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
                //Decrypt
                string decryptedMessage = pc.Decrypt(message);
                //create an object of the custom class
                CustomClass cc = new CustomClass();

                //Serialize it
                string result = JsonConvert.SerializeObject(cc);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.AreEqual(result, decryptedMessage);
                    TestComplete();
                });
            });
        }
Example #2
0
        public void ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                isUnencryptObjectPublished = false;
                Pubnub pubnub  = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
                string channel = "hello_my_channel";
                object message = new CustomClass();
                messageObjectForUnencryptPublish = JsonConvert.SerializeObject(message);

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

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

                if (!isUnencryptObjectPublished)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        Assert.IsTrue(isUnencryptObjectPublished, "Unencrypt Publish Failed");
                        TestComplete();
                    });
                }
                else
                {
                    mreDetailedHistory = new ManualResetEvent(false);
                    pubnub.DetailedHistory <string>(channel, -1, unEncryptObjectPublishTimetoken, -1, false, CaptureUnencryptObjectDetailedHistoryCallback, DummyErrorCallback);
                    mreDetailedHistory.WaitOne(60 * 1000);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        Assert.IsTrue(isUnencryptObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
                        TestComplete();
                    });
                }
            });
        }