Exemplo n.º 1
0
        public void ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            isUnencryptObjectPublished = false;
            mrePublish         = new ManualResetEvent(false);
            mreDetailedHistory = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem((s) =>
            {
                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;

                EnqueueCallback(() => pubnub.Publish <string>(channel, message, ReturnSuccessUnencryptObjectPublishCodeCallback, DummyErrorCallback));
                mrePublish.WaitOne(310 * 1000);

                EnqueueCallback(() =>
                {
                    if (!isUnencryptObjectPublished)
                    {
                        Assert.IsTrue(isUnencryptObjectPublished, "Unencrypt Publish Failed");
                    }
                    else
                    {
                        pubnub.DetailedHistory <string>(channel, -1, unEncryptObjectPublishTimetoken, -1, false, CaptureUnencryptObjectDetailedHistoryCallback, DummyErrorCallback);
                        mreDetailedHistory.WaitOne(310 * 1000);
                        Assert.IsTrue(isUnencryptObjectDH, "Unable to match the successful unencrypt object Publish");
                    }
                });

                EnqueueTestComplete();
            });
        }
Exemplo n.º 2
0
        public void TestMyObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string dec = pc.decrypt(strMessage);
            //create an object of the custom class
            CustomClass cc = new CustomClass();

            JavaScriptSerializer js = new JavaScriptSerializer();
            //Serialize it
            string res = js.Serialize(cc);

            Assert.AreEqual(res, dec);
        }
Exemplo n.º 3
0
        public void TestMyObjectEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //serialize it
            JavaScriptSerializer js = new JavaScriptSerializer();
            string res = js.Serialize(cc);
            //encrypt it
            string enc = pc.encrypt(res);

            Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", enc);
        }