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); }
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); }
public void ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo() { isUnencryptObjectPublished = false; Pubnub pubnub = new Pubnub("demo", "demo", "", "", false); string channel = "my/channel"; object message = new CustomClass(); messageObjectForUnencryptPublish = JsonConvert.SerializeObject(message); EnqueueCallback(() => pubnub.publish<string>(channel, message, ReturnSuccessUnencryptObjectPublishCodeCallback)); EnqueueConditional(() => isUnencryptObjectPubCheck); EnqueueCallback(() => { if (!isUnencryptObjectPublished) { Assert.IsTrue(isUnencryptObjectPublished, "Unencrypt Publish Failed"); } else { EnqueueCallback(() => pubnub.detailedHistory<string>(channel, -1, unEncryptObjectPublishTimetoken, -1, false, CaptureUnencryptObjectDetailedHistoryCallback)); EnqueueConditional(() => isUnencryptObjectDHCheck); EnqueueCallback(() => Assert.IsTrue(isUnencryptObjectDH, "Unable to match the successful unencrypt object Publish")); } }); EnqueueTestComplete(); }