Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

speed meter implementation in MonoTouch and monoformac

  • Loading branch information...
commit 64f0ccb9ce187b5c96cbdc4ece0fee7b20988f35 1 parent 79be361
@crimsonred crimsonred authored
Showing with 4,938 additions and 4,723 deletions.
  1. +1 −1  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/AssemblyInfo.cs
  2. +1 −1  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Messaging.csproj
  3. +731 −549 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub.cs
  4. +356 −0 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubExample.cs
  5. +0 −185 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub_Example.cs
  6. +5 −3 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/app.config
  7. +18 −19 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Messaging.userprefs
  8. +1 −1  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/AssemblyInfo.cs
  9. +19 −84 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/Common.cs
  10. +120 −158 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/EncryptionTests.cs
  11. +134 −107 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/PubnubUnitTest.cs
  12. +112 −92 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs
  13. +35 −38 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAMessageIsPublished.cs
  14. +472 −1,009 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenDetailedHistoryIsRequested.cs
  15. +14 −18 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenGetRequestServerTime.cs
  16. +34 −39 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenSubscribedToAChannel.cs
  17. +5 −3 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/app.config
  18. +18 −83 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/Common.cs
  19. +448 −486 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/EncryptionTests.cs
  20. +117 −90 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/PubnubUnitTest.cs
  21. +104 −83 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenAClientIsPresented.cs
  22. +35 −38 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenAMessageIsPublished.cs
  23. +305 −841 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenDetailedHistoryIsRequested.cs
  24. +14 −18 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenGetRequestServerTime.cs
  25. +28 −34 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.Tests/WhenSubscribedToAChannel.cs
  26. +9 −5 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging.userprefs
  27. +0 −59 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/CustomMultilineElement.cs
  28. +40 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/GraphHeader.cs
  29. +206 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/GraphHeaderView.cs
  30. +39 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/PerformanceHeader.cs
  31. +63 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/PerformanceHeaderView.cs
  32. +7 −1 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub-Messaging.csproj
  33. +725 −546 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub.cs
  34. +128 −7 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingMain.cs
  35. +309 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingSpeedTest.cs
  36. +126 −125 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/Pubnub_MessagingSub.cs
  37. +37 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/SdHeader.cs
  38. +122 −0 monotouch/3.3.0.1/Pubnub-Messaging/Pubnub-Messaging/SdHeaderView.cs
View
2  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/AssemblyInfo.cs
@@ -4,7 +4,7 @@
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
-[assembly: AssemblyTitle("PubNub-Console")]
+[assembly: AssemblyTitle("PubNub-Messaging")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
View
2  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubNub-Messaging.csproj
@@ -47,7 +47,7 @@
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Pubnub.cs" />
- <Compile Include="Pubnub_Example.cs" />
+ <Compile Include="PubnubExample.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
View
1,280 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub.cs
731 additions, 549 deletions not shown
View
356 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/PubnubExample.cs
@@ -0,0 +1,356 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.ComponentModel;
+using System.Threading;
+using System.Collections;
+using System.Diagnostics;
+
+namespace PubNubMessaging.Core
+{
+ public class PubnubExample
+ {
+ static public Pubnub pubnub;
+
+ static public bool deliveryStatus = false;
+ static public string channel = "";
+ static public long startTime;
+
+ static bool runSpeedtest = false;
+ static List<double> speedTestValues;
+ static Thread speedTestThread;
+
+ static int consoleLeft;
+
+ static int consoleTop;
+
+ static public void Main()
+ {
+ PubnubProxy proxy = null;
+
+ Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
+ Console.WriteLine(" DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
+ Console.WriteLine(" RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
+ Console.WriteLine();
+ Console.WriteLine(" IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
+ Console.WriteLine(" NETWORK ERROR MESSAGE WILL BE SENT");
+ Console.WriteLine();
+
+ Console.WriteLine("ENTER Channel Name");
+ channel = Console.ReadLine();
+
+ Console.WriteLine(string.Format("Channel = {0}",channel));
+ Console.WriteLine();
+
+ Console.WriteLine("Enable SSL? ENTER Y for Yes, else N");
+ string enableSSL = Console.ReadLine();
+ if (enableSSL.Trim().ToLower() == "y")
+ {
+ Console.WriteLine("SSL Enabled");
+ }
+ else
+ {
+ Console.WriteLine("SSL NOT Enabled");
+ }
+ Console.WriteLine();
+
+ Console.WriteLine("ENTER cipher key for encryption feature.");
+ Console.WriteLine("If you don't want to avail at this time, press ENTER.");
+ string cipheryKey = Console.ReadLine();
+ if (cipheryKey.Trim().Length > 0)
+ {
+ Console.WriteLine("Cipher key provided.");
+ }
+ else
+ {
+ Console.WriteLine("No Cipher key provided");
+ }
+ Console.WriteLine();
+
+ pubnub = new Pubnub("demo", "demo", "", cipheryKey,
+ (enableSSL.Trim().ToLower() == "y") ? true : false);
+
+ Console.WriteLine("Use Custom Session UUID? ENTER Y for Yes, else N");
+ string enableCustomUUID = Console.ReadLine();
+ if (enableCustomUUID.Trim().ToLower() == "y")
+ {
+ Console.WriteLine("ENTER Session UUID.");
+ string sessionUUID = Console.ReadLine();
+ pubnub.SessionUUID = sessionUUID;
+ Console.WriteLine("Accepted Custom Session UUID.");
+ }
+ else
+ {
+ Console.WriteLine("Default Session UUID opted.");
+ }
+ Console.WriteLine();
+
+ Console.WriteLine("Proxy Server exists? ENTER Y for Yes, else N");
+ string enableProxy = Console.ReadLine();
+ if (enableProxy.Trim().ToLower() == "y")
+ {
+ bool proxyAccepted = false;
+ while (!proxyAccepted)
+ {
+ Console.WriteLine("ENTER proxy server name or IP.");
+ string proxyServer = Console.ReadLine();
+ Console.WriteLine("ENTER port number of proxy server.");
+ string proxyPort = Console.ReadLine();
+ int port;
+ Int32.TryParse(proxyPort, out port);
+ Console.WriteLine("ENTER user name for proxy server authentication.");
+ string proxyUsername = Console.ReadLine();
+ Console.WriteLine("ENTER password for proxy server authentication.");
+ string proxyPassword = Console.ReadLine();
+
+ proxy = new PubnubProxy();
+ proxy.ProxyServer = proxyServer;
+ proxy.ProxyPort = port;
+ proxy.ProxyUserName = proxyUsername;
+ proxy.ProxyPassword = proxyPassword;
+ try
+ {
+ pubnub.Proxy = proxy;
+ proxyAccepted = true;
+ Console.WriteLine("Proxy details accepted");
+ }
+ catch (MissingFieldException mse)
+ {
+ Console.WriteLine(mse.Message);
+ Console.WriteLine("Please RE-ENTER Proxy Server details.");
+ }
+ }
+ }
+ else
+ {
+ Console.WriteLine("No Proxy");
+ }
+ Console.WriteLine();
+
+ Console.WriteLine("ENTER 1 FOR Subscribe (not implementing connectCallback)");
+ Console.WriteLine("ENTER 2 FOR Subscribe (implementing connectCallback)");
+ Console.WriteLine("ENTER 3 FOR Publish");
+ Console.WriteLine("ENTER 4 FOR Presence");
+ Console.WriteLine("ENTER 5 FOR Detailed History");
+ Console.WriteLine("ENTER 6 FOR Here_Now");
+ Console.WriteLine("ENTER 7 FOR Unsubscribe");
+ Console.WriteLine("ENTER 8 FOR Presence-Unsubscribe");
+ Console.WriteLine("ENTER 9 FOR Time");
+ Console.WriteLine("ENTER s FOR Speed Test");
+ Console.WriteLine("ENTER 0 FOR EXIT OR QUIT");
+
+ bool exitFlag = false;
+
+ Console.WriteLine("");
+ while (!exitFlag)
+ {
+ string userinput = Console.ReadLine();
+ switch (userinput)
+ {
+ case "0":
+ exitFlag = true;
+ pubnub.EndPendingRequests();
+ break;
+ case "1":
+ Console.WriteLine("Running subscribe() (not implementing connectCallback)");
+ pubnub.Subscribe<string>(channel, DisplayReturnMessage);
+ break;
+ case "2":
+ Console.WriteLine("Running subscribe() (implementing connectCallback)");
+ pubnub.Subscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage);
+ break;
+ case "3":
+ Console.WriteLine("Running publish()");
+ Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
+ string publishMsg = Console.ReadLine();
+ double doubleData;
+ int intData;
+
+ if (int.TryParse(publishMsg, out intData)) //capture numeric data
+ {
+ pubnub.Publish<string>(channel, intData, DisplayReturnMessage);
+ }
+ else if (double.TryParse(publishMsg, out doubleData)) //capture numeric data
+ {
+ pubnub.Publish<string>(channel, doubleData, DisplayReturnMessage);
+ }
+ else
+ {
+ //check whether any numeric is sent in double quotes
+ if (publishMsg.IndexOf("\"") == 0 && publishMsg.LastIndexOf("\"") == publishMsg.Length - 1)
+ {
+ string strMsg = publishMsg.Substring(1, publishMsg.Length - 2);
+ if (int.TryParse(strMsg, out intData))
+ {
+ pubnub.Publish<string>(channel, strMsg, DisplayReturnMessage);
+ }
+ else if (double.TryParse(strMsg, out doubleData))
+ {
+ pubnub.Publish<string>(channel, strMsg, DisplayReturnMessage);
+ }
+ else
+ {
+ pubnub.Publish<string>(channel, publishMsg, DisplayReturnMessage);
+ }
+ }
+ else
+ {
+ pubnub.Publish<string>(channel, publishMsg, DisplayReturnMessage);
+ }
+ }
+ break;
+ case "4":
+ Console.WriteLine("Running presence()");
+ pubnub.Presence<string>(channel, DisplayReturnMessage);
+ break;
+ case "5":
+ Console.WriteLine("Running detailed history()");
+ pubnub.DetailedHistory<string>(channel, 100, DisplayReturnMessage);
+ break;
+ case "6":
+ Console.WriteLine("Running Here_Now()");
+ pubnub.HereNow<string>(channel, DisplayReturnMessage);
+ break;
+ case "7":
+ Console.WriteLine("Running unsubscribe()");
+ pubnub.Unsubscribe<string>(channel, DisplayReturnMessage);
+ break;
+ case "8":
+ Console.WriteLine("Running presence-unsubscribe()");
+ pubnub.PresenceUnsubscribe<string>(channel, DisplayReturnMessage);
+ break;
+ case "9":
+ Console.WriteLine("Running time()");
+ pubnub.Time<string>(DisplayReturnMessage);
+ break;
+ case "s":
+ case "S":
+ Console.WriteLine("Running speed test. Enter 'q' to end the speed test");
+ LaunchSpeedTest();
+ break;
+ case "q":
+ case "Q":
+ Console.WriteLine("Ending speed test");
+ runSpeedtest = false;
+ if((speedTestThread!=null) && (speedTestThread.IsAlive))
+ {
+ speedTestThread.Join(1000);
+ }
+ if(speedTestValues!=null)
+ {
+ speedTestValues.Clear();
+ }
+
+ break;
+ default:
+ Console.WriteLine("INVALID CHOICE.");
+ break;
+ }
+ }
+
+ Console.WriteLine("\nPress any key to exit.\n\n");
+ Console.ReadLine();
+ }
+
+ static void LaunchSpeedTest ()
+ {
+ speedTestThread = new Thread(new ParameterizedThreadStart(RunSpeedTest));
+ runSpeedtest = true;
+ pubnub.Unsubscribe<string>(channel, SpeedTestPublishReturnMessage);
+ pubnub.Subscribe<string>(channel, SpeedTestSubscribeReturnMessage);
+ speedTestThread.Name = "Pubnub Speedtest";
+ speedTestThread.Start();
+ }
+
+ static void RunSpeedTest (object obj)
+ {
+ Console.CursorVisible=false;
+ consoleTop = Console.CursorTop;
+ consoleLeft = 0;
+ while (runSpeedtest)
+ {
+ startTime = DateTime.Now.Ticks;
+ pubnub.Publish<string>(channel, "Speed test message", SpeedTestPublishReturnMessage);
+ Thread.Sleep(200);
+ }
+ Console.CursorVisible=true;
+ }
+
+ static void SpeedTestPublishReturnMessage (string result)
+ {
+ //Console.WriteLine(result);
+ }
+
+ static void SpeedTestSubscribeReturnMessage (string result)
+ {
+ long endTime = DateTime.Now.Ticks;
+ double lag = Math.Round(((endTime - startTime) / 10000f), 2);
+
+ if (lag > 0) {
+ if(speedTestValues == null)
+ speedTestValues = new List<double>();
+
+ speedTestValues.Add (lag);
+ try
+ {
+ double max = Math.Round(speedTestValues.Max (), 2);
+ double min = Math.Round(speedTestValues.Min (), 2);
+ double avg = Math.Round(speedTestValues.Average (), 2);
+
+ int total = speedTestValues.Count;
+ string disp = string.Format ("Total messages: {0}"
+ +", Max: {1} MS, Min: {2} MS, Avg: {3} MS, Curr: {4} MS",
+ total.ToString (), min.ToString (), max.ToString (), avg.ToString ()
+ , lag.ToString ());
+
+ OverwriteConsoleMessage(disp);
+ }
+ catch(Exception ex)
+ {
+ Debug.WriteLine(ex.ToString());
+ }
+ }
+ }
+
+ public static void OverwriteConsoleMessage(string message)
+ {
+ int maxCharacterWidth = Console.WindowWidth - 1;
+ /*int diff = Console.CursorTop - consoleTop;
+ if(diff >= 0)
+ {
+ for(int i=0; i<=diff; i++)
+ {
+ Console.SetCursorPosition(consoleLeft, consoleTop+i);
+ }
+ }*/
+
+ Console.SetCursorPosition(consoleLeft, consoleTop);
+ if (message.Length > maxCharacterWidth)
+ {
+ message = message.Substring(0, maxCharacterWidth - 3) + "...";
+ }
+ message = message + new string(' ', (maxCharacterWidth>message.Length) ? maxCharacterWidth - message.Length: 0);
+ Console.Write (message);
+ }
+
+ /// <summary>
+ /// Callback method captures the response in JSON string format for all operations
+ /// </summary>
+ /// <param name="result"></param>
+ static void DisplayReturnMessage(string result)
+ {
+ Console.WriteLine(result);
+ }
+
+ /// <summary>
+ /// Callback method to provide the connect status of Subscribe call
+ /// </summary>
+ /// <param name="result"></param>
+ static void DisplayConnectStatusMessage(string result)
+ {
+ Console.WriteLine(result);
+ }
+ }
+}
+
View
185 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/Pubnub_Example.cs
@@ -1,185 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.ComponentModel;
-using System.Threading;
-
-namespace PubNub_Messaging
-{
- public class Pubnub_Example
- {
- static public Pubnub pubnub;
-
- static public bool deliveryStatus = false;
- static public string channel = "";
-
- static public void Main()
- {
- Console.WriteLine("HINT: TO TEST RE-CONNECT AND CATCH-UP,");
- Console.WriteLine(" DISCONNECT YOUR MACHINE FROM NETWORK/INTERNET AND ");
- Console.WriteLine(" RE-CONNECT YOUR MACHINE AFTER SOMETIME.");
- Console.WriteLine();
- Console.WriteLine(" IF NO NETWORK BEFORE MAX RE-TRY CONNECT,");
- Console.WriteLine(" NETWORK ERROR MESSAGE WILL BE SENT");
- Console.WriteLine();
-
- Console.WriteLine("ENTER Channel Name");
- channel = Console.ReadLine();
-
- Console.WriteLine(string.Format("Channel = {0}",channel));
- Console.WriteLine();
-
- Console.WriteLine("Enable SSL? ENTER Y for Yes, else N");
- string enableSSL = Console.ReadLine();
- if (enableSSL.Trim().ToLower() == "y")
- {
- Console.WriteLine("SSL Enabled");
- }
- else
- {
- Console.WriteLine("SSL NOT Enabled");
- }
- Console.WriteLine();
-
- Console.WriteLine("ENTER cipher key for encryption feature.");
- Console.WriteLine("If you don't want to avail at this time, press ENTER.");
- string cipheryKey = Console.ReadLine();
- if (cipheryKey.Trim().Length > 0)
- {
- Console.WriteLine("Cipher key provided.");
- }
- else
- {
- Console.WriteLine("No Cipher key provided");
- }
- Console.WriteLine();
-
- pubnub = new Pubnub("demo", "demo", "", cipheryKey,
- (enableSSL.Trim().ToLower() == "y") ? true : false);
-
- Console.WriteLine("ENTER 1 FOR Subscribe (not implementing connectCallback)");
- Console.WriteLine("ENTER 2 FOR Subscribe (implementing connectCallback)");
- Console.WriteLine("ENTER 3 FOR Publish");
- Console.WriteLine("ENTER 4 FOR Presence");
- Console.WriteLine("ENTER 5 FOR Detailed History");
- Console.WriteLine("ENTER 6 FOR Here_Now");
- Console.WriteLine("ENTER 7 FOR Unsubscribe");
- Console.WriteLine("ENTER 8 FOR Presence-Unsubscribe");
- Console.WriteLine("ENTER 9 FOR Time");
- Console.WriteLine("ENTER 0 FOR EXIT OR QUIT");
-
- bool exitFlag = false;
-
- Console.WriteLine("");
- while (!exitFlag)
- {
- string userinput = Console.ReadLine();
- switch (userinput)
- {
- case "0":
- exitFlag = true;
- pubnub.EndPendingRequests();
- break;
- case "1":
- Console.WriteLine("Running subscribe() (not implementing connectCallback)");
- pubnub.subscribe<string>(channel, DisplayReturnMessage);
- break;
- case "2":
- Console.WriteLine("Running subscribe() (implementing connectCallback)");
- pubnub.subscribe<string>(channel, DisplayReturnMessage, DisplayConnectStatusMessage);
- break;
- case "3":
- Console.WriteLine("Running publish()");
- Console.WriteLine("Enter the message for publish. To exit loop, enter QUIT");
- string publishMsg = Console.ReadLine();
- double doubleData;
- int intData;
- if (int.TryParse(publishMsg, out intData)) //capture numeric data
- {
- pubnub.publish<string>(channel, intData, DisplayReturnMessage);
- }
- else if (double.TryParse(publishMsg, out doubleData)) //capture numeric data
- {
- pubnub.publish<string>(channel, doubleData, DisplayReturnMessage);
- }
- else
- {
- //check whether any numeric is sent in double quotes
- if (publishMsg.IndexOf("\"") == 0 && publishMsg.LastIndexOf("\"") == publishMsg.Length - 1)
- {
- string strMsg = publishMsg.Substring(1, publishMsg.Length - 2);
- if (int.TryParse(strMsg, out intData))
- {
- pubnub.publish<string>(channel, strMsg, DisplayReturnMessage);
- }
- else if (double.TryParse(strMsg, out doubleData))
- {
- pubnub.publish<string>(channel, strMsg, DisplayReturnMessage);
- }
- else
- {
- pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage);
- }
- }
- else
- {
- pubnub.publish<string>(channel, publishMsg, DisplayReturnMessage);
- }
- }
- break;
- case "4":
- Console.WriteLine("Running presence()");
- pubnub.presence<string>(channel, DisplayReturnMessage);
- break;
- case "5":
- Console.WriteLine("Running detailed history()");
- pubnub.detailedHistory<string>(channel, 100, DisplayReturnMessage);
- break;
- case "6":
- Console.WriteLine("Running Here_Now()");
- pubnub.here_now<string>(channel, DisplayReturnMessage);
- break;
- case "7":
- Console.WriteLine("Running unsubscribe()");
- pubnub.unsubscribe<string>(channel, DisplayReturnMessage);
- break;
- case "8":
- Console.WriteLine("Running presence-unsubscribe()");
- pubnub.presence_unsubscribe<string>(channel, DisplayReturnMessage);
- break;
- case "9":
- Console.WriteLine("Running time()");
- pubnub.time<string>(DisplayReturnMessage);
- break;
- default:
- Console.WriteLine("INVALID CHOICE.");
- break;
- }
- }
-
- Console.WriteLine("\nPress any key to exit.\n\n");
- Console.ReadLine();
-
- }
-
- /// <summary>
- /// Callback method captures the response in JSON string format for all operations
- /// </summary>
- /// <param name="result"></param>
- static void DisplayReturnMessage(string result)
- {
- Console.WriteLine(result);
- }
-
- /// <summary>
- /// Callback method to provide the connect status of Subscribe call
- /// </summary>
- /// <param name="result"></param>
- static void DisplayConnectStatusMessage(string result)
- {
- Console.WriteLine(result);
- }
- }
-}
-
View
8 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Console/app.config
@@ -12,8 +12,10 @@
<remove name="Default" />
</listeners>
</trace>
- <switches>
- <add name="PubnubTraceSwitch" value="3" />
- </switches>
</system.diagnostics>
+ <system.net>
+ <connectionManagement>
+ <add address="*" maxconnection="30" />
+ </connectionManagement>
+ </system.net>
</configuration>
View
37 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNub-Messaging.userprefs
@@ -1,18 +1,22 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
- <MonoDevelop.Ide.Workbench ActiveDocument="PubNubTest/PubnubUnitTest.cs">
+ <MonoDevelop.Ide.Workbench ActiveDocument="PubNub-Console/PubnubExample.cs">
<Files>
- <File FileName="PubNub-Console/Pubnub.cs" Line="75" Column="41" />
- <File FileName="PubNub-Console/Pubnub_Example.cs" Line="82" Column="18" />
- <File FileName="PubNub-Console/app.config" Line="4" Column="43" />
- <File FileName="PubNubTest/PubnubUnitTest.cs" Line="18" Column="14" />
+ <File FileName="PubNub-Console/PubnubExample.cs" Line="294" Column="19" />
+ <File FileName="PubNubTest/WhenAClientIsPresented.cs" Line="166" Column="18" />
+ <File FileName="PubNubTest/PubnubUnitTest.cs" Line="519" Column="5" />
+ <File FileName="PubNub-Console/Pubnub.cs" Line="162" Column="5" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
- <Node name="PubNub-Messaging" expanded="True" />
+ <Node name="PubNub-Messaging" expanded="True">
+ <Node name="References" expanded="True" />
+ <Node name="Library" expanded="True" />
+ <Node name="PubnubExample.cs" selected="True" />
+ </Node>
<Node name="PubNub-Messaging.Tests" expanded="True">
- <Node name="PubnubUnitTest.cs" selected="True" />
+ <Node name="References" expanded="True" />
</Node>
</State>
</Pad>
@@ -37,17 +41,7 @@
</State>
</Pad>
<Pad Id="MonoDevelop.NUnit.TestPad">
- <State expanded="True">
- <Node name="PubNub-Messaging.Tests" expanded="True">
- <Node name="PubNubTest" expanded="True">
- <Node name="EncryptionTests" expanded="True" />
- <Node name="WhenAClientIsPresented" expanded="True" />
- <Node name="WhenDetailedHistoryIsRequested" expanded="True" />
- <Node name="WhenGetRequestServerTime" expanded="True" />
- <Node name="WhenSubscribedToAChannel" expanded="True" selected="True" />
- </Node>
- </Node>
- </State>
+ <State expanded="True" selected="True" />
</Pad>
<Pad Id="ConnectionManagerPad">
<State selected="True" />
@@ -55,7 +49,12 @@
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
- <BreakpointStore />
+ <BreakpointStore>
+ <Breakpoint file="/Volumes/Macintosh/Users/rajatkalsy/Projects/Client/ODesk/pubnub/mono-mac-new copy/3.3.0.1/PubNub-Messaging/PubNubTest/Common.cs" line="29" />
+ <Breakpoint file="/Volumes/Macintosh/Users/rajatkalsy/Projects/Client/ODesk/pubnub/mono-mac-new copy/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs" line="162" />
+ <Breakpoint file="/Volumes/Macintosh/Users/rajatkalsy/Projects/Client/ODesk/pubnub/mono-mac-new copy/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs" line="152" />
+ <Breakpoint file="/Volumes/Macintosh/Users/rajatkalsy/Projects/Client/ODesk/pubnub/mono-mac-new copy/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs" line="36" />
+ </BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches>
<Watch file="PubNub-Messaging/Pubnub.cs" line="549" offsetX="648" offsetY="6960" expression="result" liveUpdate="False" />
View
2  mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/AssemblyInfo.cs
@@ -4,7 +4,7 @@
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
-[assembly: AssemblyTitle("PubNubTest")]
+[assembly: AssemblyTitle("PubNubMessaging.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
View
103 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/Common.cs
@@ -1,108 +1,43 @@
using System;
-using PubNub_Messaging;
+using PubNubMessaging.Core;
using System.Collections.Generic;
using System.ComponentModel;
-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;
+ //response = 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;
+ DeliveryStatus = false;
- pubnub.time(DisplayReturnMessage);
- while (!deliveryStatus) ;
+ 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
278 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/EncryptionTests.cs
@@ -1,15 +1,14 @@
using System;
-using PubNub_Messaging;
+using PubNubMessaging.Core;
using NUnit.Framework;
using System.ComponentModel;
using System.Collections.Generic;
-//using System.Web.Script.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using Newtonsoft.Json;
-namespace PubNubTest
+namespace PubNubMessaging.Tests
{
[TestFixture]
public class EncryptionTests
@@ -22,12 +21,12 @@ public class EncryptionTests
[Test]
public void TestYayDecryptionBasic ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage= "q/xJqqN6qbiZMXYmiQC1Fw==";
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "q/xJqqN6qbiZMXYmiQC1Fw==";
//decrypt
- string dec = pc.decrypt(strMessage);
- //deserialize again
- Assert.AreEqual("yay!", dec);
+ string decrypted = pubnubCrypto.Decrypt(message);
+
+ Assert.AreEqual("yay!", decrypted);
}
/// <summary>
/// Tests the yay encryption.
@@ -37,13 +36,12 @@ public void TestYayDecryptionBasic ()
[Test]
public void TestYayEncryptionBasic ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//deserialized string
- string strMessage= "yay!";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
+ string message= "yay!";
//Encrypt
- string enc = pc.encrypt(strMessage);
- Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", enc);
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", encrypted);
}
/// <summary>
/// Tests the yay decryption.
@@ -53,18 +51,16 @@ public void TestYayEncryptionBasic ()
[Test]
public void TestYayDecryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
- //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//Non deserialized string
- string strMessage= "\"Wi24KS4pcTzvyuGOHubiXg==\"";
+ string message= "\"Wi24KS4pcTzvyuGOHubiXg==\"";
//Deserialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.DeserializeObject<string>(strMessage);
+ message= JsonConvert.DeserializeObject<string>(message);
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//deserialize again
- strMessage= JsonConvert.DeserializeObject<string>(dec);
- Assert.AreEqual("yay!", strMessage);
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+ Assert.AreEqual("yay!", message);
}
/// <summary>
/// Tests the yay encryption.
@@ -74,23 +70,15 @@ public void TestYayDecryption ()
[Test]
public void TestYayEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//deserialized string
- string strMessage= "yay!";
+ string message= "yay!";
//serialize the string
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
+ message= JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
//Encrypt
- string enc = pc.encrypt(strMessage);
- Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", 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);
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", encrypted);
}
/// <summary>
@@ -101,17 +89,14 @@ public void TestYayEncryption ()
[Test]
public void TestArrayEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = 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);
+ string encrypted= pubnubCrypto.Encrypt(strArr);
- Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", enc);
+ Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", encrypted);
}
/// <summary>
@@ -123,17 +108,16 @@ public void TestArrayEncryption ()
[Test]
public void TestArrayDecryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//Input the deserialized string
- string strMessage= "Ns4TB41JjT2NCXaGLWSPAQ==";
+ string message= "Ns4TB41JjT2NCXaGLWSPAQ==";
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//create a serialized object
object [] objArr = {};
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string res = JsonConvert.SerializeObject(objArr);
+ string result= JsonConvert.SerializeObject(objArr);
//compare the serialized object and the return of the Decrypt method
- Assert.AreEqual(res, dec);
+ Assert.AreEqual(result, decrypted);
}
/// <summary>
@@ -144,17 +128,15 @@ public void TestArrayDecryption ()
[Test]
public void TestObjectEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = 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);
+ string encrypted= pubnubCrypto.Encrypt(strObj);
- Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", enc);
+ Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", encrypted);
}
/// <summary>
/// Tests the object decryption.
@@ -165,18 +147,17 @@ public void TestObjectEncryption ()
[Test]
public void TestObjectDecryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//Deserialized
- string strMessage= "IDjZE9BHSjcX67RddfCYYg==";
+ string message= "IDjZE9BHSjcX67RddfCYYg==";
//Decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//create an object
Object obj = new Object();
//Serialize the object
- //JavaScriptSerializer js = new JavaScriptSerializer();
- string res = JsonConvert.SerializeObject(obj);
+ string result= JsonConvert.SerializeObject(obj);
- Assert.AreEqual(dec, res);
+ Assert.AreEqual(decrypted, result);
}
/// <summary>
/// Tests my object encryption.
@@ -186,17 +167,15 @@ public void TestObjectDecryption ()
[Test]
public void TestMyObjectEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = 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);
+ string result= JsonConvert.SerializeObject(cc);
//encrypt it
- string enc = pc.encrypt(res);
+ string encrypted= pubnubCrypto.Encrypt(result);
- Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", enc);
+ Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encrypted);
}
/// <summary>
/// Tests my object decryption.
@@ -206,18 +185,17 @@ public void TestMyObjectEncryption ()
[Test]
public void TestMyObjectDecryption()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//Deserialized
- string strMessage= "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
+ string message= "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
//Decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//create an object of the custom class
CustomClass cc = new CustomClass();
- //JavaScriptSerializer js = new JavaScriptSerializer();
//Serialize it
- string res = JsonConvert.SerializeObject(cc);
+ string result= JsonConvert.SerializeObject(cc);
- Assert.AreEqual(dec, res);
+ Assert.AreEqual(decrypted, result);
}
/// <summary>
@@ -228,17 +206,15 @@ public void TestMyObjectDecryption()
[Test]
public void TestPubNubEncryption2 ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//Deserialized
- string strMessage= "Pubnub Messaging API 2";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
+ string message= "Pubnub Messaging API 2";
//serialize the message
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
+ message= JsonConvert.SerializeObject(message);
//encrypt
- string enc = pc.encrypt(strMessage);
+ string encrypted= pubnubCrypto.Encrypt(message);
- Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", enc);
+ Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", encrypted);
}
/// <summary>
@@ -249,15 +225,14 @@ public void TestPubNubEncryption2 ()
[Test]
public void TestPubNubDecryption2 ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//Deserialized string
- string strMessage= "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
+ string message= "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
//Decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//Deserialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.DeserializeObject<string>(dec);
- Assert.AreEqual("Pubnub Messaging API 2", strMessage);
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+ Assert.AreEqual("Pubnub Messaging API 2", message);
}
/// <summary>
@@ -268,17 +243,15 @@ public void TestPubNubDecryption2 ()
[Test]
public void TestPubNubEncryption1 ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//non serialized string
- string strMessage= "Pubnub Messaging API 1";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
+ string message= "Pubnub Messaging API 1";
//serialize
- //JavaScriptSerializer js = new JavaScriptSerializer();
- strMessage= JsonConvert.SerializeObject(strMessage);
+ message= JsonConvert.SerializeObject(message);
//encrypt
- string enc = pc.encrypt(strMessage);
+ string encrypted= pubnubCrypto.Encrypt(message);
- Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", enc);
+ Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", encrypted);
}
/// <summary>
@@ -289,15 +262,14 @@ public void TestPubNubEncryption1 ()
[Test]
public void TestPubNubDecryption1 ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//deserialized string
- string strMessage= "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
- //JavaScriptSerializer js = new JavaScriptSerializer();
+ string message= "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//deserialize
- strMessage= JsonConvert.DeserializeObject<string>(dec);
- Assert.AreEqual("Pubnub Messaging API 1", strMessage);
+ message= JsonConvert.DeserializeObject<string>(decrypted);
+ Assert.AreEqual("Pubnub Messaging API 1", message);
}
/// <summary>
@@ -308,14 +280,13 @@ public void TestPubNubDecryption1 ()
[Test]
public void TestStuffCanEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//input serialized string
- string strMessage= "{\"this stuff\":{\"can get\":\"complicated!\"}}";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
+ string message= "{\"this stuff\":{\"can get\":\"complicated!\"}}";
//encrypt
- string enc = pc.encrypt(strMessage);
+ string encrypted= pubnubCrypto.Encrypt(message);
- Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", enc);
+ Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", encrypted);
}
/// <summary>
@@ -325,13 +296,13 @@ public void TestStuffCanEncryption ()
[Test]
public void TestStuffcanDecryption()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//deserialized string
- string strMessage= "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
+ string message= "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
- Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", dec);
+ Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", decrypted);
}
/// <summary>
@@ -342,14 +313,13 @@ public void TestStuffcanDecryption()
[Test]
public void TestHashEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//serialized string
- string strMessage= "{\"foo\":{\"bar\":\"foobar\"}}";
- //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
+ string message= "{\"foo\":{\"bar\":\"foobar\"}}";
//encrypt
- string enc = pc.encrypt(strMessage);
+ string encrypted= pubnubCrypto.Encrypt(message);
- Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", enc);
+ Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", encrypted);
}
/// <summary>
@@ -359,13 +329,13 @@ public void TestHashEncryption ()
[Test]
public void TestHashDecryption()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//deserialized string
- string strMessage= "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
+ string message= "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
- Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", dec);
+ Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", decrypted);
}
/// <summary>
@@ -376,13 +346,13 @@ public void TestHashDecryption()
[ExpectedException(typeof(ArgumentNullException))]
public void TestNullEncryption ()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//serialized string
- string strMessage= null;
+ string message= null;
//encrypt
- string enc = pc.encrypt(strMessage);
+ string encrypted= pubnubCrypto.Encrypt(message);
- Assert.AreEqual("", enc);
+ Assert.AreEqual("", encrypted);
}
/// <summary>
@@ -393,13 +363,13 @@ public void TestNullEncryption ()
[ExpectedException(typeof(ArgumentNullException))]
public void TestNullDecryption()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
//deserialized string
- string strMessage= null;
+ string message= null;
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
- Assert.AreEqual("", dec);
+ Assert.AreEqual("", decrypted);
}
/// <summary>
/// Tests the unicode chars encryption.
@@ -408,16 +378,13 @@ public void TestNullDecryption()
[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.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", enc);
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "漢語";
+ message= JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Console.WriteLine(encrypted);
+ Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", encrypted);
}
/// <summary>
/// Tests the unicode decryption.
@@ -427,15 +394,14 @@ public void TestUnicodeCharsEncryption ()
[Test]
public void TestUnicodeCharsDecryption()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage= "+BY5/miAA8aeuhVl4d13Kg==";
- //JavaScriptSerializer js = new JavaScriptSerializer();
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "+BY5/miAA8aeuhVl4d13Kg==";
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//deserialize
- strMessage= JsonConvert.DeserializeObject<string>(dec);
+ message= JsonConvert.DeserializeObject<string>(decrypted);
- Assert.AreEqual("漢語", strMessage);
+ Assert.AreEqual("漢語", message);
}
/// <summary>
/// Tests the german chars decryption.
@@ -445,15 +411,14 @@ public void TestUnicodeCharsDecryption()
[Test]
public void TestGermanCharsDecryption()
{
- PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage= "stpgsG1DZZxb44J7mFNSzg==";
- //JavaScriptSerializer js = new JavaScriptSerializer();
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "stpgsG1DZZxb44J7mFNSzg==";
//decrypt
- string dec = pc.decrypt(strMessage);
+ string decrypted= pubnubCrypto.Decrypt(message);
//deserialize
- strMessage= JsonConvert.DeserializeObject<string>(dec);
+ message= JsonConvert.DeserializeObject<string>(decrypted);
- Assert.AreEqual("ÜÖ", strMessage);
+ Assert.AreEqual("ÜÖ", message);
}
/// <summary>
/// Tests the german encryption.
@@ -462,31 +427,28 @@ public void TestGermanCharsDecryption()
[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.AreEqual("stpgsG1DZZxb44J7mFNSzg==", enc);
+ PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
+ string message= "ÜÖ";
+ message= JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encrypted= pubnubCrypto.Encrypt(message);
+ Console.WriteLine(encrypted);
+ Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", encrypted);
}
static string EncodeNonAsciiCharacters( string value ) {
- StringBuilder sb = new StringBuilder();
+ 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" );
- sb.Append( encodedValue );
+ encodedString.Append( encodedValue );
}
else {
- sb.Append( c );
+ encodedString.Append( c );
}
}
- return sb.ToString();
+ return encodedString.ToString();
}
static string DecodeEncodedNonAsciiCharacters( string value ) {
View
241 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/PubnubUnitTest.cs
@@ -2,52 +2,52 @@
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 = false;
- private string _testClassName = "";
- private string _testCaseName = "";
+ private bool enableStubTest = true;
+ private string testClassName = "";
+ private string testCaseName = "";
public bool EnableStubTest
{
get
{
- return _enableStubTest;
+ return enableStubTest;
}
set
{
- _enableStubTest = value;
+ enableStubTest = value;
}
}
- private Dictionary<string, string> Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessageCipher()
+ 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\"]");
-#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\"]");
-
-#endif
- data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
+ #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\"]");
+ #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\"]");
+
+ #endif
+ data.Add("/v2/presence/sub_key/demo/channel/hello_world/leave", "{\"action\": \"leave\"}");
return data;
}
- private Dictionary<string, string> Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessage()
+ private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage()
{
Dictionary<string, string> data = new Dictionary<string, string>();
#if ((!__MonoCS__) && (!SILVERLIGHT) && (!WINDOWS_PHONE))
@@ -69,14 +69,14 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenAClientIsPresented_IfHereNowIsCalledThenItShouldReturnInfo()
+ 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> Load_WhenAMessageIsPublished_ThenItShouldReturnSuccessCodeAndInfo()
+ 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\"]");
@@ -84,7 +84,7 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
+ 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\"]");
@@ -92,7 +92,7 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
+ 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\"]");
@@ -100,7 +100,7 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
+ 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\"]");
@@ -109,7 +109,7 @@ public bool EnableStubTest
}
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenEncryptPublishShouldReturnSuccessCodeAndInfo()
+ 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\"]");
@@ -117,7 +117,7 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
+ 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\"]");
@@ -125,147 +125,147 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenAMessageIsPublished_ThenOptionalSecretKeyShouldBeProvidedInConstructor()
+ 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> Load_WhenAMessageIsPublished_IfSSLNotProvidedThenDefaultShouldBeFalse()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistory()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistory()
+ 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> Load_WhenDetailedHistoryIsRequested_DetailedHistory_Decrypted_Example()
+ 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> Load_WhenDetailedHistoryIsRequested_ItShouldReturnDetailedHistory()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams1()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams2()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams3()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams1()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams2()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams3()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams1()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams2()
+ 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> Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams3()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams1()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams2()
+ 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> Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams3()
+ 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> Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReturnsRecords()
+ 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> Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReverseTrueReturnsRecords()
+ 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> Load_WhenDetailedHistoryIsRequested_DetailedHistoryStartWithReverseTrue()
+ 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]");
@@ -282,14 +282,14 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenGetRequestServerTime_ThenItShouldReturnTimeStamp()
+ private Dictionary<string, string> LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp()
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("/time/0", "[13559011090230537]");
return data;
}
- private Dictionary<string, string> Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessageCipher()
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessageCipher()
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
@@ -300,7 +300,7 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessage()
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage()
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
@@ -311,7 +311,7 @@ public bool EnableStubTest
return data;
}
- private Dictionary<string, string> Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnConnectStatus()
+ private Dictionary<string, string> LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus()
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("/subscribe/demo/hello_world/0/0", "[[],\"13559006802662768\"]");
@@ -320,146 +320,173 @@ public bool EnableStubTest
return data;
}
+ private Dictionary<string, string> LoadWhenAClientIsPresentedThenPresenceShouldReturnCustomUUID()
+ {
+ 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/testChannel/0/13559007117760880", "[[{\"action\": \"join\", \"timestamp\": 1355929955, \"uuid\": \"CustomSessionUUIDTest\", \"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\": \"CustomSessionUUIDTest\", \"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;
+ }
+
public string GetStubResponse(Uri request)
{
- Dictionary<string,string> respDic = null;
+ Dictionary<string,string> responseDictionary = null;
string response = "!! Stub Response Not Assigned !!";
- string lookUpString = request.PathAndQuery;
- switch (_testClassName)
+
+ //string lookUpString = request.PathAndQuery;
+
+ switch (testClassName)
{
case "WhenAClientIsPresented":
- switch (_testCaseName)
+ switch (testCaseName)
{
case "ThenPresenceShouldReturnReceivedMessage":
- respDic = Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessage();
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage();
break;
case "ThenPresenceShouldReturnReceivedMessageCipher":
- respDic = Load_WhenAClientIsPresented_ThenPresenceShouldReturnReceivedMessageCipher();
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessageCipher();
break;
case "IfHereNowIsCalledThenItShouldReturnInfo":
- respDic = Load_WhenAClientIsPresented_IfHereNowIsCalledThenItShouldReturnInfo();
+ responseDictionary = LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo();
+ break;
+ case "ThenPresenceShouldReturnCustomUUID":
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnCustomUUID();
break;
default:
break;
}
break;
case "WhenAMessageIsPublished":
- switch (_testCaseName)
+ switch (testCaseName)
{
case "ThenItShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenItShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenItShouldReturnSuccessCodeAndInfo();
break;
case "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenEncryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenEncryptPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = Load_WhenAMessageIsPublished_ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenOptionalSecretKeyShouldBeProvidedInConstructor":
- respDic = Load_WhenAMessageIsPublished_ThenOptionalSecretKeyShouldBeProvidedInConstructor();
+ responseDictionary = LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor();
break;
case "IfSSLNotProvidedThenDefaultShouldBeFalse":
- respDic = Load_WhenAMessageIsPublished_IfSSLNotProvidedThenDefaultShouldBeFalse();
+ responseDictionary = LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse();
break;
default:
break;
}
break;
case "WhenDetailedHistoryIsRequested":
- switch (_testCaseName)
+ switch (testCaseName)
{
- case "DetailedHistory_Decrypted_Example":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailedHistory_Decrypted_Example();
+ case "DetailedHistoryDecryptedExample":
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailedHistoryDecryptedExample();
break;
case "TestUnencryptedSecretDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams1();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams1();
break;
case "TestUnencryptedSecretDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams2();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams2();
break;
case "TestUnencryptedSecretDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedSecretDetailedHistoryParams3();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedSecretDetailedHistoryParams3();
break;
case "TestEncryptedSecretDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams1();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams1();
break;
case "TestEncryptedSecretDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams2();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams2();
break;
case "TestEncryptedSecretDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedSecretDetailedHistoryParams3();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedSecretDetailedHistoryParams3();
break;
case "TestUnencryptedDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams1();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams1();
break;
case "TestUnencryptedDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams2();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams2();
break;
case "TestUnencryptedDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistoryParams3();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistoryParams3();
break;
case "TestEncryptedDetailedHistory":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistory();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistory();
break;
case "TestUnencryptedDetailedHistory":
- respDic = Load_WhenDetailedHistoryIsRequested_TestUnencryptedDetailedHistory();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestUnencryptedDetailedHistory();
break;
case "ItShouldReturnDetailedHistory":
- respDic = Load_WhenDetailedHistoryIsRequested_ItShouldReturnDetailedHistory();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedItShouldReturnDetailedHistory();
break;
case "TestEncryptedDetailedHistoryParams1":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams1();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams1();
break;
case "TestEncryptedDetailedHistoryParams2":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams2();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams2();
break;
case "TestEncryptedDetailedHistoryParams3":
- respDic = Load_WhenDetailedHistoryIsRequested_TestEncryptedDetailedHistoryParams3();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedTestEncryptedDetailedHistoryParams3();
break;
case "DetailHistoryCount10ReturnsRecords":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReturnsRecords();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords();
break;
case "DetailHistoryCount10ReverseTrueReturnsRecords":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailHistoryCount10ReverseTrueReturnsRecords();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords();
break;
case "DetailedHistoryStartWithReverseTrue":
- respDic = Load_WhenDetailedHistoryIsRequested_DetailedHistoryStartWithReverseTrue();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue();
break;
default:
break;
}
break;
case "WhenGetRequestServerTime":
- switch (_testCaseName)
+ switch (testCaseName)
{
case "ThenItShouldReturnTimeStamp":
- respDic = Load_WhenGetRequestServerTime_ThenItShouldReturnTimeStamp();
+ responseDictionary = LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp();
break;
default:
break;
}
break;
case "WhenSubscribedToAChannel":
- switch (_testCaseName)
+ switch (testCaseName)
{
case "ThenSubscribeShouldReturnReceivedMessageCipher":
- respDic = Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessageCipher();
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessageCipher();
break;
case "ThenSubscribeShouldReturnReceivedMessage":
- respDic = Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnReceivedMessage();
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage();
break;
case "ThenSubscribeShouldReturnConnectStatus":
- respDic = Load_WhenSubscribedToAChannel_ThenSubscribeShouldReturnConnectStatus();
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus();
break;
default:
break;
@@ -469,9 +496,9 @@ public string GetStubResponse(Uri request)
break;
}
- if (respDic != null && respDic.ContainsKey(request.LocalPath))
+ if (responseDictionary != null && responseDictionary.ContainsKey(request.LocalPath))
{
- response = respDic[request.LocalPath];
+ response = responseDictionary[request.LocalPath];
}
return response;
@@ -481,11 +508,11 @@ public string TestCaseName
{
get
{
- return _testCaseName;
+ return testCaseName;
}
set
{
- _testCaseName = value;
+ testCaseName = value;
}
}
@@ -494,11 +521,11 @@ public string TestClassName
{
get
{
- return _testClassName;
+ return testClassName;
}
set
{
- _testClassName = value;
+ testClassName = value;
}
}
}
View
204 mono-for-mac/3.3.0.1/PubNub-Messaging/PubNubTest/WhenAClientIsPresented.cs
@@ -1,11 +1,11 @@
using System;
-using PubNub_Messaging;
+using PubNubMessaging.Core;
using NUnit.Framework;
using System.ComponentModel;
using System.Collections.Generic;
-namespace PubNubTest
+namespace PubNubMessaging.Tests
{
[TestFixture]
public class WhenAClientIsPresented
@@ -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 response");
}
else
{
- IList<object> fields = cm.objResponse as IList<object>;
- foreach (object item in fields)
+ IList<object> responseFields = common.Response as IList<object>;
+ foreach (object item in responseFields)
{
- strResponse = item.ToString();
- Console.WriteLine("Resp:" + strResponse);
+ response = item.ToString();
+ Console.WriteLine("Response:" + response);
//Assert.IsNotEmpty(strResponse);
}
- Assert.AreEqual("hello_world", fields[2]);
+ Assert.AreEqual("hello_world", responseFields[2]);
}
}
@@ -63,45 +60,57 @@ public void IfHereNowIsCalledThenItShouldReturnInfo()
"",
false
);
- string channel = "hello_world";
- PubnubUnitTest unitTest = new PubnubUnitTest();
- unitTest.TestClassName = "WhenAClientIsPresented";
- unitTest.TestCaseName = "IfHereNowIsCalledThenItShouldReturnInfo";
- pubnub.PubnubUnitTest = unitTest;
-
- Common cm = new Common();
- cm.deliveryStatus = false;
- cm.objResponse = null;
- pubnub.here_now(channel, cm.DisplayReturnMessage);
- while (!cm.deliveryStatus) ;
-
- string strResponse = "";
- if (cm.objResponse.Equals (null)) {
- Assert.Fail("Null response");
+ Common common = new Common();
+ common.DeliveryStatus = false;
+ common.Response = null;
+
+ HereNow(pubnub, "IfHereNowIsCalledThenItShouldReturnInfo", common.DisplayReturnMessage);
+ while (!common.DeliveryStatus) ;
+
+ ParseResponse(common.Response);
+ }
+
+ void HereNow(Pubnub pubnub, string unitTestCaseName,
+ Action<object> userCallback)
+ {
+ string channel = "hello_world";
+
+ PubnubUnitTest unitTest = new PubnubUnitTest();
+ unitTest.TestClassName = "WhenAClientIsPresented";
+ unitTest.TestCaseName = unitTestCaseName;
+ pubnub.PubnubUnitTest = unitTest;
+
+ pubnub.HereNow(channel, userCallback);
+ }
+
+ public void ParseResponse(object commonResponse)
+ {
+ string response = "";
+ if (commonResponse.Equals (null)) {
+ Assert.Fail("Null response");
+ }
+ else
+ {
+ IList<object> responseFields = commonResponse as IList<object>;
+ foreach(object item in responseFields)
+ {
+ response = item.ToString();
+ Console.WriteLine("Response:" + response);