Skip to content
Browse files

multi-message subscribe fix and unit tests

  • Loading branch information...
1 parent 3280fd3 commit 448d3100c77c38841759b8d5ea5375b2dcd23669 @budgetpreneur budgetpreneur committed Feb 8, 2013
View
1,059 csharp/3.4/PubNub-Messaging.Tests/EncryptionTests.cs
@@ -1,513 +1,546 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using NUnit.Framework;
-using System.ComponentModel;
-using System.Threading;
-using System.Collections;
-using PubNubMessaging.Core;
-using System.Text.RegularExpressions;
-using System.Globalization;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-
-
-namespace PubNubMessaging.Tests
-{
- /// <summary>
- /// Custom class for testing the encryption and decryption
- /// </summary>
- class CustomClass
- {
- public string foo = "hi!";
- public int[] bar = { 1, 2, 3, 4, 5 };
- }
- class SecretCustomClass
- {
- public string foo = "hello!";
- public int[] bar = { 10, 20, 30, 40, 50 };
- }
-
- [TestFixture]
- public class EncryptionTests
- {
- /// <summary>
- /// Tests the null encryption.
- /// The input is serialized
- /// </summary>
- [Test]
- [ExpectedException(typeof(ArgumentNullException))]
- public void TestNullEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //serialized string
- string message = null;
-
- //encrypt
- string encryptedMessage = pc.Encrypt(message);
- }
-
- /// <summary>
- /// Tests the null decryption.
- /// Assumes that the input message is deserialized
- /// </summary>
- [Test]
- [ExpectedException(typeof(ArgumentNullException))]
- public void TestNullDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //deserialized string
- string message = null;
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
-
- Assert.AreEqual("", decryptedMessage);
- }
-
- /// <summary>
- /// Tests the yay decryption.
- /// Assumes that the input message is deserialized
- /// Decrypted string should match yay!
- /// </summary>
- [Test]
- public void TestYayDecryptionBasic()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string message = "q/xJqqN6qbiZMXYmiQC1Fw==";
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
- //deserialize again
- Assert.AreEqual("yay!", decryptedMessage);
- }
-
- /// <summary>
- /// Tests the yay encryption.
- /// The output is not serialized
- /// Encrypted string should match q/xJqqN6qbiZMXYmiQC1Fw==
- /// </summary>
- [Test]
- public void TestYayEncryptionBasic()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //deserialized string
- string message = "yay!";
- //Encrypt
- string encryptedMessage = pc.Encrypt(message);
- Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the yay decryption.
- /// Assumes that the input message is not deserialized
- /// Decrypted and Deserialized string should match yay!
- /// </summary>
- [Test]
- public void TestYayDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
- //Non deserialized string
- string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";
- //Deserialize
- message = JsonConvert.DeserializeObject<string>(message);
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
- //deserialize again
- message = JsonConvert.DeserializeObject<string>(decryptedMessage);
- Assert.AreEqual("yay!", message);
- }
- /// <summary>
- /// Tests the yay encryption.
- /// The output is not serialized
- /// Encrypted string should match Wi24KS4pcTzvyuGOHubiXg==
- /// </summary>
- [Test]
- public void TestYayEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //deserialized string
- string message = "yay!";
- //serialize the string
- message = JsonConvert.SerializeObject(message);
- Console.WriteLine(message);
- //Encrypt
- string enc = pc.Encrypt(message);
- Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", enc);
- }
-
- /// <summary>
- /// Tests the array encryption.
- /// The output is not serialized
- /// Encrypted string should match the serialized object
- /// </summary>
- [Test]
- public void TestArrayEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //create an empty array object
- object[] emptyArray = { };
- //serialize
- string serializedArray = JsonConvert.SerializeObject(emptyArray);
- //Encrypt
- string encryptedMessage = pc.Encrypt(serializedArray);
-
- Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the array decryption.
- /// Assumes that the input message is deserialized
- /// And the output message has to been deserialized.
- /// Decrypted string should match the serialized object
- /// </summary>
- [Test]
- public void TestArrayDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //Input the deserialized string
- string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
- //create a serialized object
- object[] emptyArrayObject = { };
- string result = JsonConvert.SerializeObject(emptyArrayObject);
- //compare the serialized object and the return of the Decrypt method
- Assert.AreEqual(result, decryptedMessage);
- }
-
- /// <summary>
- /// Tests the object encryption.
- /// The output is not serialized
- /// Encrypted string should match the serialized object
- /// </summary>
- [Test]
- public void TestObjectEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //create an object
- Object obj = new Object();
- //serialize
- string serializedObject = JsonConvert.SerializeObject(obj);
- //encrypt
- string encryptedMessage = pc.Encrypt(serializedObject);
-
- Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", encryptedMessage);
- }
- /// <summary>
- /// Tests the object decryption.
- /// Assumes that the input message is deserialized
- /// And the output message has to be deserialized.
- /// Decrypted string should match the serialized object
- /// </summary>
- [Test]
- public void TestObjectDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //Deserialized
- string message = "IDjZE9BHSjcX67RddfCYYg==";
- //Decrypt
- string decryptedMessage = pc.Decrypt(message);
- //create an object
- Object obj = new Object();
- //Serialize the object
- string result = JsonConvert.SerializeObject(obj);
-
- Assert.AreEqual(result, decryptedMessage);
- }
- /// <summary>
- /// Tests my object encryption.
- /// The output is not serialized
- /// Encrypted string should match the serialized object
- /// </summary>
- [Test]
- public void TestMyObjectEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //create an object of the custom class
- CustomClass cc = new CustomClass();
- //serialize it
- string result = JsonConvert.SerializeObject(cc);
- //encrypt it
- string encryptedMessage = pc.Encrypt(result);
-
- Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encryptedMessage);
- }
- /// <summary>
- /// Tests my object decryption.
- /// The output is not deserialized
- /// Decrypted string should match the serialized object
- /// </summary>
- [Test]
- public void TestMyObjectDecryption()
- {
- 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);
-
- Assert.AreEqual(result, decryptedMessage);
- }
-
- /// <summary>
- /// Tests the pub nub encryption2.
- /// The output is not serialized
- /// Encrypted string should match f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=
- /// </summary>
- [Test]
- public void TestPubNubEncryption2()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //Deserialized
- string message = "Pubnub Messaging API 2";
- //serialize the message
- message = JsonConvert.SerializeObject(message);
- //encrypt
- string encryptedMessage = pc.Encrypt(message);
-
- Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the pub nub decryption2.
- /// Assumes that the input message is deserialized
- /// Decrypted and Deserialized string should match Pubnub Messaging API 2
- /// </summary>
- [Test]
- public void TestPubNubDecryption2()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //Deserialized string
- string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
- //Decrypt
- string decryptedMessage = pc.Decrypt(message);
- //Deserialize
- message = JsonConvert.DeserializeObject<string>(decryptedMessage);
- Assert.AreEqual("Pubnub Messaging API 2", message);
- }
-
- /// <summary>
- /// Tests the pub nub encryption1.
- /// The input is not serialized
- /// Encrypted string should match f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=
- /// </summary>
- [Test]
- public void TestPubNubEncryption1()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //non serialized string
- string message = "Pubnub Messaging API 1";
- //serialize
- message = JsonConvert.SerializeObject(message);
- //encrypt
- string encryptedMessage = pc.Encrypt(message);
-
- Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the pub nub decryption1.
- /// Assumes that the input message is deserialized
- /// Decrypted and Deserialized string should match Pubnub Messaging API 1
- /// </summary>
- [Test]
- public void TestPubNubDecryption1()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //deserialized string
- string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
- //deserialize
- message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
- Assert.AreEqual("Pubnub Messaging API 1", message);
- }
-
- /// <summary>
- /// Tests the stuff can encryption.
- /// The input is serialized
- /// Encrypted string should match zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF
- /// </summary>
- [Test]
- public void TestStuffCanEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //input serialized string
- string message = "{\"this stuff\":{\"can get\":\"complicated!\"}}";
- //encrypt
- string encryptedMessage = pc.Encrypt(message);
-
- Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the stuffcan decryption.
- /// Assumes that the input message is deserialized
- /// </summary>
- [Test]
- public void TestStuffcanDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //deserialized string
- string message = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
-
- Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", decryptedMessage);
- }
-
- /// <summary>
- /// Tests the hash encryption.
- /// The input is serialized
- /// Encrypted string should match GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=
- /// </summary>
- [Test]
- public void TestHashEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //serialized string
- string message = "{\"foo\":{\"bar\":\"foobar\"}}";
- //encrypt
- string encryptedMessage = pc.Encrypt(message);
-
- Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the hash decryption.
- /// Assumes that the input message is deserialized
- /// </summary>
- [Test]
- public void TestHashDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //deserialized string
- string message = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
-
- Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", decryptedMessage);
- }
-
- /// <summary>
- /// Tests the unicode chars encryption.
- /// The input is not serialized
- /// </summary>
- [Test]
- public void TestUnicodeCharsEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string message = "漢語";
-
- message = JsonConvert.SerializeObject(message);
- Console.WriteLine(message);
- string encryptedMessage = pc.Encrypt(message);
- Console.WriteLine(encryptedMessage);
- Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the unicode decryption.
- /// Assumes that the input message is deserialized
- /// Decrypted and Deserialized string should match the unicode chars
- /// </summary>
- [Test]
- public void TestUnicodeCharsDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string message = "+BY5/miAA8aeuhVl4d13Kg==";
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
- //deserialize
- message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
-
- Assert.AreEqual("漢語", message);
- }
-
- /// <summary>
- /// Tests the german chars decryption.
- /// Assumes that the input message is deserialized
- /// Decrypted and Deserialized string should match the unicode chars
- /// </summary>
- [Test]
- public void TestGermanCharsDecryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string message = "stpgsG1DZZxb44J7mFNSzg==";
-
- //decrypt
- string decryptedMessage = pc.Decrypt(message);
- //deserialize
- message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
-
- Assert.AreEqual("ÜÖ", message);
- }
-
- /// <summary>
- /// Tests the german encryption.
- /// The input is not serialized
- /// </summary>
- [Test]
- public void TestGermanCharsEncryption()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string message = "ÜÖ";
-
- message = JsonConvert.SerializeObject(message);
- Console.WriteLine(message);
- string encryptedMessage = pc.Encrypt(message);
- Console.WriteLine(encryptedMessage);
- Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", encryptedMessage);
- }
-
- /// <summary>
- /// Tests the cipher.
- /// </summary>
- /*[Test]
- public void TestCipher ()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
-
- string strCipher = pc.GetEncryptionKey();
-
- Assert.AreEqual("67a4f45f0d1d9bc606486fc42dc49416", strCipher);
- }*/
-
- static string EncodeNonAsciiCharacters(string value)
- {
- StringBuilder sb = new StringBuilder();
- foreach (char c in value)
- {
- if (c > 127)
- {
- // This character is too big for ASCII
- string encodedValue = "\\u" + ((int)c).ToString("x4");
- sb.Append(encodedValue);
- }
- else
- {
- sb.Append(c);
- }
- }
- return sb.ToString();
- }
-
- static string DecodeEncodedNonAsciiCharacters(string value)
- {
- return Regex.Replace(
- value,
- @"\\u(?<Value>[a-zA-Z0-9]{4})",
- m =>
- {
- return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString();
- });
- }
-
-
- }
-}
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using System.ComponentModel;
+using System.Threading;
+using System.Collections;
+using PubNubMessaging.Core;
+using System.Text.RegularExpressions;
+using System.Globalization;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+using System.Xml;
+
+namespace PubNubMessaging.Tests
+{
+ /// <summary>
+ /// Custom class for testing the encryption and decryption
+ /// </summary>
+ class CustomClass
+ {
+ public string foo = "hi!";
+ public int[] bar = { 1, 2, 3, 4, 5 };
+ }
+ class SecretCustomClass
+ {
+ public string foo = "hello!";
+ public int[] bar = { 10, 20, 30, 40, 50 };
+ }
+
+ class PubnubDemoObject
+ {
+ public double VersionID = 3.4;
+ public long Timetoken = 13601488652764619;
+ public string OperationName = "Publish";
+ public string[] Channels = { "ch1" };
+ public PubnubDemoMessage DemoMessage = new PubnubDemoMessage();
+ public PubnubDemoMessage CustomMessage = new PubnubDemoMessage("Welcome to the world of Pubnub for Publish and Subscribe. Hah!");
+ public XmlDocument SampleXml = new PubnubDemoMessage().TryXmlDemo();
+ }
+
+ class PubnubDemoMessage
+ {
+ public string DefaultMessage = "~!@#$%^&*()_+ `1234567890-= qwertyuiop[]\\ {}| asdfghjkl;' :\" zxcvbnm,./ <>? ";
+
+ public PubnubDemoMessage()
+ {
+ }
+
+ public PubnubDemoMessage(string message)
+ {
+ DefaultMessage = message;
+ }
+
+ public XmlDocument TryXmlDemo()
+ {
+ XmlDocument xmlDocument = new XmlDocument();
+ xmlDocument.LoadXml("<DemoRoot><Person ID='ABCD123'><Name><First>John</First><Middle>P.</Middle><Last>Doe</Last></Name><Address><Street>123 Duck Street</Street><City>New City</City><State>New York</State><Country>United States</Country></Address></Person><Person ID='ABCD456'><Name><First>Peter</First><Middle>Z.</Middle><Last>Smith</Last></Name><Address><Street>12 Hollow Street</Street><City>Philadelphia</City><State>Pennsylvania</State><Country>United States</Country></Address></Person></DemoRoot>");
+ return xmlDocument;
+ }
+ }
+
+ [TestFixture]
+ public class EncryptionTests
+ {
+ /// <summary>
+ /// Tests the null encryption.
+ /// The input is serialized
+ /// </summary>
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void TestNullEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //serialized string
+ string message = null;
+
+ //encrypt
+ string encryptedMessage = pc.Encrypt(message);
+ }
+
+ /// <summary>
+ /// Tests the null decryption.
+ /// Assumes that the input message is deserialized
+ /// </summary>
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void TestNullDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //deserialized string
+ string message = null;
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+
+ Assert.AreEqual("", decryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the yay decryption.
+ /// Assumes that the input message is deserialized
+ /// Decrypted string should match yay!
+ /// </summary>
+ [Test]
+ public void TestYayDecryptionBasic()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ string message = "q/xJqqN6qbiZMXYmiQC1Fw==";
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //deserialize again
+ Assert.AreEqual("yay!", decryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the yay encryption.
+ /// The output is not serialized
+ /// Encrypted string should match q/xJqqN6qbiZMXYmiQC1Fw==
+ /// </summary>
+ [Test]
+ public void TestYayEncryptionBasic()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //deserialized string
+ string message = "yay!";
+ //Encrypt
+ string encryptedMessage = pc.Encrypt(message);
+ Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the yay decryption.
+ /// Assumes that the input message is not deserialized
+ /// Decrypted and Deserialized string should match yay!
+ /// </summary>
+ [Test]
+ public void TestYayDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
+ //Non deserialized string
+ string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";
+ //Deserialize
+ message = JsonConvert.DeserializeObject<string>(message);
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //deserialize again
+ message = JsonConvert.DeserializeObject<string>(decryptedMessage);
+ Assert.AreEqual("yay!", message);
+ }
+ /// <summary>
+ /// Tests the yay encryption.
+ /// The output is not serialized
+ /// Encrypted string should match Wi24KS4pcTzvyuGOHubiXg==
+ /// </summary>
+ [Test]
+ public void TestYayEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //deserialized string
+ string message = "yay!";
+ //serialize the string
+ message = JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ //Encrypt
+ string enc = pc.Encrypt(message);
+ Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", enc);
+ }
+
+ /// <summary>
+ /// Tests the array encryption.
+ /// The output is not serialized
+ /// Encrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestArrayEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //create an empty array object
+ object[] emptyArray = { };
+ //serialize
+ string serializedArray = JsonConvert.SerializeObject(emptyArray);
+ //Encrypt
+ string encryptedMessage = pc.Encrypt(serializedArray);
+
+ Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the array decryption.
+ /// Assumes that the input message is deserialized
+ /// And the output message has to been deserialized.
+ /// Decrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestArrayDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //Input the deserialized string
+ string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //create a serialized object
+ object[] emptyArrayObject = { };
+ string result = JsonConvert.SerializeObject(emptyArrayObject);
+ //compare the serialized object and the return of the Decrypt method
+ Assert.AreEqual(result, decryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the object encryption.
+ /// The output is not serialized
+ /// Encrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestObjectEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //create an object
+ Object obj = new Object();
+ //serialize
+ string serializedObject = JsonConvert.SerializeObject(obj);
+ //encrypt
+ string encryptedMessage = pc.Encrypt(serializedObject);
+
+ Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", encryptedMessage);
+ }
+ /// <summary>
+ /// Tests the object decryption.
+ /// Assumes that the input message is deserialized
+ /// And the output message has to be deserialized.
+ /// Decrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestObjectDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //Deserialized
+ string message = "IDjZE9BHSjcX67RddfCYYg==";
+ //Decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //create an object
+ Object obj = new Object();
+ //Serialize the object
+ string result = JsonConvert.SerializeObject(obj);
+
+ Assert.AreEqual(result, decryptedMessage);
+ }
+ /// <summary>
+ /// Tests my object encryption.
+ /// The output is not serialized
+ /// Encrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestMyObjectEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //create an object of the custom class
+ CustomClass cc = new CustomClass();
+ //serialize it
+ string result = JsonConvert.SerializeObject(cc);
+ //encrypt it
+ string encryptedMessage = pc.Encrypt(result);
+
+ Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encryptedMessage);
+ }
+ /// <summary>
+ /// Tests my object decryption.
+ /// The output is not deserialized
+ /// Decrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestMyObjectDecryption()
+ {
+ 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);
+
+ Assert.AreEqual(result, decryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the pub nub encryption2.
+ /// The output is not serialized
+ /// Encrypted string should match f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=
+ /// </summary>
+ [Test]
+ public void TestPubNubEncryption2()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //Deserialized
+ string message = "Pubnub Messaging API 2";
+ //serialize the message
+ message = JsonConvert.SerializeObject(message);
+ //encrypt
+ string encryptedMessage = pc.Encrypt(message);
+
+ Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the pub nub decryption2.
+ /// Assumes that the input message is deserialized
+ /// Decrypted and Deserialized string should match Pubnub Messaging API 2
+ /// </summary>
+ [Test]
+ public void TestPubNubDecryption2()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //Deserialized string
+ string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
+ //Decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //Deserialize
+ message = JsonConvert.DeserializeObject<string>(decryptedMessage);
+ Assert.AreEqual("Pubnub Messaging API 2", message);
+ }
+
+ /// <summary>
+ /// Tests the pub nub encryption1.
+ /// The input is not serialized
+ /// Encrypted string should match f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=
+ /// </summary>
+ [Test]
+ public void TestPubNubEncryption1()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //non serialized string
+ string message = "Pubnub Messaging API 1";
+ //serialize
+ message = JsonConvert.SerializeObject(message);
+ //encrypt
+ string encryptedMessage = pc.Encrypt(message);
+
+ Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the pub nub decryption1.
+ /// Assumes that the input message is deserialized
+ /// Decrypted and Deserialized string should match Pubnub Messaging API 1
+ /// </summary>
+ [Test]
+ public void TestPubNubDecryption1()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //deserialized string
+ string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //deserialize
+ message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
+ Assert.AreEqual("Pubnub Messaging API 1", message);
+ }
+
+ /// <summary>
+ /// Tests the stuff can encryption.
+ /// The input is serialized
+ /// Encrypted string should match zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF
+ /// </summary>
+ [Test]
+ public void TestStuffCanEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //input serialized string
+ string message = "{\"this stuff\":{\"can get\":\"complicated!\"}}";
+ //encrypt
+ string encryptedMessage = pc.Encrypt(message);
+
+ Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the stuffcan decryption.
+ /// Assumes that the input message is deserialized
+ /// </summary>
+ [Test]
+ public void TestStuffcanDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //deserialized string
+ string message = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+
+ Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", decryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the hash encryption.
+ /// The input is serialized
+ /// Encrypted string should match GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=
+ /// </summary>
+ [Test]
+ public void TestHashEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //serialized string
+ string message = "{\"foo\":{\"bar\":\"foobar\"}}";
+ //encrypt
+ string encryptedMessage = pc.Encrypt(message);
+
+ Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the hash decryption.
+ /// Assumes that the input message is deserialized
+ /// </summary>
+ [Test]
+ public void TestHashDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ //deserialized string
+ string message = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+
+ Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", decryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the unicode chars encryption.
+ /// The input is not serialized
+ /// </summary>
+ [Test]
+ public void TestUnicodeCharsEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ string message = "漢語";
+
+ message = JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encryptedMessage = pc.Encrypt(message);
+ Console.WriteLine(encryptedMessage);
+ Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the unicode decryption.
+ /// Assumes that the input message is deserialized
+ /// Decrypted and Deserialized string should match the unicode chars
+ /// </summary>
+ [Test]
+ public void TestUnicodeCharsDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ string message = "+BY5/miAA8aeuhVl4d13Kg==";
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //deserialize
+ message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
+
+ Assert.AreEqual("漢語", message);
+ }
+
+ /// <summary>
+ /// Tests the german chars decryption.
+ /// Assumes that the input message is deserialized
+ /// Decrypted and Deserialized string should match the unicode chars
+ /// </summary>
+ [Test]
+ public void TestGermanCharsDecryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ string message = "stpgsG1DZZxb44J7mFNSzg==";
+
+ //decrypt
+ string decryptedMessage = pc.Decrypt(message);
+ //deserialize
+ message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
+
+ Assert.AreEqual("ÜÖ", message);
+ }
+
+ /// <summary>
+ /// Tests the german encryption.
+ /// The input is not serialized
+ /// </summary>
+ [Test]
+ public void TestGermanCharsEncryption()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+ string message = "ÜÖ";
+
+ message = JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encryptedMessage = pc.Encrypt(message);
+ Console.WriteLine(encryptedMessage);
+ Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", encryptedMessage);
+ }
+
+ /// <summary>
+ /// Tests the cipher.
+ /// </summary>
+ /*[Test]
+ public void TestCipher ()
+ {
+ PubnubCrypto pc = new PubnubCrypto("enigma");
+
+ string strCipher = pc.GetEncryptionKey();
+
+ Assert.AreEqual("67a4f45f0d1d9bc606486fc42dc49416", strCipher);
+ }*/
+
+ static string EncodeNonAsciiCharacters(string value)
+ {
+ StringBuilder sb = new StringBuilder();
+ foreach (char c in value)
+ {
+ if (c > 127)
+ {
+ // This character is too big for ASCII
+ string encodedValue = "\\u" + ((int)c).ToString("x4");
+ sb.Append(encodedValue);
+ }
+ else
+ {
+ sb.Append(c);
+ }
+ }
+ return sb.ToString();
+ }
+
+ static string DecodeEncodedNonAsciiCharacters(string value)
+ {
+ return Regex.Replace(
+ value,
+ @"\\u(?<Value>[a-zA-Z0-9]{4})",
+ m =>
+ {
+ return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString();
+ });
+ }
+
+
+ }
+}
View
237 csharp/3.4/PubNub-Messaging.Tests/PubNub-Messaging.Tests.csproj
@@ -1,119 +1,120 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{BD61C09A-BE66-466F-B9A6-F58BEC59E21B}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>PubNubMessaging.Tests</RootNamespace>
- <AssemblyName>PubNubMessaging.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <TargetFrameworkProfile />
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup>
- <DefineConstants Condition=" !$(DefineConstants.Contains(';NET')) ">$(DefineConstants);$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</DefineConstants>
- <DefineConstants Condition=" $(DefineConstants.Contains(';NET')) ">$(DefineConstants.Remove($(DefineConstants.LastIndexOf(";NET"))));$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</DefineConstants>
- </PropertyGroup>
- <Choose>
- <When Condition=" '$(TargetFrameworkVersion.Replace(&quot;v&quot;,&quot;&quot;))' == '3.5' ">
- <PropertyGroup>
- <ConfigTemplate>
- <Configuration>
- <Startup>
- <SupportedRuntime Version="v2.0.50727" />
- </Startup>
- </Configuration>
- </ConfigTemplate>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <Private>True</Private>
- <HintPath>v3.5\Newtonsoft.Json.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- </When>
- <When Condition=" '$(TargetFrameworkVersion.Replace(&quot;v&quot;,&quot;&quot;))' == '4.0' Or '$(TargetFrameworkVersion.Replace(&quot;v&quot;,&quot;&quot;))' == '4.5' ">
- <PropertyGroup>
- <ConfigTemplate>
- <Configuration>
- <Startup>
- <SupportedRuntime Version="v4.0" />
- </Startup>
- </Configuration>
- </ConfigTemplate>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <Private>True</Private>
- <HintPath>v4.0\Newtonsoft.Json.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- </When>
- </Choose>
- <ItemGroup>
- <Reference Include="nunit.framework, Version=2.6.1.12217, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\..\..\Program Files (x86)\NUnit 2.6.1\bin\framework\nunit.framework.dll</HintPath>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="EncryptionTests.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="PubnubUnitTest.cs" />
- <Compile Include="WhenAClientIsPresented.cs" />
- <Compile Include="WhenAMessageIsPublished.cs" />
- <Compile Include="WhenDetailedHistoryIsRequested.cs" />
- <Compile Include="WhenGetRequestServerTime.cs" />
- <Compile Include="WhenSubscribedToAChannel.cs" />
- <Compile Include="WhenUnsubscribedToAChannel.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config">
- <SubType>Designer</SubType>
- </None>
- </ItemGroup>
- <ItemGroup>
- <Folder Include="v3.5\" />
- <Folder Include="v4.0\" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\PubNub-Messaging\PubNub-Messaging.csproj">
- <Project>{B1ED98C3-FD0B-4B45-B0BE-40AFD37182CB}</Project>
- <Name>PubNub-Messaging</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{BD61C09A-BE66-466F-B9A6-F58BEC59E21B}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>PubNubMessaging.Tests</RootNamespace>
+ <AssemblyName>PubNubMessaging.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <DefineConstants Condition=" !$(DefineConstants.Contains(';NET')) ">$(DefineConstants);$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</DefineConstants>
+ <DefineConstants Condition=" $(DefineConstants.Contains(';NET')) ">$(DefineConstants.Remove($(DefineConstants.LastIndexOf(";NET"))));$(TargetFrameworkVersion.Replace("v", "NET").Replace(".", ""))</DefineConstants>
+ </PropertyGroup>
+ <Choose>
+ <When Condition=" '$(TargetFrameworkVersion.Replace(&quot;v&quot;,&quot;&quot;))' == '3.5' ">
+ <PropertyGroup>
+ <ConfigTemplate>
+ <Configuration>
+ <Startup>
+ <SupportedRuntime Version="v2.0.50727" />
+ </Startup>
+ </Configuration>
+ </ConfigTemplate>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>v3.5\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ </When>
+ <When Condition=" '$(TargetFrameworkVersion.Replace(&quot;v&quot;,&quot;&quot;))' == '4.0' Or '$(TargetFrameworkVersion.Replace(&quot;v&quot;,&quot;&quot;))' == '4.5' ">
+ <PropertyGroup>
+ <ConfigTemplate>
+ <Configuration>
+ <Startup>
+ <SupportedRuntime Version="v4.0" />
+ </Startup>
+ </Configuration>
+ </ConfigTemplate>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>v4.0\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ </When>
+ </Choose>
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.6.1.12217, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\..\..\..\Program Files (x86)\NUnit 2.6.1\bin\framework\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System.XML" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="EncryptionTests.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="PubnubUnitTest.cs" />
+ <Compile Include="WhenAClientIsPresented.cs" />
+ <Compile Include="WhenAMessageIsPublished.cs" />
+ <Compile Include="WhenDetailedHistoryIsRequested.cs" />
+ <Compile Include="WhenGetRequestServerTime.cs" />
+ <Compile Include="WhenSubscribedToAChannel.cs" />
+ <Compile Include="WhenUnsubscribedToAChannel.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config">
+ <SubType>Designer</SubType>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="v3.5\" />
+ <Folder Include="v4.0\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\PubNub-Messaging\PubNub-Messaging.csproj">
+ <Project>{B1ED98C3-FD0B-4B45-B0BE-40AFD37182CB}</Project>
+ <Name>PubNub-Messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
</Project>
View
994 csharp/3.4/PubNub-Messaging.Tests/PubnubUnitTest.cs
@@ -1,478 +1,516 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using PubNubMessaging.Core;
-
-namespace PubNubMessaging.Tests
-{
- public class PubnubUnitTest : IPubnubUnitTest
- {
- private bool enableStubTest = true;
- private string _testClassName = "";
- private string _testCaseName = "";
-
- public bool EnableStubTest
- {
- get
- {
- return enableStubTest;
- }
- set
- {
- enableStubTest = value;
- }
- }
-
- private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 0}],\"13596603694444112\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
-#else
- data.Add("/subscribe/demo/my/channel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my/channel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 0}],\"13596603694444112\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnCustomUUID()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 1}],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 0}],\"13596603694444112\"]");
- data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
- data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
-#else
- data.Add("/subscribe/demo/my/channel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my/channel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 1}],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 0}],\"13596603694444112\"]");
- data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
- data.Add("/subscribe/demo/my/channel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel", "{\"uuids\":[\"eb4c1645-1319-4425-865f-008563009d67\"],\"occupancy\":1}");
-#else
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel", "{\"uuids\":[\"eb4c1645-1319-4425-865f-008563009d67\"],\"occupancy\":1}");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub Messaging API 1\"],13557486057035336,13559006802662769]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Pubnub%20Messaging%20API%201%22", "[1,\"Sent\",\"13559014566792817\"]");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%22Pubnub%20Messaging%20API%201%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub Messaging API 1\"],13557486057035336,13559006802662769]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%7B%22foo%22%3A%22hi%21%22%2C%22bar%22%3A%5B1%2C2%2C3%2C4%2C5%5D%7D", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]}],13557486057035336,13559006802662769]");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%7B%22foo%22%3A%22hi%21%22%2C%22bar%22%3A%5B1%2C2%2C3%2C4%2C5%5D%7D", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]}],13557486057035336,13559006802662769]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],13559215464464812,13559215464464812]");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],13559215464464812,13559215464464812]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22%2BBY5%2FmiAA8aeuhVl4d13Kg%3D%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"+BY5/miAA8aeuhVl4d13Kg==\"],13557486057035336,13559006802662769]");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%22%2BBY5/miAA8aeuhVl4d13Kg%3D%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"+BY5/miAA8aeuhVl4d13Kg==\"],13557486057035336,13559006802662769]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/3f75435fcd800f5d0476fc0fb5b572d1/my%2Fchannel/0/%22f42pIQcWZ9zbTbH8cyLwB%2FtdvRxjFLOYcBNMVKeHS54%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\"],13559191494674157,13559191494674157]");
-#else
- data.Add("/publish/demo/demo/3f75435fcd800f5d0476fc0fb5b572d1/my/channel/0/%22f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\"],13559191494674157,13559191494674157]");
-#endif
-
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/d759c756abbd45a9864adc7f2b91393e/my%2Fchannel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
-#else
- data.Add("/publish/demo/demo/d759c756abbd45a9864adc7f2b91393e/my/channel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\"],13559191494674157,13559319777162196]");
-#else
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\"],13559191494674157,13559319777162196]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 3\"],13557486057035336,13557486128690220]");
-#else
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 3\"],13557486057035336,13557486128690220]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 2\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 3\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 4\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 5\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 6\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 7\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 8\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 9\"],13559326456056557,13559327017296315]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%200%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%201%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%202%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%203%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%204%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%205%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%206%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%207%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%208%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%209%22", "[1,\"Sent\",\"13559014566792817\"]");
-#else
- data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 2\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 3\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 4\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 4\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 6\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 7\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 8\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 9\"],13559326456056557,13559327017296315]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%200%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%201%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%202%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%203%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%204%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%205%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%206%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%207%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%208%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%209%22", "[1,\"Sent\",\"13559014566792817\"]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/time/0", "[13559011090230537]");
- return data;
- }
-
- private Dictionary<string, string> LoadWhenGetRequestServerTimeThenWithProxyItShouldReturnTimeStamp()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/time/0", "[13559011090230537]");
- return data;
- }
-
- private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/13559014566792816", "[[],\"13559014566792816\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%2Fchannel/leave", "{\"action\": \"leave\"}");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/my/channel/0/13559014566792816", "[[],\"13559014566792816\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/13559014566792816", "[[],\"13559014566792816\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%2Fchannel/leave", "{\"action\": \"leave\"}");
-#else
- data.Add("/publish/demo/demo/0/my/channel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/my/channel/0/13559014566792816", "[[],\"13559014566792816\"]");
- data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenSubscribedToAChannelThenMultiSubscribeShouldReturnConnectStatus()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/my%2Fchannel1/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel1/0/13559006802662768", "[[],\"13559006802662768\"]");
-
- data.Add("/subscribe/demo/my%2Fchannel1,my%2Fchannel2/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel1,my%2Fchannel2/0/13559006802662768", "[[],\"13559006802662768\"]");
-#else
- data.Add("/subscribe/demo/my/channel1/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel1/0/13559006802662768", "[[],\"13559006802662768\"]");
-
- data.Add("/subscribe/demo/my/channel1,my/channel2/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel1,my/channel2/0/13559006802662768", "[[],\"13559006802662768\"]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenSubscribedToAChannelThenDuplicateChannelShouldReturnAlreadySubscribed()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[],\"13559006802662768\"]");
-#else
- data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[],\"13559006802662768\"]");
-#endif
- return data;
- }
-
- private Dictionary<string, string> LoadWhenUnsubscribedToAChannelThenShouldReturnUnsubscribedMessage()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
-#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[],\"13559006802662768\"]");
-#else
- data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[],\"13559006802662768\"]");
-#endif
- return data;
- }
-
- public string GetStubResponse(Uri request)
- {
- Dictionary<string, string> responseDictionary = null;
- string stubResponse = "!! Stub Response Not Assigned !!";
-
- switch (_testClassName)
- {
- case "WhenAClientIsPresented":
- switch (_testCaseName)
- {
- case "ThenPresenceShouldReturnReceivedMessage":
- responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage();
- break;
- case "ThenPresenceShouldReturnCustomUUID":
- responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnCustomUUID();
- break;
- case "IfHereNowIsCalledThenItShouldReturnInfo":
- responseDictionary = LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo();
- break;
- default:
- break;
- }
- break;
- case "WhenAMessageIsPublished":
- switch (_testCaseName)
- {
- case "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo":
- responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo":
- responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo":
- responseDictionary = LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenEncryptPublishShouldReturnSuccessCodeAndInfo":
- responseDictionary = LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo":
- responseDictionary = LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenOptionalSecretKeyShouldBeProvidedInConstructor":
- responseDictionary = LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor();
- break;
- case "IfSSLNotProvidedThenDefaultShouldBeFalse":
- responseDictionary = LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse();
- break;
- default:
- break;
- }
- break;
- case "WhenDetailedHistoryIsRequested":
- switch (_testCaseName)
- {
- case "DetailHistoryCount10ReturnsRecords":
- responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords();
- break;
- case "DetailHistoryCount10ReverseTrueReturnsRecords":
- responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords();
- break;
- case "DetailedHistoryStartWithReverseTrue":
- responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue();
- break;
- default:
- break;
- }
- break;
- case "WhenGetRequestServerTime":
- switch (_testCaseName)
- {
- case "ThenItShouldReturnTimeStamp":
- responseDictionary = LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp();
- break;
- case "ThenWithProxyItShouldReturnTimeStamp":
- responseDictionary = LoadWhenGetRequestServerTimeThenWithProxyItShouldReturnTimeStamp();
- break;
- default:
- break;
- }
- break;
- case "WhenSubscribedToAChannel":
- switch (_testCaseName)
- {
- case "ThenSubscribeShouldReturnReceivedMessage":
- responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage();
- break;
- case "ThenSubscribeShouldReturnConnectStatus":
- responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus();
- break;
- case "ThenMultiSubscribeShouldReturnConnectStatus":
- responseDictionary = LoadWhenSubscribedToAChannelThenMultiSubscribeShouldReturnConnectStatus();
- break;
- case "ThenDuplicateChannelShouldReturnAlreadySubscribed":
- responseDictionary = LoadWhenSubscribedToAChannelThenDuplicateChannelShouldReturnAlreadySubscribed();
- break;
- default:
- break;
- }
- break;
- case "WhenUnsubscribedToAChannel":
- switch (_testCaseName)
- {
- case "ThenShouldReturnUnsubscribedMessage":
- responseDictionary = LoadWhenUnsubscribedToAChannelThenShouldReturnUnsubscribedMessage();
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- if (responseDictionary != null && responseDictionary.ContainsKey(request.AbsolutePath))
- {
- stubResponse = responseDictionary[request.AbsolutePath];
- }
- else
- {
- stubResponse = "!! Stub Response Not Assigned !!";
- }
-
- return stubResponse;
- }
-
- public string TestCaseName
- {
- get
- {
- return _testCaseName;
- }
- set
- {
- _testCaseName = value;
- }
- }
-
-
- public string TestClassName
- {
- get
- {
- return _testClassName;
- }
- set
- {
- _testClassName = value;
- }
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using PubNubMessaging.Core;
+
+namespace PubNubMessaging.Tests
+{
+ public class PubnubUnitTest : IPubnubUnitTest
+ {
+ private bool enableStubTest = true;
+ private string _testClassName = "";
+ private string _testCaseName = "";
+
+ public bool EnableStubTest
+ {
+ get
+ {
+ return enableStubTest;
+ }
+ set
+ {
+ enableStubTest = value;
+ }
+ }
+
+ private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 0}],\"13596603694444112\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#else
+ data.Add("/subscribe/demo/my/channel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my/channel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 0}],\"13596603694444112\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnCustomUUID()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 1}],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 0}],\"13596603694444112\"]");
+ data.Add("/subscribe/demo/my%2Fchannel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
+ data.Add("/subscribe/demo/my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#else
+ data.Add("/subscribe/demo/my/channel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my/channel-pnpres/0/13596603179264912", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/0", "[[],\"13596603179264912\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603179264912", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 1}],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13559006802662768", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel-pnpres/0/13559006802662768", "[[{\"action\": \"leave\", \"timestamp\": 1359660369, \"uuid\": \"mylocalmachine.mydomain.com\", \"occupancy\": 0}],\"13596603694444112\"]");
+ data.Add("/subscribe/demo/my/channel,my%2Fchannel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
+ data.Add("/subscribe/demo/my/channel-pnpres/0/13596603694444112", "[[],\"13596603694444112\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel", "{\"uuids\":[\"eb4c1645-1319-4425-865f-008563009d67\"],\"occupancy\":1}");
+#else
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel", "{\"uuids\":[\"eb4c1645-1319-4425-865f-008563009d67\"],\"occupancy\":1}");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub Messaging API 1\"],13557486057035336,13559006802662769]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Pubnub%20Messaging%20API%201%22", "[1,\"Sent\",\"13559014566792817\"]");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%22Pubnub%20Messaging%20API%201%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub Messaging API 1\"],13557486057035336,13559006802662769]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%7B%22foo%22%3A%22hi%21%22%2C%22bar%22%3A%5B1%2C2%2C3%2C4%2C5%5D%7D", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]}],13557486057035336,13559006802662769]");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%7B%22foo%22%3A%22hi%21%22%2C%22bar%22%3A%5B1%2C2%2C3%2C4%2C5%5D%7D", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]}],13557486057035336,13559006802662769]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],13559215464464812,13559215464464812]");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],13559215464464812,13559215464464812]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22%2BBY5%2FmiAA8aeuhVl4d13Kg%3D%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"+BY5/miAA8aeuhVl4d13Kg==\"],13557486057035336,13559006802662769]");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%22%2BBY5/miAA8aeuhVl4d13Kg%3D%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"+BY5/miAA8aeuhVl4d13Kg==\"],13557486057035336,13559006802662769]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/3f75435fcd800f5d0476fc0fb5b572d1/my%2Fchannel/0/%22f42pIQcWZ9zbTbH8cyLwB%2FtdvRxjFLOYcBNMVKeHS54%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\"],13559191494674157,13559191494674157]");
+#else
+ data.Add("/publish/demo/demo/3f75435fcd800f5d0476fc0fb5b572d1/my/channel/0/%22f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\"],13559191494674157,13559191494674157]");
+#endif
+
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenComplexMessageObjectShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%7B%22VersionID%22%3A3%2E4%2C%22Timetoken%22%3A13601488652764619%2C%22OperationName%22%3A%22Publish%22%2C%22Channels%22%3A%5B%22ch1%22%5D%2C%22DemoMessage%22%3A%7B%22DefaultMessage%22%3A%22%7E%21%40%23%24%25%5E%26%2A%28%29_%2B%20%601234567890-%3D%20qwertyuiop%5B%5D%5C%5C%20%7B%7D%7C%20asdfghjkl%3B%27%20%3A%5C%22%20zxcvbnm%2C%2E%2F%20%3C%3E%3F%20%22%7D%2C%22CustomMessage%22%3A%7B%22DefaultMessage%22%3A%22Welcome%20to%20the%20world%20of%20Pubnub%20for%20Publish%20and%20Subscribe%2E%20Hah%21%22%7D%2C%22SampleXml%22%3A%7B%22DemoRoot%22%3A%7B%22Person%22%3A%5B%7B%22%40ID%22%3A%22ABCD123%22%2C%22Name%22%3A%7B%22First%22%3A%22John%22%2C%22Middle%22%3A%22P%2E%22%2C%22Last%22%3A%22Doe%22%7D%2C%22Address%22%3A%7B%22Street%22%3A%22123%20Duck%20Street%22%2C%22City%22%3A%22New%20City%22%2C%22State%22%3A%22New%20York%22%2C%22Country%22%3A%22United%20States%22%7D%7D%2C%7B%22%40ID%22%3A%22ABCD456%22%2C%22Name%22%3A%7B%22First%22%3A%22Peter%22%2C%22Middle%22%3A%22Z%2E%22%2C%22Last%22%3A%22Smith%22%7D%2C%22Address%22%3A%7B%22Street%22%3A%2212%20Hollow%20Street%22%2C%22City%22%3A%22Philadelphia%22%2C%22State%22%3A%22Pennsylvania%22%2C%22Country%22%3A%22United%20States%22%7D%7D%5D%7D%7D%7D", "[1,\"Sent\",\"13602210467298480\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[{\"VersionID\":3.4,\"Timetoken\":13601488652764619,\"OperationName\":\"Publish\",\"Channels\":[\"ch1\"],\"DemoMessage\":{\"DefaultMessage\":\"~!@#$%^&*()_+ `1234567890-= qwertyuiop[]\\\\ {}| asdfghjkl;' :\\\" zxcvbnm,./ <>? \"},\"CustomMessage\":{\"DefaultMessage\":\"Welcome to the world of Pubnub for Publish and Subscribe. Hah!\"},\"SampleXml\":{\"DemoRoot\":{\"Person\":[{\"@ID\":\"ABCD123\",\"Name\":{\"First\":\"John\",\"Middle\":\"P.\",\"Last\":\"Doe\"},\"Address\":{\"Street\":\"123 Duck Street\",\"City\":\"New City\",\"State\":\"New York\",\"Country\":\"United States\"}},{\"@ID\":\"ABCD456\",\"Name\":{\"First\":\"Peter\",\"Middle\":\"Z.\",\"Last\":\"Smith\"},\"Address\":{\"Street\":\"12 Hollow Street\",\"City\":\"Philadelphia\",\"State\":\"Pennsylvania\",\"Country\":\"United States\"}}]}}}],13602274270564989,13602274270564989]");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%7B%22VersionID%22%3A3%2E4%2C%22Timetoken%22%3A13601488652764619%2C%22OperationName%22%3A%22Publish%22%2C%22Channels%22%3A%5B%22ch1%22%5D%2C%22DemoMessage%22%3A%7B%22DefaultMessage%22%3A%22%7E%21%40%23%24%25%5E%26%2A%28%29_%2B%20%601234567890-%3D%20qwertyuiop%5B%5D%5C%5C%20%7B%7D%7C%20asdfghjkl%3B%27%20%3A%5C%22%20zxcvbnm%2C%2E%2F%20%3C%3E%3F%20%22%7D%2C%22CustomMessage%22%3A%7B%22DefaultMessage%22%3A%22Welcome%20to%20the%20world%20of%20Pubnub%20for%20Publish%20and%20Subscribe%2E%20Hah%21%22%7D%2C%22SampleXml%22%3A%7B%22DemoRoot%22%3A%7B%22Person%22%3A%5B%7B%22%40ID%22%3A%22ABCD123%22%2C%22Name%22%3A%7B%22First%22%3A%22John%22%2C%22Middle%22%3A%22P%2E%22%2C%22Last%22%3A%22Doe%22%7D%2C%22Address%22%3A%7B%22Street%22%3A%22123%20Duck%20Street%22%2C%22City%22%3A%22New%20City%22%2C%22State%22%3A%22New%20York%22%2C%22Country%22%3A%22United%20States%22%7D%7D%2C%7B%22%40ID%22%3A%22ABCD456%22%2C%22Name%22%3A%7B%22First%22%3A%22Peter%22%2C%22Middle%22%3A%22Z%2E%22%2C%22Last%22%3A%22Smith%22%7D%2C%22Address%22%3A%7B%22Street%22%3A%2212%20Hollow%20Street%22%2C%22City%22%3A%22Philadelphia%22%2C%22State%22%3A%22Pennsylvania%22%2C%22Country%22%3A%22United%20States%22%7D%7D%5D%7D%7D%7D", "[1,\"Sent\",\"13602210467298480\"]");
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[{\"VersionID\":3.4,\"Timetoken\":13601488652764619,\"OperationName\":\"Publish\",\"Channels\":[\"ch1\"],\"DemoMessage\":{\"DefaultMessage\":\"~!@#$%^&*()_+ `1234567890-= qwertyuiop[]\\\\ {}| asdfghjkl;' :\\\" zxcvbnm,./ <>? \"},\"CustomMessage\":{\"DefaultMessage\":\"Welcome to the world of Pubnub for Publish and Subscribe. Hah!\"},\"SampleXml\":{\"DemoRoot\":{\"Person\":[{\"@ID\":\"ABCD123\",\"Name\":{\"First\":\"John\",\"Middle\":\"P.\",\"Last\":\"Doe\"},\"Address\":{\"Street\":\"123 Duck Street\",\"City\":\"New City\",\"State\":\"New York\",\"Country\":\"United States\"}},{\"@ID\":\"ABCD456\",\"Name\":{\"First\":\"Peter\",\"Middle\":\"Z.\",\"Last\":\"Smith\"},\"Address\":{\"Street\":\"12 Hollow Street\",\"City\":\"Philadelphia\",\"State\":\"Pennsylvania\",\"Country\":\"United States\"}}]}}}],13602274270564989,13602274270564989]");
+#endif
+
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/d759c756abbd45a9864adc7f2b91393e/my%2Fchannel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
+#else
+ data.Add("/publish/demo/demo/d759c756abbd45a9864adc7f2b91393e/my/channel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\"],13559191494674157,13559319777162196]");
+#else
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\"],13559191494674157,13559319777162196]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 3\"],13557486057035336,13557486128690220]");
+#else
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"Pubnub API Usage Example\",\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\",\"+BY5/miAA8aeuhVl4d13Kg==\",\"Pubnub API Usage Example\",\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\",{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]},\"Pubnub Messaging API 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13557486100000000 3\"],13557486057035336,13557486128690220]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 2\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 3\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 4\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 5\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 6\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 7\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 8\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 9\"],13559326456056557,13559327017296315]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%200%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%201%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%202%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%203%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%204%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%205%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%206%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%207%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%208%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22DetailedHistoryStartTimeWithReverseTrue%209%22", "[1,\"Sent\",\"13559014566792817\"]");
+#else
+ data.Add("/v2/history/sub-key/demo/channel/my%252Fchannel", "[[\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 0\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 1\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 2\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 3\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 4\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 4\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 6\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 7\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 8\",\"DetailedHistoryStartTimeWithReverseTrue 13559326410000000 9\"],13559326456056557,13559327017296315]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%200%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%201%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%202%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%203%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%204%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%205%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%206%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%207%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%208%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/my/channel/0/%22DetailedHistoryStartTimeWithReverseTrue%209%22", "[1,\"Sent\",\"13559014566792817\"]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/time/0", "[13559011090230537]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenGetRequestServerTimeThenWithProxyItShouldReturnTimeStamp()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/time/0", "[13559011090230537]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%2Fchannel/leave", "{\"action\": \"leave\"}");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/my/channel/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/publish/demo/demo/0/my%2Fchannel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%2Fchannel/leave", "{\"action\": \"leave\"}");
+#else
+ data.Add("/publish/demo/demo/0/my/channel/0/%22Test%20for%20WhenSubscribedToAChannel%20ThenItShouldReturnReceivedMessage%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[\"Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/my/channel/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenMultiSubscribeShouldReturnConnectStatus()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/subscribe/demo/my%2Fchannel1/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel1/0/13559006802662768", "[[],\"13559006802662768\"]");
+
+ data.Add("/subscribe/demo/my%2Fchannel1,my%2Fchannel2/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel1,my%2Fchannel2/0/13559006802662768", "[[],\"13559006802662768\"]");
+#else
+ data.Add("/subscribe/demo/my/channel1/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel1/0/13559006802662768", "[[],\"13559006802662768\"]");
+
+ data.Add("/subscribe/demo/my/channel1,my/channel2/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel1,my/channel2/0/13559006802662768", "[[],\"13559006802662768\"]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenDuplicateChannelShouldReturnAlreadySubscribed()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[],\"13559006802662768\"]");
+#else
+ data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[],\"13559006802662768\"]");
+#endif
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscriberShouldBeAbleToReceiveManyMessages()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13602645380839594\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13602645380839594", "[[742730406,1853970548,1899616327,1043229779,1270838952,788288787,627599385,1517373321,1202317119,184893837],\"13602645382888692\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13602645382888692", "[[],\"13602645382888692\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%2Fchannel/leave", "{\"action\": \"leave\"}");
+#else
+ data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13602645380839594\"]");
+ data.Add("/subscribe/demo/my/channel/0/13602645380839594", "[[742730406,1853970548,1899616327,1043229779,1270838952,788288787,627599385,1517373321,1202317119,184893837],\"13602645382888692\"]");
+ data.Add("/subscribe/demo/my/channel/0/13602645382888692", "[[],\"13602645382888692\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/my%252Fchannel/leave", "{\"action\": \"leave\"}");
+#endif
+ return data;
+ }
+
+
+ private Dictionary<string, string> LoadWhenUnsubscribedToAChannelThenShouldReturnUnsubscribedMessage()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
+ data.Add("/subscribe/demo/my%2Fchannel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my%2Fchannel/0/13559006802662768", "[[],\"13559006802662768\"]");
+#else
+ data.Add("/subscribe/demo/my/channel/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/my/channel/0/13559006802662768", "[[],\"13559006802662768\"]");
+#endif
+ return data;
+ }
+
+ public string GetStubResponse(Uri request)
+ {
+ Dictionary<string, string> responseDictionary = null;
+ string stubResponse = "!! Stub Response Not Assigned !!";
+
+ switch (_testClassName)
+ {
+ case "WhenAClientIsPresented":
+ switch (_testCaseName)
+ {
+ case "ThenPresenceShouldReturnReceivedMessage":
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage();
+ break;
+ case "ThenPresenceShouldReturnCustomUUID":
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnCustomUUID();
+ break;
+ case "IfHereNowIsCalledThenItShouldReturnInfo":
+ responseDictionary = LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo();
+ break;
+ default:
+ break;
+ }
+ break;
+ case "WhenAMessageIsPublished":
+ switch (_testCaseName)
+ {
+ case "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
+ break;
+ case "ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
+ break;
+ case "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
+ break;
+ case "ThenEncryptPublishShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo();
+ break;
+ case "ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
+ break;
+ case "ThenComplexMessageObjectShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenComplexMessageObjectShouldReturnSuccessCodeAndInfo();
+ break;
+ case "ThenOptionalSecretKeyShouldBeProvidedInConstructor":
+ responseDictionary = LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor();
+ break;
+ case "IfSSLNotProvidedThenDefaultShouldBeFalse":
+ responseDictionary = LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse();
+ break;
+ default:
+ break;
+ }
+ break;
+ case "WhenDetailedHistoryIsRequested":
+ switch (_testCaseName)
+ {
+ case "DetailHistoryCount10ReturnsRecords":