Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor code all mono versions

  • Loading branch information...
commit 45afe6dac97af59665c19fe3b0009d7e6371e37a 1 parent c945ed5
@crimsonred crimsonred authored
Showing with 7,967 additions and 9,609 deletions.
  1. +2 −2 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Andr.Unit.csproj
  2. +19 −84 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Common.cs
  3. +462 −499 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/EncryptionTests.cs
  4. +1 −1  mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/MainActivity.cs
  5. +494 −492 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs
  6. +56 −79 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAClientIsPresented.cs
  7. +165 −167 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAMessageIsPublished.cs
  8. +305 −841 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenDetailedHistoryIsRequested.cs
  9. +23 −26 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenGetRequestServerTime.cs
  10. +43 −66 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenSubscribedToAChannel.cs
  11. +204 −7 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/LaunchScreen.cs
  12. +25 −94 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/MainActivity.cs
  13. +2 −2 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Properties/AndroidManifest.xml
  14. +2 −1  ...r-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/{PubNub_Messaging.csproj → PubNubMessaging.csproj}
  15. +689 −544 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Pubnub.cs
  16. +118 −55 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Resources/Resource.designer.cs
  17. +17 −0 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Resources/layout-large/Launch.axml
  18. +18 −1 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Launch.axml
  19. +89 −0 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Resources/layout/Proxy.axml
  20. +11 −0 mono-for-android/3.3.0.1/Pubnub-Messaging/PubNub_Messaging/Resources/values/Strings.xml
  21. +2 −2 mono-for-android/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.sln
  22. +8 −7 mono-for-android/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.userprefs
  23. +1 −1  mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Messaging.csproj
  24. BIN  mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Messaging.pidb
  25. +695 −547 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub.cs
  26. +63 −18 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub_Example.cs
  27. +9 −13 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNub-Messaging.userprefs
  28. +19 −84 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/Common.cs
  29. +167 −203 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/EncryptionTests.cs
  30. +4 −1 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/PubNub-Messaging.Tests.csproj
  31. BIN  mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/PubNub-Messaging.Tests.pidb
  32. +92 −90 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/PubnubUnitTest.cs
  33. +72 −95 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs
  34. +35 −40 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAMessageIsPublished.cs
  35. +472 −1,009 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/WhenDetailedHistoryIsRequested.cs
  36. +17 −20 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/WhenGetRequestServerTime.cs
  37. +34 −39 mono-for-linux/3.3.0.1/PubNub-Messaging/PubNubTest/WhenSubscribedToAChannel.cs
  38. +1 −1  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/AssemblyInfo.cs
  39. +1 −1  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Messaging.csproj
  40. +695 −547 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub.cs
  41. +62 −18 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/{Pubnub_Example.cs → PubnubExample.cs}
  42. +12 −19 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Messaging.userprefs
  43. +1 −1  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/AssemblyInfo.cs
  44. +19 −84 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/Common.cs
  45. +120 −158 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/EncryptionTests.cs
  46. +92 −90 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/PubnubUnitTest.cs
  47. +72 −95 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs
  48. +35 −38 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAMessageIsPublished.cs
  49. +472 −1,009 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenDetailedHistoryIsRequested.cs
  50. +14 −18 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenGetRequestServerTime.cs
  51. +34 −39 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenSubscribedToAChannel.cs
  52. +18 −83 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/Common.cs
  53. +448 −486 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/EncryptionTests.cs
  54. +92 −90 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/PubnubUnitTest.cs
  55. +71 −93 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenAClientIsPresented.cs
  56. +35 −38 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenAMessageIsPublished.cs
  57. +305 −841 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenDetailedHistoryIsRequested.cs
  58. +14 −18 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenGetRequestServerTime.cs
  59. +28 −34 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenSubscribedToAChannel.cs
  60. +7 −5 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.userprefs
  61. +689 −544 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub.cs
  62. +69 −4 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingMain.cs
  63. +126 −125 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingSub.cs
View
4 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Andr.Unit.csproj
@@ -129,9 +129,9 @@
<Project>{E6C3413C-919B-486D-8B6C-225CBD921B98}</Project>
<Name>Newtonsoft.Json.MonoDroid</Name>
</ProjectReference>
- <ProjectReference Include="..\..\PubNub_Messaging\PubNub_Messaging.csproj">
+ <ProjectReference Include="..\..\PubNub_Messaging\PubNubMessaging.csproj">
<Project>{F1BE10BB-84AE-42A0-895A-8A7918F87A28}</Project>
- <Name>PubNub_Messaging</Name>
+ <Name>PubNubMessaging</Name>
</ProjectReference>
</ItemGroup>
</Project>
View
103 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/Common.cs
@@ -1,108 +1,43 @@
using System;
-using PubNub_Messaging;
using System.Collections.Generic;
using System.ComponentModel;
+using PubNubMessaging.Core;
-namespace PubNubTest
+namespace PubNubMessaging.Tests
{
public class Common
{
- public object objResponse = null;
- public bool deliveryStatus = false;
+ public object Response { get; set; }
+ public bool DeliveryStatus { get; set; }
+
+ public PubnubUnitTest CreateUnitTestInstance(string testClassName, string testCaseName)
+ {
+ PubnubUnitTest unitTest = new PubnubUnitTest();
+ unitTest.TestClassName = testClassName;
+ unitTest.TestCaseName = testCaseName;
+ return unitTest;
+ }
public void DisplayReturnMessageDummy(object result)
{
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- //ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
//deliveryStatus = true;
//objResponse = result;
}
public void DisplayReturnMessage(object result)
{
- IList<object> message = result as IList<object>;
-
- if (message != null && message.Count >= 2)
- {
- for (int index = 0; index < message.Count; index++)
- {
- //ParseObject(message[index], 1);
- }
- }
- else
- {
- Console.WriteLine("unable to parse data");
- }
- deliveryStatus = true;
- objResponse = result;
- }
-
- void ParseObject(object result, int loop)
- {
- if (result is object[])
- {
- object[] arrResult = (object[])result;
- foreach (object item in arrResult)
- {
- if (!item.GetType().IsGenericType)
- {
- if (!item.GetType().IsArray)
- {
- Console.WriteLine(item.ToString());
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- else
- {
- ParseObject(item, loop + 1);
- }
- }
- }
- else if (result.GetType().IsGenericType && (result.GetType().Name == typeof(Dictionary<,>).Name))
- {
- Dictionary<string, object> itemList = (Dictionary<string, object>)result;
- foreach (KeyValuePair<string, object> pair in itemList)
- {
- Console.WriteLine(string.Format("key = {0}", pair.Key));
- if (pair.Value is object[])
- {
- Console.WriteLine("value = ");
- ParseObject(pair.Value, loop);
- }
- else
- {
- Console.WriteLine(string.Format("value = {0}", pair.Value));
- }
- }
- }
- else
- {
- Console.WriteLine(result.ToString());
- }
+ DeliveryStatus = true;
+ Response = result;
}
public long Timestamp(Pubnub pubnub)
{
- deliveryStatus = false;
-
- pubnub.time(DisplayReturnMessage);
- while (!deliveryStatus) ;
+ DeliveryStatus = false;
+
+ pubnub.Time(DisplayReturnMessage);
+ while (!DeliveryStatus) ;
- IList<object> fields = objResponse as IList<object>;
+ IList<object> fields = Response as IList<object>;
return Convert.ToInt64(fields[0].ToString());
}
}
View
961 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/EncryptionTests.cs
@@ -1,510 +1,473 @@
using System;
-using PubNub_Messaging;
+using PubNubMessaging.Core;
using NUnit.Framework;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
-using Newtonsoft.Json;
using System.Globalization;
+using Newtonsoft.Json;
-namespace PubNubTest
+namespace PubNubMessaging.Tests
{
- [TestFixture]
- public class EncryptionTests
- {
- /// <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 strMessage= "q/xJqqN6qbiZMXYmiQC1Fw==";
- //decrypt
- string dec = pc.decrypt(strMessage);
- //deserialize again
- Assert.True(("yay!").Equals(dec));
- }
- /// <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 strMessage= "yay!";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
- //Encrypt
- string enc = pc.encrypt(strMessage);
- Assert.True(("q/xJqqN6qbiZMXYmiQC1Fw==").Equals(enc));
- }
- /// <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 strMessage= "\"Wi24KS4pcTzvyuGOHubiXg==\"";
- //Deserialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.DeserializeObject<string>(strMessage);
- //decrypt
- string dec = pc.decrypt(strMessage);
- //deserialize again
- strMessage= JsonConvert.DeserializeObject<string>(dec);
- Assert.True(("yay!" ).Equals( strMessage));
- }
- /// <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 strMessage= "yay!";
- //serialize the string
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
- //Encrypt
- string enc = pc.encrypt(strMessage);
- Assert.True(("Wi24KS4pcTzvyuGOHubiXg==" ).Equals( enc));
- /*PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage= "yay!";
- JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= js.Serialize(strMessage);
- string enc = pc.encrypt(strMessage);*/
-
- //Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", 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 [] objArr = {};
- //pubnub.publish(channel, objArr, Common.DisplayReturnMessage);
- //serialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string strArr = JsonConvert.SerializeObject(objArr);
- //Encrypt
- string enc = pc.encrypt(strArr);
-
- Assert.True(("Ns4TB41JjT2NCXaGLWSPAQ==" ).Equals( enc));
- }
-
- /// <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 strMessage= "Ns4TB41JjT2NCXaGLWSPAQ==";
- //decrypt
- string dec = pc.decrypt(strMessage);
- //create a serialized object
- object [] objArr = {};
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string res = JsonConvert.SerializeObject(objArr);
- //compare the serialized object and the return of the Decrypt method
- Assert.True(res.Equals(dec));
- }
-
- /// <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();
- //pubnub.publish(channel, obj, Common.DisplayReturnMessage);
- //serialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string strObj = JsonConvert.SerializeObject(obj);
- //encrypt
- string enc = pc.encrypt(strObj);
-
- Assert.True(("IDjZE9BHSjcX67RddfCYYg==" ).Equals( enc));
- }
- /// <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 strMessage= "IDjZE9BHSjcX67RddfCYYg==";
- //Decrypt
- string dec = pc.decrypt(strMessage);
- //create an object
- Object obj = new Object();
- //Serialize the object
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string res = JsonConvert.SerializeObject(obj);
-
- Assert.True(dec.Equals(res));
- }
- /// <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();
- //pubnub.publish(channel, cc, Common.DisplayReturnMessage);
- //serialize it
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string res = JsonConvert.SerializeObject(cc);
- //encrypt it
- string enc = pc.encrypt(res);
-
- Assert.True(("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=").Equals(enc));
- }
- /// <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 strMessage= "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
- //Decrypt
- string dec = pc.decrypt(strMessage);
- //create an object of the custom class
- CustomClass cc = new CustomClass();
- //JavaScriptSerializer js = new JavaScriptSerializer();
- //Serialize it
- string res = JsonConvert.SerializeObject(cc);
-
- Assert.True(dec.Equals(res));
- }
-
- /// <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 strMessage= "Pubnub Messaging API 2";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
- //serialize the message
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
- //encrypt
- string enc = pc.encrypt(strMessage);
-
- Assert.True(("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=").Equals(enc));
- }
-
- /// <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 strMessage= "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
- //Decrypt
- string dec = pc.decrypt(strMessage);
- //Deserialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.DeserializeObject<string>(dec);
- Assert.True(("Pubnub Messaging API 2").Equals(strMessage));
- }
-
- /// <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 strMessage= "Pubnub Messaging API 1";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
- //serialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
- //encrypt
- string enc = pc.encrypt(strMessage);
-
- Assert.True(("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=").Equals(enc));
- }
-
- /// <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 strMessage= "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
- //JavaScriptSerializer js = new JavaScriptSerializer();
- //decrypt
- string dec = pc.decrypt(strMessage);
- //deserialize
- strMessage= JsonConvert.DeserializeObject<string>(dec);
- Assert.True(("Pubnub Messaging API 1").Equals(strMessage));
- }
-
- /// <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 strMessage= "{\"this stuff\":{\"can get\":\"complicated!\"}}";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
- //encrypt
- string enc = pc.encrypt(strMessage);
-
- Assert.True(("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF").Equals(enc));
- }
-
- /// <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 strMessage= "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
- //decrypt
- string dec = pc.decrypt(strMessage);
-
- Assert.True(("{\"this stuff\":{\"can get\":\"complicated!\"}}").Equals(dec));
- }
-
- /// <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 strMessage= "{\"foo\":{\"bar\":\"foobar\"}}";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
- //encrypt
- string enc = pc.encrypt(strMessage);
-
- Assert.True(("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=").Equals(enc));
- }
-
- /// <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 strMessage= "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
- //decrypt
- string dec = pc.decrypt(strMessage);
-
- Assert.True(("{\"foo\":{\"bar\":\"foobar\"}}").Equals(dec));
- }
-
- /// <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 strMessage= null;
- //encrypt
- string enc = pc.encrypt(strMessage);
-
- Assert.True(("").Equals(enc));
- }
-
- /// <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 strMessage= null;
- //decrypt
- string dec = pc.decrypt(strMessage);
-
- Assert.True(("").Equals(dec));
- }
- /// <summary>
- /// Tests the unicode chars encryption.
- /// The input is not serialized
- /// </summary>
- [Test]
- public void TestUnicodeCharsEncryption ()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage= "漢語";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
-
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
- string enc = pc.encrypt(strMessage);
- Console.WriteLine(enc);
- Assert.True(("+BY5/miAA8aeuhVl4d13Kg==").Equals(enc));
- }
- /// <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 strMessage= "+BY5/miAA8aeuhVl4d13Kg==";
- //JavaScriptSerializer js = new JavaScriptSerializer();
- //decrypt
- string dec = pc.decrypt(strMessage);
- //deserialize
- strMessage= JsonConvert.DeserializeObject<string>(dec);
-
- Assert.True(("漢語").Equals(strMessage));
- }
- /// <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 strMessage= "stpgsG1DZZxb44J7mFNSzg==";
- //JavaScriptSerializer js = new JavaScriptSerializer();
- //decrypt
- string dec = pc.decrypt(strMessage);
- //deserialize
- strMessage= JsonConvert.DeserializeObject<string>(dec);
-
- Assert.True(("ÜÖ").Equals(strMessage));
- }
- /// <summary>
- /// Tests the german encryption.
- /// The input is not serialized
- /// </summary>
- [Test]
- public void TestGermanCharsEncryption ()
- {
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage= "ÜÖ";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
-
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
- string enc = pc.encrypt(strMessage);
- Console.WriteLine(enc);
- Assert.True(("stpgsG1DZZxb44J7mFNSzg==").Equals(enc));
- }
-
- 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();
- } );
- }
- }
-
- /// <summary>
- /// Custom class for testing the encryption and decryption
- /// </summary>
- class CustomClass
- {
- public string foo = "hi!";
- public int [] bar = {1, 2, 3, 4, 5};
- }
+ [TestFixture]
+ public class EncryptionTests
+ {
+ /// <summary>
+ /// Tests the yay decryption.
+ /// Assumes that the input message is deserialized
+ /// Decrypted string should match yay!
+ /// </summary>
+ [Test]
+ public void TestYayDecryptionBasic ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "q/xJqqN6qbiZMXYmiQC1Fw==";
+ //decrypt
+ string decrypted = pubnubCrypto.Decrypt(message);
+
+ Assert.True(("yay!").Equals(decrypted));
+ }
+ /// <summary>
+ /// Tests the yay encryption.
+ /// The output is not serialized
+ /// Encrypted string should match q/xJqqN6qbiZMXYmiQC1Fw==
+ /// </summary>
+ [Test]
+ public void TestYayEncryptionBasic ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //deserialized string
+ string message= "yay!";
+ //Encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Assert.True(("q/xJqqN6qbiZMXYmiQC1Fw==").Equals(encrypted));
+ }
+ /// <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 pubnubCrypto = new PubnubCrypto("enigma");
+ //Non deserialized string
+ string message= "\"Wi24KS4pcTzvyuGOHubiXg==\"";
+ //Deserialize
+ message= JsonConvert.DeserializeObject<string>(message);
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //deserialize again
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+ Assert.True(("yay!").Equals(message));
+ }
+ /// <summary>
+ /// Tests the yay encryption.
+ /// The output is not serialized
+ /// Encrypted string should match Wi24KS4pcTzvyuGOHubiXg==
+ /// </summary>
+ [Test]
+ public void TestYayEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //deserialized string
+ string message= "yay!";
+ //serialize the string
+ message= JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ //Encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Assert.True(("Wi24KS4pcTzvyuGOHubiXg==").Equals(encrypted));
+ }
+
+ /// <summary>
+ /// Tests the array encryption.
+ /// The output is not serialized
+ /// Encrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestArrayEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //create an empty array object
+ object [] objArr = {};
+ string strArr = JsonConvert.SerializeObject(objArr);
+ //Encrypt
+ string encrypted= pubnubCrypto.Encrypt(strArr);
+
+ Assert.True (("Ns4TB41JjT2NCXaGLWSPAQ==").Equals(encrypted));
+ }
+
+ /// <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 pubnubCrypto = new PubnubCrypto("enigma");
+ //Input the deserialized string
+ string message= "Ns4TB41JjT2NCXaGLWSPAQ==";
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //create a serialized object
+ object [] objArr = {};
+ string result= JsonConvert.SerializeObject(objArr);
+ //compare the serialized object and the return of the Decrypt method
+ Assert.True(result.Equals(decrypted));
+ }
+
+ /// <summary>
+ /// Tests the object encryption.
+ /// The output is not serialized
+ /// Encrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestObjectEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //create an object
+ Object obj = new Object();
+ //serialize
+ string strObj = JsonConvert.SerializeObject(obj);
+ //encrypt
+ string encrypted= pubnubCrypto.Encrypt(strObj);
+
+ Assert.True (("IDjZE9BHSjcX67RddfCYYg==").Equals(encrypted));
+ }
+ /// <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 pubnubCrypto = new PubnubCrypto("enigma");
+ //Deserialized
+ string message= "IDjZE9BHSjcX67RddfCYYg==";
+ //Decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //create an object
+ Object obj = new Object();
+ //Serialize the object
+ string result= JsonConvert.SerializeObject(obj);
+
+ Assert.True(decrypted.Equals(result));
+ }
+ /// <summary>
+ /// Tests my object encryption.
+ /// The output is not serialized
+ /// Encrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestMyObjectEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //create an object of the custom class
+ CustomClass cc = new CustomClass();
+ //serialize it
+ string result= JsonConvert.SerializeObject(cc);
+ //encrypt it
+ string encrypted= pubnubCrypto.Encrypt(result);
+
+ Assert.True (("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=").Equals(encrypted));
+ }
+ /// <summary>
+ /// Tests my object decryption.
+ /// The output is not deserialized
+ /// Decrypted string should match the serialized object
+ /// </summary>
+ [Test]
+ public void TestMyObjectDecryption()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //Deserialized
+ string message= "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
+ //Decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //create an object of the custom class
+ CustomClass cc = new CustomClass();
+ //Serialize it
+ string result= JsonConvert.SerializeObject(cc);
+
+ Assert.True(decrypted.Equals(result));
+ }
+
+ /// <summary>
+ /// Tests the pub nub encryption2.
+ /// The output is not serialized
+ /// Encrypted string should match f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=
+ /// </summary>
+ [Test]
+ public void TestPubNubEncryption2 ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //Deserialized
+ string message= "Pubnub Messaging API 2";
+ //serialize the message
+ message= JsonConvert.SerializeObject(message);
+ //encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+
+ Assert.True(("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=").Equals(encrypted));
+ }
+
+ /// <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 pubnubCrypto = new PubnubCrypto("enigma");
+ //Deserialized string
+ string message= "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
+ //Decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //Deserialize
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+ Assert.True(("Pubnub Messaging API 2").Equals(message));
+ }
+
+ /// <summary>
+ /// Tests the pub nub encryption1.
+ /// The input is not serialized
+ /// Encrypted string should match f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=
+ /// </summary>
+ [Test]
+ public void TestPubNubEncryption1 ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //non serialized string
+ string message= "Pubnub Messaging API 1";
+ //serialize
+ message= JsonConvert.SerializeObject(message);
+ //encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+
+ Assert.True(("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=").Equals(encrypted));
+ }
+
+ /// <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 pubnubCrypto = new PubnubCrypto("enigma");
+ //deserialized string
+ string message= "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //deserialize
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+ Assert.True (("Pubnub Messaging API 1").Equals(message));
+ }
+
+ /// <summary>
+ /// Tests the stuff can encryption.
+ /// The input is serialized
+ /// Encrypted string should match zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF
+ /// </summary>
+ [Test]
+ public void TestStuffCanEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //input serialized string
+ string message= "{\"this stuff\":{\"can get\":\"complicated!\"}}";
+ //encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+
+ Assert.True (("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF").Equals(encrypted));
+ }
+
+ /// <summary>
+ /// Tests the stuffcan decryption.
+ /// Assumes that the input message is deserialized
+ /// </summary>
+ [Test]
+ public void TestStuffcanDecryption()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //deserialized string
+ string message= "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+
+ Assert.True (("{\"this stuff\":{\"can get\":\"complicated!\"}}").Equals(decrypted));
+ }
+
+ /// <summary>
+ /// Tests the hash encryption.
+ /// The input is serialized
+ /// Encrypted string should match GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=
+ /// </summary>
+ [Test]
+ public void TestHashEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //serialized string
+ string message= "{\"foo\":{\"bar\":\"foobar\"}}";
+ //encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+
+ Assert.True (("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=").Equals(encrypted));
+ }
+
+ /// <summary>
+ /// Tests the hash decryption.
+ /// Assumes that the input message is deserialized
+ /// </summary>
+ [Test]
+ public void TestHashDecryption()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //deserialized string
+ string message= "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+
+ Assert.True (("{\"foo\":{\"bar\":\"foobar\"}}").Equals(decrypted));
+ }
+
+ /// <summary>
+ /// Tests the null encryption.
+ /// The input is serialized
+ /// </summary>
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void TestNullEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //serialized string
+ string message= null;
+ //encrypt
+ string encrypted= pubnubCrypto.Encrypt(message);
+
+ Assert.True (("").Equals(encrypted));
+ }
+
+ /// <summary>
+ /// Tests the null decryption.
+ /// Assumes that the input message is deserialized
+ /// </summary>
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void TestNullDecryption()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ //deserialized string
+ string message= null;
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+
+ Assert.True(("").Equals(decrypted));
+ }
+ /// <summary>
+ /// Tests the unicode chars encryption.
+ /// The input is not serialized
+ /// </summary>
+ [Test]
+ public void TestUnicodeCharsEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "漢語";
+ message= JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Console.WriteLine(encrypted);
+ Assert.True (("+BY5/miAA8aeuhVl4d13Kg==").Equals(encrypted));
+ }
+ /// <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 pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "+BY5/miAA8aeuhVl4d13Kg==";
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //deserialize
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+
+ Assert.True(("漢語").Equals(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 pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "stpgsG1DZZxb44J7mFNSzg==";
+ //decrypt
+ string decrypted= pubnubCrypto.Decrypt(message);
+ //deserialize
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+
+ Assert.True (("ÜÖ").Equals(message));
+ }
+ /// <summary>
+ /// Tests the german encryption.
+ /// The input is not serialized
+ /// </summary>
+ [Test]
+ public void TestGermanCharsEncryption ()
+ {
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "ÜÖ";
+ message= JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Console.WriteLine(encrypted);
+ Assert.True (("stpgsG1DZZxb44J7mFNSzg==").Equals(encrypted));
+ }
+
+ static string EncodeNonAsciiCharacters( string value ) {
+ StringBuilder encodedString = new StringBuilder();
+ foreach( char c in value ) {
+ if( c > 127 ) {
+ // This character is too big for ASCII
+ string encodedValue = "\\u" + ((int) c).ToString( "x4" );
+ encodedString.Append( encodedValue );
+ }
+ else {
+ encodedString.Append( c );
+ }
+ }
+ return encodedString.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();
+ } );
+ }
+ }
+
+ /// <summary>
+ /// Custom class for testing the encryption and decryption
+ /// </summary>
+ class CustomClass
+ {
+ public string foo = "hi!";
+ public int [] bar = {1, 2, 3, 4, 5};
+ }
}
View
2  mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/MainActivity.cs
@@ -31,7 +31,7 @@ protected override void OnCreate (Bundle bundle)
// tests can be inside the main assembly
Add (Assembly.GetExecutingAssembly ());
// or in any reference assemblies
- //Add (typeof (PubNubTest.EncryptionTests).Assembly);
+ //Add (typeof (PubNubMessaging.Core.EncryptionTests).Assembly);
// or in any assembly that you load (since JIT is available)
#if false
View
986 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/PubnubUnitTest.cs
@@ -2,504 +2,506 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using PubNub_Messaging;
+using PubNubMessaging.Core;
-namespace PubNubTest
+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> Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessageCipher()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
+ public class PubnubUnitTest : IPubnubUnitTest
+ {
+ private bool enableStubTest = false;
+ private string testClassName = "";
+ private string testCaseName = "";
+
+ public bool EnableStubTest
+ {
+ get
+ {
+ return enableStubTest;
+ }
+ set
+ {
+ enableStubTest = value;
+ }
+ }
+
+ private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessageCipher()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
#else
- data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
-
+ data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
+
#endif
- data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessage()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
- data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"demo test for stubs\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"demo test for stubs\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
#else
- data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"demo test for stubs\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/0", "[[],\"13559007117760880\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"eb4c1645-1319-4425-865f-008563009d67\", \"occupancy\": 1}],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world-pnpres/0/13559011560379628", "[[],\"13559011560379628\"]");
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"demo test for stubs\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
#endif
- data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAClientIsPresented_IfHereNowIsCalledThenItShouldReturnInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/presence/sub_key/demo/channel/hello_world", "{\"uuids\":[\"eb4c1645-1319-4425-865f-008563009d67\"],\"occupancy\":1}");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenItShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/0/hello_world/0/\"Pubnub API Usage Example\"", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"Pubnub API Usage Example\"],13557486057035336,13559006802662769]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/0/hello_world/0/\"Pubnub Messaging API 1\"", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"Pubnub Messaging API 1\"],13557486057035336,13559006802662769]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/0/hello_world/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/hello_world", "[[{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]}],13557486057035336,13559006802662769]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/0/hello_world/0/%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],13559215464464812,13559215464464812]");
- return data;
- }
-
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenEncryptPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/0/hello_world/0/%22%2BBY5%2FmiAA8aeuhVl4d13Kg%3D%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"+BY5/miAA8aeuhVl4d13Kg==\"],13557486057035336,13559006802662769]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/3f75435fcd800f5d0476fc0fb5b572d1/hello_world/0/%22f42pIQcWZ9zbTbH8cyLwB%2FtdvRxjFLOYcBNMVKeHS54%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\"],13559191494674157,13559191494674157]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenOptionalSecretKeyShouldBeProvidedInConstructor()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/d759c756abbd45a9864adc7f2b91393e/hello_world/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenAMessageIsPublished_IfSSLNotProvidedThenDefaultShouldBeFalse()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/publish/demo/demo/0/hello_world/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistory()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\",\"QByvge9lb/3H008RfX+VRA==\",\"tEJ1HKlGhYklpZqZLUDQjA==\",\"XZGNx138XpiwS5aVESXuYg==\",\"ayWFXhv+qv09Gj+I/ooNQQ==\",\"4N2LhvhnPG3v3bvWuqEb0g==\"],13561926677985130,13561926705714509]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistory()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"],13561931614319981,13561931641037537]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_DetailedHistory_Decrypted_Example()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],13561993102217562,13561993102217562]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_ItShouldReturnDetailedHistory()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"Test message\"],13561916644576302,13561916644576302]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams1()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561997459447496,13561997470537187]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams2()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"QByvge9lb/3H008RfX+VRA==\",\"tEJ1HKlGhYklpZqZLUDQjA==\",\"XZGNx138XpiwS5aVESXuYg==\",\"ayWFXhv+qv09Gj+I/ooNQQ==\",\"4N2LhvhnPG3v3bvWuqEb0g==\"],13561997475925030,13561997486798712]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams3()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561997459447496,13561997470537187]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams1()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561998607085158,13561998618677990]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams2()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"5\",\"6\",\"7\",\"8\",\"9\"],13561998626205890,13561998636560986]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams3()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561998607085158,13561998618677990]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams1()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561885846793689,13561885857459163]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams2()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"QByvge9lb/3H008RfX+VRA==\",\"tEJ1HKlGhYklpZqZLUDQjA==\",\"XZGNx138XpiwS5aVESXuYg==\",\"ayWFXhv+qv09Gj+I/ooNQQ==\",\"4N2LhvhnPG3v3bvWuqEb0g==\"],13561885862589838,13561885872731649]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams3()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561885846793689,13561885857459163]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams1()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561969547888925,13561969560429174]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams2()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"5\",\"6\",\"7\",\"8\",\"9\"],13561969565962377,13561969576984085]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams3()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561969547888925,13561969560429174]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReturnsRecords()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"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]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReverseTrueReturnsRecords()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"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]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenDetailedHistoryIsRequested_DetailedHistoryStartWithReverseTrue()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"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/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%200%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%201%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%202%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%203%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%204%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%205%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%206%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%207%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%208%22", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%209%22", "[1,\"Sent\",\"13559014566792817\"]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenGetRequestServerTime_ThenItShouldReturnTimeStamp()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/time/0", "[13559011090230537]");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessageCipher()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/\"f7wNXpx8Ys8pVJNR5ZHT9g==\"", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessage()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"Test Message\"],\"13559014566792816\"]");
- data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
- data.Add("/publish/demo/demo/0/hello_world/0/\"Test Message\"", "[1,\"Sent\",\"13559014566792817\"]");
- data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
- return data;
- }
-
- private Dictionary<string, string> Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnConnectStatus()
- {
- Dictionary<string, string> data = new Dictionary<string, string>();
- data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
- data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[],\"13559006802662768\"]");
- data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
- return data;
- }
-
- public string GetStubResponse(Uri request)
- {
- Dictionary<string,string> respDic = null;
- string response = "!! Stub Response Not Assigned !!";
- string lookUpString = request.PathAndQuery;
- switch (_testClassName)
- {
- case "WhenAClientIsPresented":
- switch (_testCaseName)
- {
- case "ThenPresenceShouldReturnReceivedMessage":
- respDic = Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessage();
- break;
- case "ThenPresenceShouldReturnReceivedMessageCipher":
- respDic = Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessageCipher();
- break;
- case "IfHereNowIsCalledThenItShouldReturnInfo":
- respDic = Load_WhenAClientIsPresented_IfHereNowIsCalledThenItShouldReturnInfo();
- break;
- default:
- break;
- }
- break;
- case "WhenAMessageIsPublished":
- switch (_testCaseName)
- {
- case "ThenItShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenItShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenEncryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenEncryptPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
- break;
- case "ThenOptionalSecretKeyShouldBeProvidedInConstructor":
- respDic = Load_WhenAMessageIsPublished_ThenOptionalSecretKeyShouldBeProvidedInConstructor();
- break;
- case "IfSSLNotProvidedThenDefaultShouldBeFalse":
- respDic = Load_WhenAMessageIsPublished_IfSSLNotProvidedThenDefaultShouldBeFalse();
- break;
- default:
- break;
- }
- break;
- case "WhenDetailedHistoryIsRequested":
- switch (_testCaseName)
- {
-
- case "DetailedHistory_Decrypted_Example":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailedHistory_Decrypted_Example();
- break;
- case "TestUnencryptedSecretDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams1();
- break;
- case "TestUnencryptedSecretDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams2();
- break;
- case "TestUnencryptedSecretDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams3();
- break;
- case "TestEncryptedSecretDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams1();
- break;
- case "TestEncryptedSecretDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams2();
- break;
- case "TestEncryptedSecretDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams3();
- break;
- case "TestUnencryptedDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams1();
- break;
- case "TestUnencryptedDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams2();
- break;
- case "TestUnencryptedDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams3();
- break;
- case "TestEncryptedDetailedHistory":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistory();
- break;
- case "TestUnencryptedDetailedHistory":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistory();
- break;
- case "ItShouldReturnDetailedHistory":
- respDic = Load_WhenDetailedHistoryIsRequested_ItShouldReturnDetailedHistory();
- break;
- case "TestEncryptedDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams1();
- break;
- case "TestEncryptedDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams2();
- break;
- case "TestEncryptedDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams3();
- break;
- case "DetailHistoryCount10ReturnsRecords":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReturnsRecords();
- break;
- case "DetailHistoryCount10ReverseTrueReturnsRecords":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReverseTrueReturnsRecords();
- break;
- case "DetailedHistoryStartWithReverseTrue":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailedHistoryStartWithReverseTrue();
- break;
- default:
- break;
- }
- break;
- case "WhenGetRequestServerTime":
- switch (_testCaseName)
- {
- case "ThenItShouldReturnTimeStamp":
- respDic = Load_WhenGetRequestServerTime_ThenItShouldReturnTimeStamp();
- break;
- default:
- break;
- }
- break;
- case "WhenSubscribedToAChannel":
- switch (_testCaseName)
- {
- case "ThenSubscribeShouldReturnReceivedMessageCipher":
- respDic = Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessageCipher();
- break;
- case "ThenSubscribeShouldReturnReceivedMessage":
- respDic = Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessage();
- break;
- case "ThenSubscribeShouldReturnConnectStatus":
- respDic = Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnConnectStatus();
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- if (respDic != null && respDic.ContainsKey(request.LocalPath))
- {
- response = respDic[request.LocalPath];
- }
-
- return response;
- }
-
- public string TestCaseName
- {
- get
- {
- return _testCaseName;
- }
- set
- {
- _testCaseName = value;
- }
- }
-
-
- public string TestClassName
- {
- get
- {
- return _testClassName;
- }
- set
- {
- _testClassName = value;
- }
- }
- }
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world", "{\"uuids\":[\"eb4c1645-1319-4425-865f-008563009d67\"],\"occupancy\":1}");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenItShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/0/hello_world/0/\"Pubnub API Usage Example\"", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"Pubnub API Usage Example\"],13557486057035336,13559006802662769]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/0/hello_world/0/\"Pubnub Messaging API 1\"", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"Pubnub Messaging API 1\"],13557486057035336,13559006802662769]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/0/hello_world/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/hello_world", "[[{\"foo\":\"hi!\",\"bar\":[1,2,3,4,5]}],13557486057035336,13559006802662769]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/0/hello_world/0/%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],13559215464464812,13559215464464812]");
+ return data;
+ }
+
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/0/hello_world/0/%22%2BBY5%2FmiAA8aeuhVl4d13Kg%3D%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"+BY5/miAA8aeuhVl4d13Kg==\"],13557486057035336,13559006802662769]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/3f75435fcd800f5d0476fc0fb5b572d1/hello_world/0/%22f42pIQcWZ9zbTbH8cyLwB%2FtdvRxjFLOYcBNMVKeHS54%3D%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=\"],13559191494674157,13559191494674157]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/d759c756abbd45a9864adc7f2b91393e/hello_world/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/publish/demo/demo/0/hello_world/0/%22Pubnub%20API%20Usage%20Example%22", "[1,\"Sent\",\"13559014566792817\"]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistory()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\",\"QByvge9lb/3H008RfX+VRA==\",\"tEJ1HKlGhYklpZqZLUDQjA==\",\"XZGNx138XpiwS5aVESXuYg==\",\"ayWFXhv+qv09Gj+I/ooNQQ==\",\"4N2LhvhnPG3v3bvWuqEb0g==\"],13561926677985130,13561926705714509]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistory()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"],13561931614319981,13561931641037537]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailedHistoryDecryptedExample()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],13561993102217562,13561993102217562]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedItShouldReturnDetailedHistory()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"Test message\"],13561916644576302,13561916644576302]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams1()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561997459447496,13561997470537187]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams2()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"QByvge9lb/3H008RfX+VRA==\",\"tEJ1HKlGhYklpZqZLUDQjA==\",\"XZGNx138XpiwS5aVESXuYg==\",\"ayWFXhv+qv09Gj+I/ooNQQ==\",\"4N2LhvhnPG3v3bvWuqEb0g==\"],13561997475925030,13561997486798712]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams3()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561997459447496,13561997470537187]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams1()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561998607085158,13561998618677990]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams2()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"5\",\"6\",\"7\",\"8\",\"9\"],13561998626205890,13561998636560986]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams3()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561998607085158,13561998618677990]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams1()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561885846793689,13561885857459163]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams2()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"QByvge9lb/3H008RfX+VRA==\",\"tEJ1HKlGhYklpZqZLUDQjA==\",\"XZGNx138XpiwS5aVESXuYg==\",\"ayWFXhv+qv09Gj+I/ooNQQ==\",\"4N2LhvhnPG3v3bvWuqEb0g==\"],13561885862589838,13561885872731649]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams3()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"EyKRq4Bzi1V44Lwz9i/cZw==\",\"BIWan5yOqIz3a0hAinJJ9Q==\",\"2x9t3rbm6Jr6YcCCuWCRdQ==\",\"NmPPeaSVnChejVR44rFJ5Q==\",\"y4FSc7Y9IEEoEmtDAJO3FQ==\"],13561885846793689,13561885857459163]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams1()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561969547888925,13561969560429174]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams2()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"5\",\"6\",\"7\",\"8\",\"9\"],13561969565962377,13561969576984085]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams3()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"0\",\"1\",\"2\",\"3\",\"4\"],13561969547888925,13561969560429174]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"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]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"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]");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/v2/history/sub-key/demo/channel/hello_world", "[[\"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/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%200%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%201%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%202%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%203%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%204%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%205%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%206%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%207%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%208%22", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/%22DetailedHistoryStartTimeWithReverseTrue%209%22", "[1,\"Sent\",\"13559014566792817\"]");
+ 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> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessageCipher()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"f7wNXpx8Ys8pVJNR5ZHT9g==\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/\"f7wNXpx8Ys8pVJNR5ZHT9g==\"", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[\"Test Message\"],\"13559014566792816\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559014566792816", "[[],\"13559014566792816\"]");
+ data.Add("/publish/demo/demo/0/hello_world/0/\"Test Message\"", "[1,\"Sent\",\"13559014566792817\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
+ return data;
+ }
+
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus()
+ {
+ Dictionary<string, string> data = new Dictionary<string, string>();
+ data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
+ data.Add("/subscribe/demo/hello_world/0/13559006802662768", "[[],\"13559006802662768\"]");
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
+ return data;
+ }
+
+ public string GetStubResponse(Uri request)
+ {
+ Dictionary<string,string> responseDictionary = null;
+ string response = "!! Stub Response Not Assigned !!";
+
+ //string lookUpString = request.PathAndQuery;
+
+ switch (testClassName)
+ {
+ case "WhenAClientIsPresented":
+ switch (testCaseName)
+ {
+ case "ThenPresenceShouldReturnReceivedMessage":
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage();
+ break;
+ case "ThenPresenceShouldReturnReceivedMessageCipher":
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessageCipher();
+ break;
+ case "IfHereNowIsCalledThenItShouldReturnInfo":
+ responseDictionary = LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo();
+ break;
+ default:
+ break;
+ }
+ break;
+ case "WhenAMessageIsPublished":
+ switch (testCaseName)
+ {
+ case "ThenItShouldReturnSuccessCodeAndInfo":
+ responseDictionary = LoadWhenAMessageIsPublishedThenItShouldReturnSuccessCodeAndInfo();
+ break;
+ 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 "DetailedHistoryDecryptedExample":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailedHistoryDecryptedExample();
+ break;
+ case "TestUnencryptedSecretDetailedHistoryParams1":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams1();
+ break;
+ case "TestUnencryptedSecretDetailedHistoryParams2":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams2();
+ break;
+ case "TestUnencryptedSecretDetailedHistoryParams3":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams3();
+ break;
+ case "TestEncryptedSecretDetailedHistoryParams1":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams1();
+ break;
+ case "TestEncryptedSecretDetailedHistoryParams2":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams2();
+ break;
+ case "TestEncryptedSecretDetailedHistoryParams3":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams3();
+ break;
+ case "TestUnencryptedDetailedHistoryParams1":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams1();
+ break;
+ case "TestUnencryptedDetailedHistoryParams2":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams2();
+ break;
+ case "TestUnencryptedDetailedHistoryParams3":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams3();
+ break;
+ case "TestEncryptedDetailedHistory":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistory();
+ break;
+ case "TestUnencryptedDetailedHistory":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistory();
+ break;
+ case "ItShouldReturnDetailedHistory":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedItShouldReturnDetailedHistory();
+ break;
+ case "TestEncryptedDetailedHistoryParams1":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams1();
+ break;
+ case "TestEncryptedDetailedHistoryParams2":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams2();
+ break;
+ case "TestEncryptedDetailedHistoryParams3":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams3();
+ break;
+ 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;
+ default:
+ break;
+ }
+ break;
+ case "WhenSubscribedToAChannel":
+ switch (testCaseName)
+ {
+ case "ThenSubscribeShouldReturnReceivedMessageCipher":
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessageCipher();
+ break;
+ case "ThenSubscribeShouldReturnReceivedMessage":
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage();
+ break;
+ case "ThenSubscribeShouldReturnConnectStatus":
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus();
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (responseDictionary != null && responseDictionary.ContainsKey(request.LocalPath))
+ {
+ response = responseDictionary[request.LocalPath];
+ }
+
+ return response;
+ }
+
+ public string TestCaseName
+ {
+ get
+ {
+ return testCaseName;
+ }
+ set
+ {
+ testCaseName = value;
+ }
+ }
+
+
+ public string TestClassName
+ {
+ get
+ {
+ return testClassName;
+ }
+ set
+ {
+ testClassName = value;
+ }
+ }
+ }
}
View
135 mono-for-android/3.3.0.1/Pubnub-Messaging/Andr.Unit-master/Andr.Unit/WhenAClientIsPresented.cs
@@ -1,14 +1,14 @@
using System;
-using PubNub_Messaging;
using NUnit.Framework;
using System.ComponentModel;
using System.Collections.Generic;
+using PubNubMessaging.Core;
-namespace PubNubTest
+namespace PubNubMessaging.Tests
{
[TestFixture]
- public class WhenAClientIsPresented
+ public class WhenAClientIsPresented
{
[Test]
public void ThenItShouldReturnReceivedMessage()
@@ -21,35 +21,32 @@ public void ThenItShouldReturnReceivedMessage()
false
);
string channel = "hello_world";
- Common cm = new Common();
- cm.deliveryStatus = false;
- cm.objResponse = null;
+ Common common = new Common();
+ common.DeliveryStatus = false;
+ common.Response = null;
- PubnubUnitTest unitTest = new PubnubUnitTest();
- unitTest.TestClassName = "WhenAClientIsPresented";
- unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
- pubnub.PubnubUnitTest = unitTest;
+ pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnReceivedMessage");
- pubnub.presence(channel, cm.DisplayReturnMessage);
+ pubnub.Presence(channel, common.DisplayReturnMessage);
//while (!cm.deliveryStatus) ;
- //cm.objResponse = null;
- pubnub.subscribe(channel, cm.DisplayReturnMessageDummy);
- while (!cm.deliveryStatus) ;
+ //cm.response = null;
+ pubnub.Subscribe(channel, common.DisplayReturnMessageDummy);
+ while (!common.DeliveryStatus) ;
- string strResponse = "";
- if (cm.objResponse.Equals (null)) {
+ string response = "";
+ if (common.Response.Equals (null)) {
Assert.Fail("Null