Permalink
Browse files

refactored naming conventions in test projects

  • Loading branch information...
1 parent ae1b544 commit e35ec4949fc1f4b540f490136b0d29773477dd15 @budgetpreneur budgetpreneur committed Jan 8, 2013
Showing with 1,170 additions and 1,192 deletions.
  1. +92 −92 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/EncryptionTests.cs
  2. +19 −19 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/PubnubUnitTest.cs
  3. +29 −29 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenAClientIsPresented.cs
  4. +112 −113 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenAMessageIsPublished.cs
  5. +42 −44 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenDetailedHistoryIsRequested.cs
  6. +11 −11 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenGetRequestServerTime.cs
  7. +18 −19 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenSubscribedToAChannel.cs
  8. BIN csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.suo
  9. +338 −339 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone/Pubnub.cs
  10. +2 −2 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone/PubnubOperation.xaml
  11. +27 −28 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone/PubnubOperation.xaml.cs
  12. +92 −91 csharp/3.3.0.1/PubNub-Messaging.Tests/EncryptionTests.cs
  13. +19 −19 csharp/3.3.0.1/PubNub-Messaging.Tests/PubnubUnitTest.cs
  14. +29 −29 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenAClientIsPresented.cs
  15. +112 −113 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenAMessageIsPublished.cs
  16. +42 −42 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenDetailedHistoryIsRequested.cs
  17. +17 −17 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenGetRequestServerTime.cs
  18. +26 −28 csharp/3.3.0.1/PubNub-Messaging.Tests/WhenSubscribedToAChannel.cs
  19. +1 −1 csharp/3.3.0.1/PubNub-Messaging/PubNub-Messaging.csproj
  20. +140 −141 csharp/3.3.0.1/PubNub-Messaging/Pubnub.cs
  21. +2 −15 csharp/3.3.0.1/PubNub-Messaging/app.config
  22. BIN csharp/3.3.0.1/PubNub-Messaging/bin/Debug/Newtonsoft.Json.dll
  23. BIN csharp/3.3.0.1/PubNub.suo
View
184 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/EncryptionTests.cs
@@ -41,12 +41,12 @@ public void TestNullEncryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//serialized string
- string strMessage = null;
+ string message = null;
try
{
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
}
catch (ArgumentNullException)
{
@@ -70,16 +70,16 @@ public void TestNullEncryption()
public void TestNullDecryption()
{
bool isExpectedException = false;
- string dec = "";
+ string decryptedMessage = "";
ThreadPool.QueueUserWorkItem((s) =>
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//deserialized string
- string strMessage = null;
+ string message = null;
try
{
//Decrypt
- dec = pc.Decrypt(strMessage);
+ decryptedMessage = pc.Decrypt(message);
}
catch (ArgumentNullException)
{
@@ -106,13 +106,13 @@ public void TestYayDecryptionBasic()
ThreadPool.QueueUserWorkItem((s) =>
{
PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage = "q/xJqqN6qbiZMXYmiQC1Fw==";
+ string message = "q/xJqqN6qbiZMXYmiQC1Fw==";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//deserialize again
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("yay!", dec);
+ Assert.AreEqual("yay!", decryptedMessage);
TestComplete();
});
});
@@ -130,12 +130,12 @@ public void TestYayEncryptionBasic()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//deserialized string
- string strMessage = "yay!";
+ string message = "yay!";
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", enc);
+ Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", encryptedMessage);
TestComplete();
});
});
@@ -154,16 +154,16 @@ public void TestYayDecryption()
PubnubCrypto pc = new PubnubCrypto("enigma");
//string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
//Non deserialized string
- string strMessage = "\"Wi24KS4pcTzvyuGOHubiXg==\"";
+ string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";
//Deserialize
- strMessage = JsonConvert.DeserializeObject<string>(strMessage);
+ message = JsonConvert.DeserializeObject<string>(message);
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//deserialize again
- strMessage = JsonConvert.DeserializeObject<string>(dec);
+ message = JsonConvert.DeserializeObject<string>(decryptedMessage);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("yay!", strMessage);
+ Assert.AreEqual("yay!", message);
TestComplete();
});
});
@@ -180,15 +180,15 @@ public void TestYayEncryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//deserialized string
- string strMessage = "yay!";
+ string message = "yay!";
//serialize the string
- strMessage = JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
+ message = JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", enc);
+ Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", encryptedMessage);
TestComplete();
});
});
@@ -206,14 +206,14 @@ public void TestArrayEncryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//create an empty array object
- object[] objArr = { };
+ object[] emptyArray = { };
//serialize
- string strArr = JsonConvert.SerializeObject(objArr);
+ string serializedArray = JsonConvert.SerializeObject(emptyArray);
//Encrypt
- string enc = pc.Encrypt(strArr);
+ string encryptedMessage = pc.Encrypt(serializedArray);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", enc);
+ Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", encryptedMessage);
TestComplete();
});
});
@@ -232,16 +232,16 @@ public void TestArrayDecryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//Input the deserialized string
- string strMessage = "Ns4TB41JjT2NCXaGLWSPAQ==";
+ string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//create a serialized object
- object[] objArr = { };
- string res = JsonConvert.SerializeObject(objArr);
+ object[] emptyArrayObject = { };
+ string result = JsonConvert.SerializeObject(emptyArrayObject);
//compare the serialized object and the return of the Decrypt method
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual(res, dec);
+ Assert.AreEqual(result, decryptedMessage);
TestComplete();
});
});
@@ -261,12 +261,12 @@ public void TestObjectEncryption()
//create an object
Object obj = new Object();
//serialize
- string strObj = JsonConvert.SerializeObject(obj);
+ string serializedObject = JsonConvert.SerializeObject(obj);
//Encrypt
- string enc = pc.Encrypt(strObj);
+ string encryptedMessage = pc.Encrypt(serializedObject);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", enc);
+ Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", encryptedMessage);
TestComplete();
});
});
@@ -284,16 +284,16 @@ public void TestObjectDecryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//Deserialized
- string strMessage = "IDjZE9BHSjcX67RddfCYYg==";
+ string message = "IDjZE9BHSjcX67RddfCYYg==";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//create an object
Object obj = new Object();
//Serialize the object
- string res = JsonConvert.SerializeObject(obj);
+ string result = JsonConvert.SerializeObject(obj);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual(res, dec);
+ Assert.AreEqual(result, decryptedMessage);
TestComplete();
});
});
@@ -312,13 +312,13 @@ public void TestMyObjectEncryption()
//create an object of the custom class
CustomClass cc = new CustomClass();
//serialize it
- string res = JsonConvert.SerializeObject(cc);
+ string result = JsonConvert.SerializeObject(cc);
//Encrypt it
- string enc = pc.Encrypt(res);
+ string encryptedMessage = pc.Encrypt(result);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", enc);
+ Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encryptedMessage);
TestComplete();
});
});
@@ -335,17 +335,17 @@ public void TestMyObjectDecryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//Deserialized
- string strMessage = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
+ string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//create an object of the custom class
CustomClass cc = new CustomClass();
//Serialize it
- string res = JsonConvert.SerializeObject(cc);
+ string result = JsonConvert.SerializeObject(cc);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual(res, dec);
+ Assert.AreEqual(result, decryptedMessage);
TestComplete();
});
});
@@ -363,15 +363,15 @@ public void TestPubNubEncryption2()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//Deserialized
- string strMessage = "Pubnub Messaging API 2";
+ string message = "Pubnub Messaging API 2";
//serialize the message
- strMessage = JsonConvert.SerializeObject(strMessage);
+ message = JsonConvert.SerializeObject(message);
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", enc);
+ Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", encryptedMessage);
TestComplete();
});
});
@@ -389,14 +389,14 @@ public void TestPubNubDecryption2()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//Deserialized string
- string strMessage = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
+ string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//Deserialize
- strMessage = JsonConvert.DeserializeObject<string>(dec);
+ message = JsonConvert.DeserializeObject<string>(decryptedMessage);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("Pubnub Messaging API 2", strMessage);
+ Assert.AreEqual("Pubnub Messaging API 2", message);
TestComplete();
});
});
@@ -414,14 +414,14 @@ public void TestPubNubEncryption1()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//non serialized string
- string strMessage = "Pubnub Messaging API 1";
+ string message = "Pubnub Messaging API 1";
//serialize
- strMessage = JsonConvert.SerializeObject(strMessage);
+ message = JsonConvert.SerializeObject(message);
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", enc);
+ Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", encryptedMessage);
TestComplete();
});
});
@@ -439,14 +439,14 @@ public void TestPubNubDecryption1()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//deserialized string
- string strMessage = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
+ string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//deserialize
- strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : "";
+ message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("Pubnub Messaging API 1", strMessage);
+ Assert.AreEqual("Pubnub Messaging API 1", message);
TestComplete();
});
});
@@ -464,12 +464,12 @@ public void TestStuffCanEncryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//input serialized string
- string strMessage = "{\"this stuff\":{\"can get\":\"complicated!\"}}";
+ string message = "{\"this stuff\":{\"can get\":\"complicated!\"}}";
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", enc);
+ Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", encryptedMessage);
TestComplete();
});
});
@@ -486,12 +486,12 @@ public void TestStuffcanDecryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//deserialized string
- string strMessage = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
+ string message = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", dec);
+ Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", decryptedMessage);
TestComplete();
});
});
@@ -509,12 +509,12 @@ public void TestHashEncryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//serialized string
- string strMessage = "{\"foo\":{\"bar\":\"foobar\"}}";
+ string message = "{\"foo\":{\"bar\":\"foobar\"}}";
//Encrypt
- string enc = pc.Encrypt(strMessage);
+ string encryptedMessage = pc.Encrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", enc);
+ Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", encryptedMessage);
TestComplete();
});
});
@@ -531,12 +531,12 @@ public void TestHashDecryption()
{
PubnubCrypto pc = new PubnubCrypto("enigma");
//deserialized string
- string strMessage = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
+ string message = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", dec);
+ Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", decryptedMessage);
TestComplete();
});
});
@@ -552,15 +552,15 @@ public void TestUnicodeCharsEncryption()
ThreadPool.QueueUserWorkItem((s) =>
{
PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage = "漢語";
+ string message = "漢語";
- strMessage = JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
- string enc = pc.Encrypt(strMessage);
- Console.WriteLine(enc);
+ message = JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encryptedMessage = pc.Encrypt(message);
+ Console.WriteLine(encryptedMessage);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", enc);
+ Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", encryptedMessage);
TestComplete();
});
});
@@ -577,15 +577,15 @@ public void TestUnicodeCharsDecryption()
ThreadPool.QueueUserWorkItem((s) =>
{
PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage = "+BY5/miAA8aeuhVl4d13Kg==";
+ string message = "+BY5/miAA8aeuhVl4d13Kg==";
//JavaScriptSerializer js = new JavaScriptSerializer();
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//deserialize
- strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : "";
+ message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("漢語", strMessage);
+ Assert.AreEqual("漢語", message);
TestComplete();
});
});
@@ -602,14 +602,14 @@ public void TestGermanCharsDecryption()
ThreadPool.QueueUserWorkItem((s) =>
{
PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage = "stpgsG1DZZxb44J7mFNSzg==";
+ string message = "stpgsG1DZZxb44J7mFNSzg==";
//Decrypt
- string dec = pc.Decrypt(strMessage);
+ string decryptedMessage = pc.Decrypt(message);
//deserialize
- strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : "";
+ message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("ÜÖ", strMessage);
+ Assert.AreEqual("ÜÖ", message);
TestComplete();
});
});
@@ -624,15 +624,15 @@ public void TestGermanCharsEncryption()
ThreadPool.QueueUserWorkItem((s) =>
{
PubnubCrypto pc = new PubnubCrypto("enigma");
- string strMessage = "ÜÖ";
+ string message = "ÜÖ";
- strMessage = JsonConvert.SerializeObject(strMessage);
- Console.WriteLine(strMessage);
- string enc = pc.Encrypt(strMessage);
- Console.WriteLine(enc);
+ message = JsonConvert.SerializeObject(message);
+ Console.WriteLine(message);
+ string encryptedMessage = pc.Encrypt(message);
+ Console.WriteLine(encryptedMessage);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", enc);
+ Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", encryptedMessage);
TestComplete();
});
});
View
38 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/PubnubUnitTest.cs
@@ -259,7 +259,7 @@ public bool EnableStubTest
public string GetStubResponse(Uri request)
{
- Dictionary<string, string> respDic = null;
+ Dictionary<string, string> responseDictionary = null;
string stubResponse = "!! Stub Response Not Assigned !!";
switch (_testClassName)
@@ -268,10 +268,10 @@ public string GetStubResponse(Uri request)
switch (_testCaseName)
{
case "ThenPresenceShouldReturnReceivedMessage":
- respDic = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage();
+ responseDictionary = LoadWhenAClientIsPresentedThenPresenceShouldReturnReceivedMessage();
break;
case "IfHereNowIsCalledThenItShouldReturnInfo":
- respDic = LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo();
+ responseDictionary = LoadWhenAClientIsPresentedIfHereNowIsCalledThenItShouldReturnInfo();
break;
default:
break;
@@ -281,25 +281,25 @@ public string GetStubResponse(Uri request)
switch (_testCaseName)
{
case "ThenUnencryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo":
- respDic = LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo":
- respDic = LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenEncryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenEncryptPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo":
- respDic = LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
+ responseDictionary = LoadWhenAMessageIsPublishedThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo();
break;
case "ThenOptionalSecretKeyShouldBeProvidedInConstructor":
- respDic = LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor();
+ responseDictionary = LoadWhenAMessageIsPublishedThenOptionalSecretKeyShouldBeProvidedInConstructor();
break;
case "IfSSLNotProvidedThenDefaultShouldBeFalse":
- respDic = LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse();
+ responseDictionary = LoadWhenAMessageIsPublishedIfSSLNotProvidedThenDefaultShouldBeFalse();
break;
default:
break;
@@ -309,13 +309,13 @@ public string GetStubResponse(Uri request)
switch (_testCaseName)
{
case "DetailHistoryCount10ReturnsRecords":
- respDic = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReturnsRecords();
break;
case "DetailHistoryCount10ReverseTrueReturnsRecords":
- respDic = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailHistoryCount10ReverseTrueReturnsRecords();
break;
case "DetailedHistoryStartWithReverseTrue":
- respDic = LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue();
+ responseDictionary = LoadWhenDetailedHistoryIsRequestedDetailedHistoryStartWithReverseTrue();
break;
default:
break;
@@ -325,10 +325,10 @@ public string GetStubResponse(Uri request)
switch (_testCaseName)
{
case "ThenItShouldReturnTimeStamp":
- respDic = LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp();
+ responseDictionary = LoadWhenGetRequestServerTimeThenItShouldReturnTimeStamp();
break;
case "ThenWithProxyItShouldReturnTimeStamp":
- respDic = LoadWhenGetRequestServerTimeThenWithProxyItShouldReturnTimeStamp();
+ responseDictionary = LoadWhenGetRequestServerTimeThenWithProxyItShouldReturnTimeStamp();
break;
default:
break;
@@ -338,10 +338,10 @@ public string GetStubResponse(Uri request)
switch (_testCaseName)
{
case "ThenSubscribeShouldReturnReceivedMessage":
- respDic = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage();
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnReceivedMessage();
break;
case "ThenSubscribeShouldReturnConnectStatus":
- respDic = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus();
+ responseDictionary = LoadWhenSubscribedToAChannelThenSubscribeShouldReturnConnectStatus();
break;
default:
break;
@@ -351,9 +351,9 @@ public string GetStubResponse(Uri request)
break;
}
- if (respDic != null && respDic.ContainsKey(request.AbsolutePath))
+ if (responseDictionary != null && responseDictionary.ContainsKey(request.AbsolutePath))
{
- stubResponse = respDic[request.AbsolutePath];
+ stubResponse = responseDictionary[request.AbsolutePath];
}
else
{
View
58 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenAClientIsPresented.cs
@@ -22,20 +22,20 @@ namespace PubnubWindowsPhone.Test.UnitTest
[TestClass]
public class WhenAClientIsPresented : WorkItemTest
{
- ManualResetEvent manualEvent1 = new ManualResetEvent(false);
- ManualResetEvent manualEvent2 = new ManualResetEvent(false);
- ManualResetEvent manualEvent3 = new ManualResetEvent(false);
+ ManualResetEvent subscribeManualEvent = new ManualResetEvent(false);
+ ManualResetEvent presenceManualEvent = new ManualResetEvent(false);
+ ManualResetEvent unsubscribeManualEvent = new ManualResetEvent(false);
- ManualResetEvent manualEvent4 = new ManualResetEvent(false);
- ManualResetEvent preUnsubEvent = new ManualResetEvent(false);
+ ManualResetEvent hereNowManualEvent = new ManualResetEvent(false);
+ ManualResetEvent presenceUnsubscribeEvent = new ManualResetEvent(false);
- static bool receivedFlag1 = false;
- static bool receivedFlag2 = false;
+ static bool receivedPresenceMessage = false;
+ static bool receivedHereNowMessage = false;
[TestMethod,Asynchronous]
public void ThenPresenceShouldReturnReceivedMessage()
{
- receivedFlag1 = false;
+ receivedPresenceMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
@@ -50,18 +50,18 @@ public void ThenPresenceShouldReturnReceivedMessage()
//since presence expects from stimulus from sub/unsub...
pubnub.Subscribe<string>(channel, DummyMethodForSubscribe);
- manualEvent1.WaitOne(2000);
+ subscribeManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe);
- manualEvent3.WaitOne(2000);
+ unsubscribeManualEvent.WaitOne(2000);
pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSub);
- preUnsubEvent.WaitOne(2000);
+ presenceUnsubscribeEvent.WaitOne(2000);
- manualEvent2.WaitOne(310 * 1000);
+ presenceManualEvent.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(receivedFlag1, "Presence message not received");
+ Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
TestComplete();
});
});
@@ -74,27 +74,27 @@ void ThenPresenceShouldReturnMessage(string receivedMessage)
{
if (!string.IsNullOrWhiteSpace(receivedMessage))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(receivedMessage);
- JContainer dic = receivedObj[0] as JContainer;
- var uuid = dic["uuid"].ToString();
+ object[] serializedMessage = JsonConvert.DeserializeObject<object[]>(receivedMessage);
+ JContainer dictionary = serializedMessage[0] as JContainer;
+ var uuid = dictionary["uuid"].ToString();
if (uuid != null)
{
- receivedFlag1 = true;
+ receivedPresenceMessage = true;
}
}
}
catch { }
finally
{
- manualEvent2.Set();
+ presenceManualEvent.Set();
}
}
[TestMethod,Asynchronous]
public void IfHereNowIsCalledThenItShouldReturnInfo()
{
- receivedFlag2 = false;
+ receivedHereNowMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
@@ -106,10 +106,10 @@ public void IfHereNowIsCalledThenItShouldReturnInfo()
pubnub.PubnubUnitTest = unitTest;
pubnub.HereNow<string>(channel, ThenHereNowShouldReturnMessage);
- manualEvent4.WaitOne();
+ hereNowManualEvent.WaitOne();
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(receivedFlag2, "here_now message not received");
+ Assert.IsTrue(receivedHereNowMessage, "here_now message not received");
TestComplete();
});
});
@@ -124,40 +124,40 @@ void ThenHereNowShouldReturnMessage(string receivedMessage)
{
if (!string.IsNullOrWhiteSpace(receivedMessage))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(receivedMessage);
- var dic = ((JContainer)receivedObj[0])["uuids"];
- if (dic != null)
+ object[] serializedMessage = JsonConvert.DeserializeObject<object[]>(receivedMessage);
+ var dictionary = ((JContainer)serializedMessage[0])["uuids"];
+ if (dictionary != null)
{
- receivedFlag2 = true;
+ receivedHereNowMessage = true;
}
}
});
}
catch { }
finally
{
- manualEvent4.Set();
+ hereNowManualEvent.Set();
}
}
[Asynchronous]
void DummyMethodForSubscribe(string receivedMessage)
{
- manualEvent1.Set();
+ subscribeManualEvent.Set();
//Dummary callback method for subscribe and unsubscribe to test presence
}
[Asynchronous]
void DummyMethodForUnSubscribe(string receivedMessage)
{
- manualEvent3.Set();
+ unsubscribeManualEvent.Set();
//Dummary callback method for unsubscribe to test presence
}
[Asynchronous]
void DummyMethodForPreUnSub(string receivedMessage)
{
- preUnsubEvent.Set();
+ presenceUnsubscribeEvent.Set();
}
}
}
View
225 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenAMessageIsPublished.cs
@@ -28,33 +28,33 @@ public class WhenAMessageIsPublished : WorkItemTest
{
JsonSerializer serializer = new JsonSerializer();
- ManualResetEvent manualEvent1 = new ManualResetEvent(false);
- ManualResetEvent manualEvent2 = new ManualResetEvent(false);
- ManualResetEvent manualEvent3 = new ManualResetEvent(false);
-
- ManualResetEvent mreUnencryptObjectPub = new ManualResetEvent(false);
- ManualResetEvent mreEncryptObjectPub = new ManualResetEvent(false);
- ManualResetEvent mreEncryptPub = new ManualResetEvent(false);
- ManualResetEvent mreSecretEncryptPub = new ManualResetEvent(false);
- ManualResetEvent mreEncryptDH = new ManualResetEvent(false);
- ManualResetEvent mreSecretEncryptDH = new ManualResetEvent(false);
- ManualResetEvent mreUnencryptDH = new ManualResetEvent(false);
- ManualResetEvent mreUnencryptObjectDH = new ManualResetEvent(false);
- ManualResetEvent mreEncryptObjectDH = new ManualResetEvent(false);
+ ManualResetEvent mreUnencryptedPublish = new ManualResetEvent(false);
+ ManualResetEvent mreOptionalSecretKeyPublish = new ManualResetEvent(false);
+ ManualResetEvent mreNoSslPublish = new ManualResetEvent(false);
+
+ ManualResetEvent mreUnencryptObjectPublish = new ManualResetEvent(false);
+ ManualResetEvent mreEncryptObjectPublish = new ManualResetEvent(false);
+ ManualResetEvent mreEncryptPublish = new ManualResetEvent(false);
+ ManualResetEvent mreSecretEncryptPublish = new ManualResetEvent(false);
+ ManualResetEvent mreEncryptDetailedHistory = new ManualResetEvent(false);
+ ManualResetEvent mreSecretEncryptDetailedHistory = new ManualResetEvent(false);
+ ManualResetEvent mreUnencryptDetailedHistory = new ManualResetEvent(false);
+ ManualResetEvent mreUnencryptObjectDetailedHistory = new ManualResetEvent(false);
+ ManualResetEvent mreEncryptObjectDetailedHistory = new ManualResetEvent(false);
bool isPublished2 = false;
bool isPublished3 = false;
bool isUnencryptPublished = false;
bool isUnencryptObjectPublished = false;
bool isEncryptObjectPublished = false;
- bool isUnencryptDH = false;
- bool isUnencryptObjectDH = false;
- bool isEncryptObjectDH = false;
+ bool isUnencryptDetailedHistory = false;
+ bool isUnencryptObjectDetailedHistory = false;
+ bool isEncryptObjectDetailedHistory = false;
bool isEncryptPublished = false;
bool isSecretEncryptPublished = false;
- bool isEncryptDH = false;
- bool isSecretEncryptDH = false;
+ bool isEncryptDetailedHistory = false;
+ bool isSecretEncryptDetailedHistory = false;
long unEncryptPublishTimetoken = 0;
long unEncryptObjectPublishTimetoken = 0;
@@ -86,7 +86,7 @@ public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnSuccessUnencryptPublishCodeCallback);
- manualEvent1.WaitOne(310 * 1000);
+ mreUnencryptedPublish.WaitOne(310 * 1000);
if (!isUnencryptPublished)
{
@@ -99,10 +99,10 @@ public void ThenUnencryptPublishShouldReturnSuccessCodeAndInfo()
else
{
pubnub.DetailedHistory<string>(channel, -1, unEncryptPublishTimetoken, -1, false, CaptureUnencryptDetailedHistoryCallback);
- mreUnencryptDH.WaitOne(310 * 1000);
+ mreUnencryptDetailedHistory.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(isUnencryptDH, "Unable to match the successful unencrypt Publish");
+ Assert.IsTrue(isUnencryptDetailedHistory, "Unable to match the successful unencrypt Publish");
TestComplete();
});
}
@@ -126,7 +126,7 @@ public void ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnSuccessUnencryptObjectPublishCodeCallback);
- mreUnencryptObjectPub.WaitOne(310 * 1000);
+ mreUnencryptObjectPublish.WaitOne(310 * 1000);
if (!isUnencryptObjectPublished)
{
@@ -139,10 +139,10 @@ public void ThenUnencryptObjectPublishShouldReturnSuccessCodeAndInfo()
else
{
pubnub.DetailedHistory<string>(channel, -1, unEncryptObjectPublishTimetoken, -1, false, CaptureUnencryptObjectDetailedHistoryCallback);
- mreUnencryptObjectDH.WaitOne(310 * 1000);
+ mreUnencryptObjectDetailedHistory.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(isUnencryptObjectDH, "Unable to match the successful unencrypt object Publish");
+ Assert.IsTrue(isUnencryptObjectDetailedHistory, "Unable to match the successful unencrypt object Publish");
TestComplete();
});
}
@@ -168,7 +168,7 @@ public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback);
- mreEncryptObjectPub.WaitOne(310 * 1000);
+ mreEncryptObjectPublish.WaitOne(310 * 1000);
if (!isEncryptObjectPublished)
{
@@ -181,10 +181,10 @@ public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
else
{
pubnub.DetailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback);
- mreEncryptObjectDH.WaitOne(310 * 1000);
+ mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(isEncryptObjectDH, "Unable to match the successful encrypt object Publish");
+ Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
TestComplete();
});
}
@@ -208,7 +208,7 @@ public void ThenEncryptPublishShouldReturnSuccessCodeAndInfo()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnSuccessEncryptPublishCodeCallback);
- mreEncryptPub.WaitOne(310 * 1000);
+ mreEncryptPublish.WaitOne(310 * 1000);
if (!isEncryptPublished)
{
@@ -221,10 +221,10 @@ public void ThenEncryptPublishShouldReturnSuccessCodeAndInfo()
else
{
pubnub.DetailedHistory<string>(channel, -1, encryptPublishTimetoken, -1, false, CaptureEncryptDetailedHistoryCallback);
- mreEncryptDH.WaitOne(310 * 1000);
+ mreEncryptDetailedHistory.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(isEncryptDH, "Unable to decrypt the successful Publish");
+ Assert.IsTrue(isEncryptDetailedHistory, "Unable to decrypt the successful Publish");
TestComplete();
});
}
@@ -247,7 +247,7 @@ public void ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnSuccessSecretEncryptPublishCodeCallback);
- mreSecretEncryptPub.WaitOne(310 * 1000);
+ mreSecretEncryptPublish.WaitOne(310 * 1000);
if (!isSecretEncryptPublished)
{
@@ -260,10 +260,10 @@ public void ThenSecretKeyWithEncryptPublishShouldReturnSuccessCodeAndInfo()
else
{
pubnub.DetailedHistory<string>(channel, -1, secretEncryptPublishTimetoken, -1, false, CaptureSecretEncryptDetailedHistoryCallback);
- mreSecretEncryptDH.WaitOne(310 * 1000);
+ mreSecretEncryptDetailedHistory.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(isSecretEncryptDH, "Unable to decrypt the successful Secret key Publish");
+ Assert.IsTrue(isSecretEncryptDetailedHistory, "Unable to decrypt the successful Secret key Publish");
TestComplete();
});
}
@@ -275,195 +275,194 @@ private void ReturnSuccessUnencryptPublishCodeCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isUnencryptPublished = true;
- unEncryptPublishTimetoken = Convert.ToInt64(receivedObj[2].ToString());
+ unEncryptPublishTimetoken = Convert.ToInt64(deserializedMessage[2].ToString());
}
}
}
- manualEvent1.Set();
+ mreUnencryptedPublish.Set();
}
[Asynchronous]
private void ReturnSuccessUnencryptObjectPublishCodeCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isUnencryptObjectPublished = true;
- unEncryptObjectPublishTimetoken = Convert.ToInt64(receivedObj[2].ToString());
+ unEncryptObjectPublishTimetoken = Convert.ToInt64(deserializedMessage[2].ToString());
}
}
}
- mreUnencryptObjectPub.Set();
+ mreUnencryptObjectPublish.Set();
}
[Asynchronous]
private void ReturnSuccessEncryptObjectPublishCodeCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isEncryptObjectPublished = true;
- encryptObjectPublishTimetoken = Convert.ToInt64(receivedObj[2].ToString());
+ encryptObjectPublishTimetoken = Convert.ToInt64(deserializedMessage[2].ToString());
}
}
}
- mreEncryptObjectPub.Set();
+ mreEncryptObjectPublish.Set();
}
[Asynchronous]
private void ReturnSuccessEncryptPublishCodeCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isEncryptPublished = true;
- encryptPublishTimetoken = Convert.ToInt64(receivedObj[2].ToString());
+ encryptPublishTimetoken = Convert.ToInt64(deserializedMessage[2].ToString());
}
}
}
- mreEncryptPub.Set();
+ mreEncryptPublish.Set();
}
[Asynchronous]
private void ReturnSuccessSecretEncryptPublishCodeCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isSecretEncryptPublished = true;
- secretEncryptPublishTimetoken = Convert.ToInt64(receivedObj[2].ToString());
+ secretEncryptPublishTimetoken = Convert.ToInt64(deserializedMessage[2].ToString());
}
}
}
- mreSecretEncryptPub.Set();
+ mreSecretEncryptPublish.Set();
}
[Asynchronous]
private void CaptureUnencryptDetailedHistoryCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null && jArr[0].ToString() == messageForUnencryptPublish)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null && message[0].ToString() == messageForUnencryptPublish)
{
- isUnencryptDH = true;
+ isUnencryptDetailedHistory = true;
}
}
}
- mreUnencryptDH.Set();
+ mreUnencryptDetailedHistory.Set();
}
[Asynchronous]
private void CaptureUnencryptObjectDetailedHistoryCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null && jArr[0].ToString(Formatting.None) == messageObjectForUnencryptPublish)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null && message[0].ToString(Formatting.None) == messageObjectForUnencryptPublish)
{
- isUnencryptObjectDH = true;
+ isUnencryptObjectDetailedHistory = true;
}
}
}
- mreUnencryptObjectDH.Set();
+ mreUnencryptObjectDetailedHistory.Set();
}
[Asynchronous]
private void CaptureEncryptObjectDetailedHistoryCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- //JArray jArr = JArray.Parse(receivedObj[0].ToString());
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null && jArr[0].ToString(Formatting.None) == messageObjectForEncryptPublish)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null && message[0].ToString(Formatting.None) == messageObjectForEncryptPublish)
{
- isEncryptObjectDH = true;
+ isEncryptObjectDetailedHistory = true;
}
}
}
- mreEncryptObjectDH.Set();
+ mreEncryptObjectDetailedHistory.Set();
}
[Asynchronous]
private void CaptureEncryptDetailedHistoryCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null && jArr[0].ToString() == messageForEncryptPublish)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null && message[0].ToString() == messageForEncryptPublish)
{
- isEncryptDH = true;
+ isEncryptDetailedHistory = true;
}
}
}
- mreEncryptDH.Set();
+ mreEncryptDetailedHistory.Set();
}
[Asynchronous]
private void CaptureSecretEncryptDetailedHistoryCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null && jArr[0].ToString() == messageForSecretEncryptPublish)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null && message[0].ToString() == messageForSecretEncryptPublish)
{
- isSecretEncryptDH = true;
+ isSecretEncryptDetailedHistory = true;
}
}
}
- mreSecretEncryptDH.Set();
+ mreSecretEncryptDetailedHistory.Set();
}
[TestMethod, Asynchronous]
@@ -530,7 +529,7 @@ public void ThenOptionalSecretKeyShouldBeProvidedInConstructor()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnSecretKeyPublishCallback);
- manualEvent2.WaitOne(310 * 1000);
+ mreOptionalSecretKeyPublish.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(isPublished2, "Publish Failed with secret key");
@@ -544,18 +543,18 @@ private void ReturnSecretKeyPublishCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isPublished2 = true;
}
}
}
- manualEvent2.Set();
+ mreOptionalSecretKeyPublish.Set();
}
[TestMethod,Asynchronous]
@@ -574,7 +573,7 @@ public void IfSSLNotProvidedThenDefaultShouldBeFalse()
pubnub.PubnubUnitTest = unitTest;
pubnub.Publish<string>(channel, message, ReturnNoSSLDefaultFalseCallback);
- manualEvent3.WaitOne(310 * 1000);
+ mreNoSslPublish.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(isPublished3, "Publish Failed with no SSL");
@@ -590,19 +589,19 @@ private void ReturnNoSSLDefaultFalseCallback(string result)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
isPublished3 = true;
}
}
});
}
- manualEvent3.Set();
+ mreNoSslPublish.Set();
}
}
}
View
86 ...-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenDetailedHistoryIsRequested.cs
@@ -23,23 +23,23 @@ namespace PubnubWindowsPhone.Test.UnitTest
[TestClass]
public class WhenDetailedHistoryIsRequested : WorkItemTest
{
- ManualResetEvent mreMsgCount10 = new ManualResetEvent(false);
- ManualResetEvent mreMsgCount10ReverseTrue = new ManualResetEvent(false);
- ManualResetEvent mreMsgStartReverseTrue = new ManualResetEvent(false);
+ ManualResetEvent mreMessageCount10 = new ManualResetEvent(false);
+ ManualResetEvent mreMessageCount10ReverseTrue = new ManualResetEvent(false);
+ ManualResetEvent mreMessageStartReverseTrue = new ManualResetEvent(false);
ManualResetEvent mrePublishStartReverseTrue = new ManualResetEvent(false);
- bool msg10Received = false;
- bool msg10ReverseTrueReceived = false;
- bool msgStartReverseTrue = false;
+ bool message10Received = false;
+ bool message10ReverseTrueReceived = false;
+ bool messageStartReverseTrue = false;
int expectedCountAtStartTimeWithReverseTrue=0;
long startTimeWithReverseTrue = 0;
[TestMethod,Asynchronous]
public void DetailHistoryCount10ReturnsRecords()
{
- msg10Received = false;
+ message10Received = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
@@ -51,10 +51,10 @@ public void DetailHistoryCount10ReturnsRecords()
pubnub.PubnubUnitTest = unitTest;
pubnub.DetailedHistory<string>(channel, 10, DetailedHistoryCount10Callback);
- mreMsgCount10.WaitOne(310 * 1000);
+ mreMessageCount10.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(msg10Received, "Detailed History Failed");
+ Assert.IsTrue(message10Received, "Detailed History Failed");
TestComplete();
});
});
@@ -65,27 +65,27 @@ void DetailedHistoryCount10Callback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null)
{
- if (jArr.Count >= 0)
+ if (message.Count >= 0)
{
- msg10Received = true;
+ message10Received = true;
}
}
}
}
- mreMsgCount10.Set();
+ mreMessageCount10.Set();
}
[TestMethod,Asynchronous]
public void DetailHistoryCount10ReverseTrueReturnsRecords()
{
- msg10ReverseTrueReceived = false;
+ message10ReverseTrueReceived = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
@@ -97,10 +97,10 @@ public void DetailHistoryCount10ReverseTrueReturnsRecords()
pubnub.PubnubUnitTest = unitTest;
pubnub.DetailedHistory<string>(channel, -1, -1, 10, true, DetailedHistoryCount10ReverseTrueCallback);
- mreMsgCount10ReverseTrue.WaitOne(310 * 1000);
+ mreMessageCount10ReverseTrue.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(msg10ReverseTrueReceived, "Detailed History Failed");
+ Assert.IsTrue(message10ReverseTrueReceived, "Detailed History Failed");
TestComplete();
});
});
@@ -111,28 +111,28 @@ void DetailedHistoryCount10ReverseTrueCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null)
{
- if (jArr.Count >= 0)
+ if (message.Count >= 0)
{
- msg10ReverseTrueReceived = true;
+ message10ReverseTrueReceived = true;
}
}
}
}
- mreMsgCount10ReverseTrue.Set();
+ mreMessageCount10ReverseTrue.Set();
}
[TestMethod,Asynchronous]
public void DetailedHistoryStartWithReverseTrue()
{
expectedCountAtStartTimeWithReverseTrue = 0;
- msgStartReverseTrue = false;
+ messageStartReverseTrue = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
@@ -153,13 +153,11 @@ public void DetailedHistoryStartWithReverseTrue()
Thread.Sleep(200);
}
- //Thread.Sleep(2000);
-
pubnub.DetailedHistory<string>(channel, startTimeWithReverseTrue, DetailedHistoryStartWithReverseTrueCallback, true);
- mreMsgStartReverseTrue.WaitOne(310 * 1000);
+ mreMessageStartReverseTrue.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
- Assert.IsTrue(msgStartReverseTrue, "Detailed History with Start and Reverse True Failed");
+ Assert.IsTrue(messageStartReverseTrue, "Detailed History with Start and Reverse True Failed");
TestComplete();
});
});
@@ -171,15 +169,15 @@ private void DetailedHistoryStartWithReverseTrueCallback(string result)
int actualCountAtStartTimeWithReverseFalse = 0;
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- JArray jArr = receivedObj[0] as JArray;
- if (jArr != null)
+ JArray message = deserializedMessage[0] as JArray;
+ if (message != null)
{
- if (jArr.Count >= expectedCountAtStartTimeWithReverseTrue)
+ if (message.Count >= expectedCountAtStartTimeWithReverseTrue)
{
- foreach (object item in jArr)
+ foreach (object item in message)
{
if (item.ToString().Contains("DetailedHistoryStartTimeWithReverseTrue"))
{
@@ -188,26 +186,26 @@ private void DetailedHistoryStartWithReverseTrueCallback(string result)
}
if (actualCountAtStartTimeWithReverseFalse == expectedCountAtStartTimeWithReverseTrue)
{
- msgStartReverseTrue = true;
+ messageStartReverseTrue = true;
}
}
}
}
}
- mreMsgStartReverseTrue.Set();
+ mreMessageStartReverseTrue.Set();
}
[Asynchronous]
private void DetailedHistorySamplePublishCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- int statusCode = Int32.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "sent")
+ int statusCode = Int32.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "sent")
{
expectedCountAtStartTimeWithReverseTrue++;
}
View
22 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenGetRequestServerTime.cs
@@ -22,7 +22,7 @@ namespace PubnubWindowsPhone.Test.UnitTest
[TestClass]
public class WhenGetRequestServerTime : WorkItemTest
{
- ManualResetEvent manualEvent1 = new ManualResetEvent(false);
+ ManualResetEvent mreTime = new ManualResetEvent(false);
bool timeReceived = false;
[TestMethod]
@@ -40,7 +40,7 @@ public void ThenItShouldReturnTimeStamp()
pubnub.PubnubUnitTest = unitTest;
pubnub.Time<string>(ReturnTimeStampCallback);
- manualEvent1.WaitOne(310 * 1000);
+ mreTime.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(timeReceived, "time() Failed");
@@ -56,36 +56,36 @@ private void ReturnTimeStampCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- string time = receivedObj[0].ToString();
+ string time = deserializedMessage[0].ToString();
if (time.Length > 0)
{
timeReceived = true;
}
}
}
});
- manualEvent1.Set();
+ mreTime.Set();
}
[TestMethod]
public void TranslateDateTimeToUnixTime()
{
DateTime dt = new DateTime(2012, 6, 26, 0, 0, 0, DateTimeKind.Utc);
- long nanosecTime = Pubnub.TranslateDateTimeToPubnubUnixNanoSeconds(dt);
+ long nanoSecondTime = Pubnub.TranslateDateTimeToPubnubUnixNanoSeconds(dt);
//Test for 26th June 2012 GMT
- Assert.AreEqual<long>(13406688000000000, nanosecTime);
+ Assert.AreEqual<long>(13406688000000000, nanoSecondTime);
}
[TestMethod]
public void TranslateUnixTimeToDateTime()
{
//Test for 26th June 2012 GMT
- DateTime expectedDt = new DateTime(2012, 6, 26, 0, 0, 0, DateTimeKind.Utc);
- DateTime actualDt = Pubnub.TranslatePubnubUnixNanoSecondsToDateTime(13406688000000000);
- Assert.AreEqual<DateTime>(expectedDt, actualDt);
+ DateTime expectedDate = new DateTime(2012, 6, 26, 0, 0, 0, DateTimeKind.Utc);
+ DateTime actualDate = Pubnub.TranslatePubnubUnixNanoSecondsToDateTime(13406688000000000);
+ Assert.AreEqual<DateTime>(expectedDate, actualDate);
}
}
}
View
37 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.Test/UnitTest/WhenSubscribedToAChannel.cs
@@ -23,10 +23,10 @@ namespace PubnubWindowsPhone.Test.UnitTest
[TestClass]
public class WhenSubscribedToAChannel : WorkItemTest
{
- ManualResetEvent meSubNoConnect = new ManualResetEvent(false);
+ ManualResetEvent meSubscribeNoConnect = new ManualResetEvent(false);
+ ManualResetEvent meSubscribeYesConnect = new ManualResetEvent(false);
ManualResetEvent mePublish = new ManualResetEvent(false);
- ManualResetEvent meUnsub = new ManualResetEvent(false);
- ManualResetEvent meSubYesConnect = new ManualResetEvent(false);
+ ManualResetEvent meUnsubscribe = new ManualResetEvent(false);
bool receivedMessage = false;
bool receivedConnectMessage = false;
@@ -50,12 +50,11 @@ public void ThenSubscribeShouldReturnReceivedMessage()
pubnub.Publish<string>(channel, "Test for WhenSubscribedToAChannel ThenItShouldReturnReceivedMessage", dummyPublishCallback);
mePublish.WaitOne(310 * 1000);
- //Thread.Sleep(100);
- meSubNoConnect.WaitOne(310 * 1000);
+ meSubscribeNoConnect.WaitOne(310 * 1000);
pubnub.Unsubscribe<string>(channel, dummyUnsubCallback);
- meUnsub.WaitOne(310 * 1000);
+ meUnsubscribe.WaitOne(310 * 1000);
Thread.Sleep(100);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
@@ -82,11 +81,11 @@ public void ThenSubscribeShouldReturnConnectStatus()
string channel = "my/channel";
pubnub.Subscribe<string>(channel, ReceivedMessageCallbackYesConnect, ConnectStatusCallback);
- meSubYesConnect.WaitOne(310 * 1000);
+ meSubscribeYesConnect.WaitOne(310 * 1000);
Thread.Sleep(200);
pubnub.Unsubscribe<string>(channel, dummyUnsubCallback);
- meUnsub.WaitOne(310 * 1000);
+ meUnsubscribe.WaitOne(310 * 1000);
Thread.Sleep(200);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
@@ -107,35 +106,35 @@ private void ConnectStatusCallback(string result)
{
if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- long statusCode = Int64.Parse(receivedObj[0].ToString());
- string statusMsg = (string)receivedObj[1];
- if (statusCode == 1 && statusMsg.ToLower() == "connected")
+ long statusCode = Int64.Parse(deserializedMessage[0].ToString());
+ string statusMessage = (string)deserializedMessage[1];
+ if (statusCode == 1 && statusMessage.ToLower() == "connected")
{
receivedConnectMessage = true;
}
}
}
- meSubYesConnect.Set();
+ meSubscribeYesConnect.Set();
}
[Asynchronous]
private void ReceivedMessageCallback(string result)
{
if (!string.IsNullOrWhiteSpace(result))
{
- object[] receivedObj = JsonConvert.DeserializeObject<object[]>(result);
- if (receivedObj is object[])
+ object[] deserializedMessage = JsonConvert.DeserializeObject<object[]>(result);
+ if (deserializedMessage is object[])
{
- object subscribedObj = (object)receivedObj[0];
+ object subscribedObj = (object)deserializedMessage[0];
if (subscribedObj != null)
{
receivedMessage = true;
}
}
}
- meSubNoConnect.Set();
+ meSubscribeNoConnect.Set();
}
[Asynchronous]
@@ -147,7 +146,7 @@ private void dummyPublishCallback(string result)
[Asynchronous]
private void dummyUnsubCallback(string result)
{
- meUnsub.Set();
+ meUnsubscribe.Set();
}
}
}
View
BIN csharp-windows-phone/3.3.0.1/PubnubWindowsPhone.suo
Binary file not shown.
View
677 csharp-windows-phone/3.3.0.1/PubnubWindowsPhone/Pubnub.cs
@@ -1,4 +1,4 @@
-//Build Date: Jan 05, 2013
+//Build Date: Jan 08, 2013
#if (__MonoCS__)
#define TRACE
#endif
@@ -33,16 +33,16 @@ namespace PubNubMessaging.Core
public class Pubnub : INotifyPropertyChanged
{
- const int PUBNUB_WEBREQUEST_CALLBACK_INTERVAL_IN_SEC = 310;
- const int PUBNUB_OPERATION_TIMEOUT_INTERVAL_IN_SEC = 60;
- const int PUBNUB_NETWORK_TCP_CHECK_INTERVAL_IN_SEC = 15;
- const int PUBNUB_NETWORK_CHECK_RETRIES = 50;
- const int PUBNUB_WEBREQUEST_RETRY_INTERVAL_IN_SEC = 10;
- bool OVERRIDE_TCP_KEEP_ALIVE = true;
- const LoggingMethod.Level LOG_LEVEL = LoggingMethod.Level.Error;
+ const int pubnubWebRequestCallbackIntervalInSeconds = 310;
+ const int pubnubOperationTimeoutIntervalInSeconds = 200;
+ const int pubnubNetworkTcpCheckIntervalInSeconds = 15;
+ const int pubnubNetworkCheckRetries = 50;
+ const int pubnubWebRequestRetryIntervalInSeconds = 10;
+ bool overrideTcpKeepAlive = true;
+ const LoggingMethod.Level pubnubLogLevel = LoggingMethod.Level.Error;
#if (!SILVERLIGHT && !WINDOWS_PHONE)
- bool ENABLE_PROXY_CONFIG = true;
+ bool pubnubEnableProxyConfig = true;
#endif
// Common property changed event
@@ -96,7 +96,7 @@ public PubnubProxy Proxy
if (string.IsNullOrEmpty(_pubnubProxy.ProxyServer) || (_pubnubProxy.ProxyPort <= 0) || string.IsNullOrEmpty(_pubnubProxy.ProxyUserName) || string.IsNullOrEmpty(_pubnubProxy.ProxyPassword))
{
_pubnubProxy = null;
- throw new MissingFieldException("Insufficient proxy details");
+ throw new MissingFieldException("Insufficient Proxy Details");
}
}
}
@@ -106,75 +106,75 @@ public PubnubProxy Proxy
private static bool _pubnetSystemActive = true;
- // History of Messages
- private List<object> _History = new List<object>();
- public List<object> History { get { return _History; } set { _History = value; RaisePropertyChanged("History"); } }
+ // History of Messages (Obsolete)
+ private List<object> _history = new List<object>();
+ public List<object> History { get { return _history; } set { _history = value; RaisePropertyChanged("History"); } }
// Subscribe
- private ConcurrentDictionary<string, object> _subscribeMsg = new ConcurrentDictionary<string, object>();
+ private ConcurrentDictionary<string, object> _subscribeMessage = new ConcurrentDictionary<string, object>();
// Presence
- private ConcurrentDictionary<string, object> _presenceMsg = new ConcurrentDictionary<string, object>();
+ private ConcurrentDictionary<string, object> _presenceMessage = new ConcurrentDictionary<string, object>();
// Timestamp
- private List<object> _Time = new List<object>();
+ private List<object> _time = new List<object>();
// Pubnub Core API implementation
- private string ORIGIN = "pubsub.pubnub.com";
- private string PUBLISH_KEY = "";
- private string SUBSCRIBE_KEY = "";
- private string SECRET_KEY = "";
- private string CIPHER_KEY = "";
- private bool SSL = false;
+ private string origin = "pubsub.pubnub.com";
+ private string publishKey = "";
+ private string subscribeKey = "";
+ private string secretKey = "";
+ private string cipherKey = "";
+ private bool ssl = false;
private string sessionUUID = "";
private string parameters = "";
/**
* Pubnub instance initialization function
*
- * @param string pubish_key.
- * @param string subscribe_key.
- * @param string secret_key.
- * @param bool ssl_on
+ * @param string publishKey.
+ * @param string subscribeKey.
+ * @param string secretKey.
+ * @param bool sslOn
*/
private void Init(string publishKey, string subscribeKey, string secretKey, string cipherKey, bool sslOn)
{
#if(MONOTOUCH || MONODROID || SILVERLIGHT || WINDOWS_PHONE)
- LoggingMethod.LogLevel = LOG_LEVEL;
+ LoggingMethod.LogLevel = pubnubLogLevel;
#else
- string strLogLevel = ConfigurationManager.AppSettings["PubnubMessaging.LogLevel"];
- int iLogLevel;
- if (!Int32.TryParse(strLogLevel, out iLogLevel))
+ string configuredLogLevel = ConfigurationManager.AppSettings["PubnubMessaging.LogLevel"];
+ int logLevelValue;
+ if (!Int32.TryParse(configuredLogLevel, out logLevelValue))
{
- LoggingMethod.LogLevel = LOG_LEVEL;
+ LoggingMethod.LogLevel = pubnubLogLevel;
}
else
{
- LoggingMethod.LogLevel = (LoggingMethod.Level)iLogLevel;
+ LoggingMethod.LogLevel = (LoggingMethod.Level)logLevelValue;
}
#endif
- this.PUBLISH_KEY = publishKey;
- this.SUBSCRIBE_KEY = subscribeKey;
- this.SECRET_KEY = secretKey;
- this.CIPHER_KEY = cipherKey;
- this.SSL = sslOn;
+ this.publishKey = publishKey;
+ this.subscribeKey = subscribeKey;
+ this.secretKey = secretKey;
+ this.cipherKey = cipherKey;
+ this.ssl = sslOn;
if (this.sessionUUID == "")
this.sessionUUID = Guid.NewGuid().ToString();
// SSL is ON?
- if (this.SSL)
- this.ORIGIN = "https://" + this.ORIGIN;
+ if (this.ssl)
+ this.origin = "https://" + this.origin;
else
- this.ORIGIN = "http://" + this.ORIGIN;
+ this.origin = "http://" + this.origin;
//Initiate System Events for PowerModeChanged - to monitor suspend/resume
InitiatePowerModeCheck();
}
private void ReconnectNetwork<T>(ReconnectState<T> netState)
{
- System.Threading.Timer timer = new Timer(new TimerCallback(ReconnectNetworkCallback<T>), netState, 0, PUBNUB_NETWORK_TCP_CHECK_INTERVAL_IN_SEC * 1000);
+ System.Threading.Timer timer = new Timer(new TimerCallback(ReconnectNetworkCallback<T>), netState, 0, pubnubNetworkTcpCheckIntervalInSeconds * 1000);
_channelReconnectTimer.AddOrUpdate(netState.channel, timer, (key, oldState) => timer);
}
@@ -196,7 +196,7 @@ void ReconnectNetworkCallback<T>(Object reconnectState)
else
{
_channelInternetRetry.AddOrUpdate(netState.channel, 1, (key, oldValue) => oldValue + 1);
- LoggingMethod.WriteToLog(string.Format("DateTime {0}, {1} {2} reconnectNetworkCallback. Retry {3} of {4}", DateTime.Now.ToString(), netState.channel, netState.type, _channelInternetRetry[netState.channel], PUBNUB_NETWORK_CHECK_RETRIES), LoggingMethod.LevelInfo);
+ LoggingMethod.WriteToLog(string.Format("DateTime {0}, {1} {2} reconnectNetworkCallback. Retry {3} of {4}", DateTime.Now.ToString(), netState.channel, netState.type, _channelInternetRetry[netState.channel], pubnubNetworkCheckRetries), LoggingMethod.LevelInfo);
}
}
@@ -221,7 +221,7 @@ void ReconnectNetworkCallback<T>(Object reconnectState)
break;
}
}
- else if (_channelInternetRetry[netState.channel] >= PUBNUB_NETWORK_CHECK_RETRIES)
+ else if (_channelInternetRetry[netState.channel] >= pubnubNetworkCheckRetries)
{
if (_channelReconnectTimer.ContainsKey(netState.channel))
{
@@ -276,31 +276,31 @@ void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
_pubnetSystemActive = false;
TerminatePendingWebRequest();
- if (OVERRIDE_TCP_KEEP_ALIVE)
+ if (overrideTcpKeepAlive)
{
heartBeatTimer.Change(Timeout.Infinite, Timeout.Infinite);
}
LoggingMethod.WriteToLog(string.Format("DateTime {0}, System entered into Suspend Mode.", DateTime.Now.ToString()), LoggingMethod.LevelInfo);
- if (OVERRIDE_TCP_KEEP_ALIVE)
+ if (overrideTcpKeepAlive)
{
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Disabled Timer for heartbeat ", DateTime.Now.ToString()), LoggingMethod.LevelInfo);
}
}
else if (e.Mode == PowerModes.Resume)
{
_pubnetSystemActive = true;
- if (OVERRIDE_TCP_KEEP_ALIVE)
+ if (overrideTcpKeepAlive)
{
heartBeatTimer.Change(
- (-1 == PUBNUB_NETWORK_TCP_CHECK_INTERVAL_IN_SEC) ? -1 : PUBNUB_NETWORK_TCP_CHECK_INTERVAL_IN_SEC * 1000,
- (-1 == PUBNUB_NETWORK_TCP_CHECK_INTERVAL_IN_SEC) ? -1 : PUBNUB_NETWORK_TCP_CHECK_INTERVAL_IN_SEC * 1000);
+ (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000,
+ (-1 == pubnubNetworkTcpCheckIntervalInSeconds) ? -1 : pubnubNetworkTcpCheckIntervalInSeconds * 1000);
}
LoggingMethod.WriteToLog(string.Format("DateTime {0}, System entered into Resume/Awake Mode.", DateTime.Now.ToString()), LoggingMethod.LevelInfo);
- if (OVERRIDE_TCP_KEEP_ALIVE)
+ if (overrideTcpKeepAlive)
{
LoggingMethod.WriteToLog(string.Format("DateTime {0}, Enabled Timer for heartbeat ", DateTime.Now.ToString()), LoggingMethod.LevelInfo);
}
@@ -329,28 +329,28 @@ private void TerminatePendingWebRequest(RequestState state)
}
else
{
- ConcurrentDictionary<string, RequestState> webReq = _channelRequest;
- ICollection<string> keyCol = _channelRequest.Keys;
- foreach (string key in keyCol)
+ ConcurrentDictionary<string, RequestState> webRequest = _channelRequest;
+ ICollection<string> keyCollection = _channelRequest.Keys;
+ foreach (string key in keyCollection)
{
- RequestState currReq = _channelRequest[key];
- if (currReq.request != null)
+ RequestState currentRequest = _channelRequest[key];
+ if (currentRequest.request != null)
{
- if (currReq.type == ResponseType.Subscribe)
+ if (currentRequest.type == ResponseType.Subscribe)
{
- Unsubscribe<string>(currReq.channel, null);
+ Unsubscribe<string>(currentRequest.channel, null);
}
- else if (currReq.type == ResponseType.Presence)
+ else if (currentRequest.type == ResponseType.Presence)
{
- PresenceUnsubscribe<string>(currReq.channel.Replace("-pnpres", ""), null);
+ PresenceUnsubscribe<string>(currentRequest.channel.Replace("-pnpres", ""), null);
}
else
{
- TerminateHeartbeatTimer(currReq.request.RequestUri);
- currReq.request.Abort();
- LoggingMethod.WriteToLog(string.Format("DateTime {0} TerminatePendingWebRequest {1}", DateTime.Now.ToString(), currReq.request.RequestUri.ToString()), LoggingMethod.LevelInfo);
+ TerminateHeartbeatTimer(currentRequest.request.RequestUri);
+ currentRequest.request.Abort();
+ LoggingMethod.WriteToLog(string.Format("DateTime {0} TerminatePendingWebRequest {1}", DateTime.Now.ToString(), currentRequest.request.RequestUri.ToString()), LoggingMethod.LevelInfo);
}
- bool removeKey = _channelRequest.TryRemove(key, out currReq);
+ bool removeKey = _channelRequest.TryRemove(key, out currentRequest);
if (!removeKey)
{
LoggingMethod.WriteToLog(string.Format("DateTime {0} Unable to remove web request from dictionary in TerminatePendingWebRequest for channel= {1}", DateTime.Now.ToString(), key), LoggingMethod.LevelError);
@@ -372,10 +372,10 @@ private void TerminatePendingWebRequest(RequestState state)
*
* Prepare Pubnub messaging class initial state
*
- * @param string pubish_key.
- * @param string subscribe_key.
- * @param string secret_key.
- * @param bool ssl_on
+ * @param string publishKey.
+ * @param string subscribeKey.
+ * @param string secretKey.
+ * @param bool sslOn
*/
public Pubnub(string publishKey, string subscribeKey, string secretKey, string cipherKey, bool sslOn)
{
@@ -387,44 +387,40 @@ public Pubnub(string publishKey, string subscribeKey, string secretKey, string c
*
* Prepare Pubnub messaging class initial state
*
- * @param string pubish_key.
- * @param string subscribe_key.
+ * @param string publishKey.
+ * @param string subscribeKey.
*/
public Pubnub(string publishKey, string subscribeKey)
{
this.Init(publishKey, subscribeKey, "", "", false);
}
- /**
- * PubNub 3.0 without SSL
- *
- * Prepare Pubnub messaging class initial state
- *
- * @param string pubish_key.
- * @param string subscribe_key.
- * @param string secret_key.
- */
+ /// <summary>
+ /// PubNub without SSL
+ /// Prepare Pubnub messaging class initial state
+ /// </summary>
+ /// <param name="publishKey"></param>
+ /// <param name="subscribeKey"></param>
+ /// <param name="secretKey"></param>
public Pubnub(string publishKey, string subscribeKey, string secretKey)
{
this.Init(publishKey, subscribeKey, secretKey, "", false);
}
- /**
- * History
- *
- * Load history from a channel
- *
- * @param String channel name.
- * @param int limit history count response
- * @return ListArray of history
- */
- [Obsolete("This method should no longer be used, please use detailedHistory() instead.")]
+ /// <summary>
+ /// History (Obsolete)
+ /// Load history from a channel
+ /// </summary>
+ /// <param name="channel"></param>
+ /// <param name="limit"></param>
+ /// <returns></returns>
+ [Obsolete("This method should no longer be used, please use DetailedHistory() instead.")]
public bool history(string channel, int limit)
{
List<string> url = new List<string>();
url.Add("history");
- url.Add(this.SUBSCRIBE_KEY);
+ url.Add(this.subscribeKey);
url.Add(channel);
url.Add("0");
url.Add(limit.ToString());
@@ -472,15 +468,14 @@ public bool DetailedHistory<T>(string channel, int count, Action<T> userCallback
return DetailedHistory<T>(channel, -1, -1, count, false, userCallback);
}
- /**
- * Publish
- *
- * Send a message to a channel
- *
- * @param String channel name.
- * @param List<object> info.
- * @return bool false on fail
- */
+ /// <summary>
+ /// Publish
+ /// Send a message to a channel
+ /// </summary>
+ /// <param name="channel"></param>
+ /// <param name="message"></param>
+ /// <param name="userCallback"></param>
+ /// <returns></returns>
public bool Publish(string channel, object message, Action<object> userCallback)
{
return Publish<object>(channel, message, userCallback);
@@ -493,7 +488,7 @@ public bool Publish<T>(string channel, object message, Action<T> userCallback)
throw new ArgumentException("Missing Channel or Message");
}
- if (string.IsNullOrEmpty(this.PUBLISH_KEY) || string.IsNullOrEmpty(this.PUBLISH_KEY.Trim()) || this.PUBLISH_KEY.Length <= 0)
+ if (string.IsNullOrEmpty(this.publishKey) || string.IsNullOrEmpty(this.publishKey.Trim()) || this.publishKey.Length <= 0)
{
throw new MissingFieldException("Invalid publish key");
}
@@ -508,24 +503,24 @@ public bool Publish<T>(string channel, object message, Action<T> userCallback)
return UrlProcessRequest<T>(request, channel, ResponseType.Publish, userCallback, null, false); //connectCallback = null
}
- private string JsonEncodePublishMsg(object originalMsg)