Permalink
Browse files

Added tests to verify we don't parse groups on connect requests.

  • Loading branch information...
1 parent 70da9f0 commit c7c5a47a73ac3f68a17f1c2b37877835824bdc3d @davidfowl davidfowl committed Mar 22, 2012
Showing with 62 additions and 0 deletions.
  1. +61 −0 SignalR.Tests/PersistentConnectionFacts.cs
  2. +1 −0 SignalR.Tests/SignalR.Tests.csproj
@@ -0,0 +1,61 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using SignalR.Hosting.Memory;
+using Xunit;
+using System.Threading;
+using System;
+using System.Linq;
+
+namespace SignalR.Tests
+{
+ public class PersistentConnectionFacts
+ {
+ public class OnConnectedAsync
+ {
+ [Fact]
+ public void GroupsAreNotReadOnConnectedAsync()
+ {
+ var host = new MemoryHost();
+ host.MapConnection<MyConnection>("/echo");
+
+ var connection = new Client.Connection("http://foo/echo");
+ connection.Groups = new List<string> { typeof(MyConnection).FullName + ".test" };
+ connection.Received += data =>
+ {
+ Assert.False(true, "Unexpectedly received data");
+ };
+
+ connection.Start(host).Wait();
+
+ Thread.Sleep(TimeSpan.FromSeconds(10));
+ }
+
+ [Fact]
+ public void GroupsAreNotReadOnConnectedAsyncLongPolling()
+ {
+ var host = new MemoryHost();
+ host.MapConnection<MyConnection>("/echo");
+
+ var connection = new Client.Connection("http://foo/echo");
+ connection.Groups = new List<string> { typeof(MyConnection).FullName + ".test" };
+ connection.Received += data =>
+ {
+ Assert.False(true, "Unexpectedly received data");
+ };
+
+ var transport = new Client.Transports.LongPollingTransport(host);
+ connection.Start(transport).Wait();
+
+ Thread.Sleep(TimeSpan.FromSeconds(10));
+ }
+ }
+ }
+
+ public class MyConnection : PersistentConnection
+ {
+ protected override Task OnConnectedAsync(Hosting.IRequest request, string connectionId)
+ {
+ return SendToGroup("test", "hey");
+ }
+ }
+}
@@ -60,6 +60,7 @@
<Compile Include="HubProxyTest.cs" />
<Compile Include="InProcessMessageBusFacts.cs" />
<Compile Include="DefaultActionResolverTest.cs" />
+ <Compile Include="PersistentConnectionFacts.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

0 comments on commit c7c5a47

Please sign in to comment.