Permalink
Browse files

unit tests converted

  • Loading branch information...
1 parent 38cb95b commit e8116ef6a582a2daed6c8be79bca693afc65239b Petro committed Nov 17, 2012
Showing with 449 additions and 253 deletions.
  1. +1 −3 silverlight-part/PubNub-Messaging.Tests/PubNub-Messaging.Tests.csproj
  2. BIN silverlight-part/PubNub-Messaging.Tests/bin/Debug/PubNub-Messaging.Tests.dll
  3. BIN silverlight-part/PubNub-Messaging.Tests/bin/Debug/PubNub-Messaging.Tests.pdb
  4. BIN silverlight-part/PubNub-Messaging.Tests/obj/Debug/PubNub-Messaging.Tests.dll
  5. BIN silverlight-part/PubNub-Messaging.Tests/obj/Debug/PubNub-Messaging.Tests.pdb
  6. BIN silverlight-part/PubnubSilverlight.Core/Bin/Debug/PubnubSilverlight.Core.dll
  7. BIN silverlight-part/PubnubSilverlight.Core/Bin/Debug/PubnubSilverlight.Core.pdb
  8. BIN silverlight-part/PubnubSilverlight.Core/Bin/Debug/PubnubSilverlight.Imports.dll
  9. BIN silverlight-part/PubnubSilverlight.Core/Bin/Debug/PubnubSilverlight.Imports.pdb
  10. +1 −1 silverlight-part/PubnubSilverlight.Core/PubnubV3.cs
  11. BIN ...part/PubnubSilverlight.Core/obj/Debug/PubnubSilverlight.Core.csprojResolveAssemblyReference.cache
  12. BIN silverlight-part/PubnubSilverlight.Core/obj/Debug/PubnubSilverlight.Core.dll
  13. BIN silverlight-part/PubnubSilverlight.Core/obj/Debug/PubnubSilverlight.Core.pdb
  14. BIN silverlight-part/PubnubSilverlight.Example.Web/ClientBin/PubnubSilverlight.Example.xap
  15. BIN silverlight-part/PubnubSilverlight.Example.Web/bin/PubnubSilverlight.Web.dll
  16. BIN silverlight-part/PubnubSilverlight.Example.Web/bin/PubnubSilverlight.Web.pdb
  17. BIN silverlight-part/PubnubSilverlight.Example.Web/obj/Debug/PubnubSilverlight.Web.dll
  18. BIN silverlight-part/PubnubSilverlight.Example.Web/obj/Debug/PubnubSilverlight.Web.pdb
  19. BIN silverlight-part/PubnubSilverlight.Example.suo
  20. BIN silverlight-part/PubnubSilverlight.Example/Bin/Debug/PubnubSilverlight.Example.dll
  21. BIN silverlight-part/PubnubSilverlight.Example/Bin/Debug/PubnubSilverlight.Example.pdb
  22. BIN silverlight-part/PubnubSilverlight.Example/Bin/Debug/PubnubSilverlight.Example.xap
  23. BIN silverlight-part/PubnubSilverlight.Example/Bin/Debug/PubnubSilverlight.UnitTest.dll
  24. BIN silverlight-part/PubnubSilverlight.Example/Bin/Debug/PubnubSilverlight.UnitTest.pdb
  25. BIN silverlight-part/PubnubSilverlight.Example/obj/Debug/DesignTimeResolveAssemblyReferences.cache
  26. +2 −2 ...ht-part/PubnubSilverlight.Example/obj/Debug/PubnubSilverlight.Example.csproj.FileListAbsolute.txt
  27. BIN ...ubnubSilverlight.Example/obj/Debug/PubnubSilverlight.Example.csprojResolveAssemblyReference.cache
  28. BIN silverlight-part/PubnubSilverlight.Example/obj/Debug/PubnubSilverlight.Example.dll
  29. BIN silverlight-part/PubnubSilverlight.Example/obj/Debug/PubnubSilverlight.Example.pdb
  30. +4 −4 silverlight-part/PubnubSilverlight.Example/obj/Debug/XapCacheFile.xml
  31. BIN silverlight-part/PubnubSilverlight.Imports/Bin/Debug/PubnubSilverlight.Imports.dll
  32. BIN silverlight-part/PubnubSilverlight.Imports/Bin/Debug/PubnubSilverlight.Imports.pdb
  33. +1 −0 silverlight-part/PubnubSilverlight.Imports/PubnubSilverlight.Imports.csproj
  34. +40 −0 silverlight-part/PubnubSilverlight.Imports/Trace.cs
  35. BIN silverlight-part/PubnubSilverlight.Imports/obj/Debug/PubnubSilverlight.Imports.dll
  36. BIN silverlight-part/PubnubSilverlight.Imports/obj/Debug/PubnubSilverlight.Imports.pdb
  37. BIN silverlight-part/PubnubSilverlight.UnitTest/Bin/Debug/PubnubSilverlight.UnitTest.dll
  38. BIN silverlight-part/PubnubSilverlight.UnitTest/Bin/Debug/PubnubSilverlight.UnitTest.pdb
  39. BIN silverlight-part/PubnubSilverlight.UnitTest/Bin/Debug/PubnubSilverlight.UnitTest.xap
  40. +6 −0 silverlight-part/PubnubSilverlight.UnitTest/PubnubSilverlight.UnitTest.csproj
  41. +37 −36 silverlight-part/PubnubSilverlight.UnitTest/WhenAClientIsPresented.cs
  42. +220 −174 silverlight-part/PubnubSilverlight.UnitTest/WhenAMessageIsPublished.cs
  43. +49 −31 silverlight-part/PubnubSilverlight.UnitTest/WhenDetailedHistoryIsRequested.cs
  44. BIN silverlight-part/PubnubSilverlight.UnitTest/obj/Debug/PubnubSilverlight.UnitTest.dll
  45. BIN silverlight-part/PubnubSilverlight.UnitTest/obj/Debug/PubnubSilverlight.UnitTest.pdb
  46. +2 −2 silverlight-part/PubnubSilverlight.UnitTest/obj/Debug/XapCacheFile.xml
  47. +56 −0 silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14.trx
  48. BIN silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/Newtonsoft.Json.dll
  49. BIN silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/PubNub-Messaging.Tests.pdb
  50. BIN silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/PubNub-Messaging.exe
  51. BIN silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/PubNub-Messaging.pdb
  52. +8 −0 silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/pubnub-messaging.log
  53. BIN silverlight-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/pubnub-messaging.tests.dll
  54. +22 −0 ...light-part/TestResults/Jhonny_JHONNY-PC 2012-11-17 22_37_14/Out/pubnub-messaging.tests.dll.config
@@ -51,9 +51,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="WhenSubscribedToAChannel.cs">
- <SubType>Code</SubType>
- </Compile>
+ <Compile Include="WhenAClientIsPresented.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PubNub-Messaging\PubNub-Messaging.csproj">
@@ -56,9 +56,9 @@ public void RaisePropertyChanged(string propertyName)
private static bool _pubnetSystemActive = true;
+
//private static TraceSwitch appSwitch = new TraceSwitch("PubnubTraceSwitch", "Pubnub Trace Switch in config file"); *Changed*
-
// Publish
private ConcurrentDictionary<string, object> _publishMsg = new ConcurrentDictionary<string, object>();
Binary file not shown.
@@ -10,12 +10,10 @@ C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.E
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\System.Windows.Controls.dll
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\System.Windows.Controls.Navigation.dll
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\ConcurrentHashtable_Silverlight.dll
-C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Imports.dll
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Core.pdb
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.UnitTest.pdb
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\System.Windows.Controls.xml
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\System.Windows.Controls.Navigation.xml
-C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Imports.pdb
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\ar\System.Windows.Controls.resources.dll
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\bg\System.Windows.Controls.resources.dll
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\ca\System.Windows.Controls.resources.dll
@@ -77,3 +75,5 @@ C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.E
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\obj\Debug\PubnubSilverlight.Example.pdb
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\obj\Debug\XapCacheFile.xml
C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\Newtonsoft.Json.dll
+C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Imports.dll
+C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Imports.pdb
@@ -1,13 +1,13 @@
-<xapCache source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Example.xap" wasSigned="False" certificateThumbprint="" TimeStampUrl="" lastWriteTime="11/17/2012 3:02:39 AM">
- <file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\obj\Debug\PubnubSilverlight.Example.dll" archivePath="PubnubSilverlight.Example.dll" lastWriteTime="11/17/2012 3:02:37 AM" />
+<xapCache source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\PubnubSilverlight.Example.xap" wasSigned="False" certificateThumbprint="" TimeStampUrl="" lastWriteTime="11/18/2012 12:12:42 AM">
+ <file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\obj\Debug\PubnubSilverlight.Example.dll" archivePath="PubnubSilverlight.Example.dll" lastWriteTime="11/18/2012 12:12:40 AM" />
<file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\Libraries\Microsoft.Silverlight.Testing.dll" archivePath="Microsoft.Silverlight.Testing.dll" lastWriteTime="11/16/2012 9:22:28 PM" />
<file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\Libraries\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll" archivePath="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll" lastWriteTime="11/16/2012 9:22:28 PM" />
<file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Core\Bin\Debug\PubnubSilverlight.Core.dll" archivePath="PubnubSilverlight.Core.dll" lastWriteTime="11/17/2012 1:20:50 AM" />
- <file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.UnitTest\Bin\Debug\PubnubSilverlight.UnitTest.dll" archivePath="PubnubSilverlight.UnitTest.dll" lastWriteTime="11/17/2012 3:02:35 AM" />
+ <file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.UnitTest\Bin\Debug\PubnubSilverlight.UnitTest.dll" archivePath="PubnubSilverlight.UnitTest.dll" lastWriteTime="11/18/2012 12:12:38 AM" />
<file source="C:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client\System.Windows.Controls.dll" archivePath="System.Windows.Controls.dll" lastWriteTime="11/18/2011 5:40:20 PM" />
<file source="C:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client\System.Windows.Controls.Navigation.dll" archivePath="System.Windows.Controls.Navigation.dll" lastWriteTime="11/18/2011 5:40:20 PM" />
<file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Core\Bin\Debug\ConcurrentHashtable_Silverlight.dll" archivePath="ConcurrentHashtable_Silverlight.dll" lastWriteTime="11/16/2012 9:22:28 PM" />
<file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Core\Bin\Debug\Newtonsoft.Json.dll" archivePath="Newtonsoft.Json.dll" lastWriteTime="10/7/2012 11:48:54 PM" />
<file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.UnitTest\Bin\Debug\PubnubSilverlight.Imports.dll" archivePath="PubnubSilverlight.Imports.dll" lastWriteTime="11/17/2012 12:43:16 AM" />
- <file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\AppManifest.xaml" archivePath="AppManifest.xaml" lastWriteTime="11/16/2012 11:27:58 PM" />
+ <file source="C:\Users\Jhonny\Documents\GitHub\pubnub-api\silverlight-part\PubnubSilverlight.Example\Bin\Debug\AppManifest.xaml" archivePath="AppManifest.xaml" lastWriteTime="11/17/2012 11:36:37 PM" />
</xapCache>
@@ -67,6 +67,7 @@
<Compile Include="JavaScriptConverter.cs" />
<Compile Include="JavaScriptSerializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Trace.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<ProjectExtensions>
@@ -0,0 +1,40 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.IO.IsolatedStorage;
+using System.IO;
+
+namespace System.Diagnostics
+{
+ public class Trace
+ {
+ private static IsolatedStorageFile _storageFile = null;
+ private static IsolatedStorageFileStream _storageFileStream = null;
+ private static StreamWriter _streamWriter = null;
+
+ public static Trace()
+ {
+ _storageFile = IsolatedStorageFile.GetUserStoreForApplication();
+ _storageFileStream = _storageFile.OpenFile("Trace.log", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
+ _streamWriter = new StreamWriter(_storageFileStream);
+ _streamWriter.AutoFlush = true;
+ }
+
+ ~Trace()
+ {
+ _storageFileStream.Close();
+ }
+
+ public static void WriteLine(String message)
+ {
+ _streamWriter.WriteLine(message);
+ }
+ }
+}
@@ -95,6 +95,12 @@
</Compile>
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="WhenAClientIsPresented.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="WhenAMessageIsPublished.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="WhenGetRequestServerTime.cs">
<SubType>Code</SubType>
</Compile>
@@ -10,44 +10,44 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PubnubSilverlight.Core;
+using Microsoft.Silverlight.Testing;
namespace PubnubSilverlight.UnitTest
{
[TestClass]
- public class WhenAClientIsPresented
+ public class WhenAClientIsPresented : SilverlightTest
{
- ManualResetEvent manualEvent1 = new ManualResetEvent(false);
- ManualResetEvent manualEvent2 = new ManualResetEvent(false);
- ManualResetEvent manualEvent3 = new ManualResetEvent(false);
-
- ManualResetEvent manualEvent4 = new ManualResetEvent(false);
-
static bool receivedFlag1 = false;
static bool receivedFlag2 = false;
+ bool isPresenceReturnMessage = false;
+ bool isSubscribed = false;
+ bool isUnSubscribed = false;
+ bool isHereNowReturnMessage = false;
+
[TestMethod]
+ [Asynchronous]
public void ThenPresenceShouldReturnReceivedMessage()
{
receivedFlag1 = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
string channel = "my/channel";
- pubnub.presence<string>(channel, ThenPresenceShouldReturnMessage);
-
- //since presence expects from stimulus from sub/unsub...
- pubnub.subscribe<string>(channel, DummyMethodForSubscribe);
- manualEvent1.WaitOne(2000);
+ EnqueueCallback(() => pubnub.presence<string>(channel, ThenPresenceShouldReturnMessage));
+ EnqueueCallback(() => pubnub.subscribe<string>(channel, DummyMethodForSubscribe));
+ EnqueueConditional(() => isSubscribed);
+ EnqueueCallback(() => pubnub.unsubscribe<string>(channel, DummyMethodForUnSubscribe));
+ EnqueueConditional(() => isUnSubscribed);
+ EnqueueConditional(() => isPresenceReturnMessage);
+ EnqueueCallback(() => Assert.IsTrue(receivedFlag1, "Presence message not received"));
- pubnub.unsubscribe<string>(channel, DummyMethodForUnSubscribe);
- manualEvent3.WaitOne(2000);
-
- manualEvent2.WaitOne(310 * 1000);
- Assert.IsTrue(receivedFlag1, "Presence message not received");
+ EnqueueTestComplete();
}
- void ThenPresenceShouldReturnMessage(string receivedMessage)
+ [Asynchronous]
+ public void ThenPresenceShouldReturnMessage(string receivedMessage)
{
try
{
@@ -63,27 +63,28 @@ void ThenPresenceShouldReturnMessage(string receivedMessage)
}
}
catch { }
- finally
- {
- manualEvent2.Set();
- }
+
+ isPresenceReturnMessage = true;
}
[TestMethod]
+ [Asynchronous]
public void IfHereNowIsCalledThenItShouldReturnInfo()
{
- receivedFlag2 = false;
-
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
string channel = "my/channel";
- pubnub.here_now<string>(channel, ThenHereNowShouldReturnMessage);
- manualEvent4.WaitOne();
- Assert.IsTrue(receivedFlag2, "here_now message not received");
+
+ EnqueueCallback(() => pubnub.here_now<string>(channel, ThenHereNowShouldReturnMessage));
+ EnqueueConditional(() => isHereNowReturnMessage);
+ EnqueueCallback(() => Assert.IsTrue(receivedFlag2, "here_now message not received"));
+
+ EnqueueTestComplete();
}
- void ThenHereNowShouldReturnMessage(string receivedMessage)
+ [Asynchronous]
+ public void ThenHereNowShouldReturnMessage(string receivedMessage)
{
try
{
@@ -99,21 +100,21 @@ void ThenHereNowShouldReturnMessage(string receivedMessage)
}
}
catch { }
- finally
- {
- manualEvent4.Set();
- }
+
+ isHereNowReturnMessage = true;
}
- void DummyMethodForSubscribe(string receivedMessage)
+ [Asynchronous]
+ public void DummyMethodForSubscribe(string receivedMessage)
{
- manualEvent1.Set();
+ isSubscribed = true;
//Dummary callback method for subscribe and unsubscribe to test presence
}
- void DummyMethodForUnSubscribe(string receivedMessage)
+ [Asynchronous]
+ public void DummyMethodForUnSubscribe(string receivedMessage)
{
- manualEvent3.Set();
+ isUnSubscribed = true;
//Dummary callback method for unsubscribe to test presence
}
}
Oops, something went wrong.

0 comments on commit e8116ef

Please sign in to comment.