Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added unit tests for hub resolver

  • Loading branch information...
commit 334ffa06effb38a4862a7ac2b2c1af99307b2e67 1 parent cd18cf9
@pszmyd authored
View
86 SignalR.Tests/DefaultHubResolverTest.cs
@@ -0,0 +1,86 @@
+using SignalR.Hubs;
+using Xunit;
+
+namespace SignalR.Tests
+{
+ public class DefaultHubResolverTest
+ {
+ [Fact]
+ public void ShouldResolveHubByTypeName()
+ {
+ var resolver = new DefaultDependencyResolver();
+ var hubResolver = new ReflectedHubDescriptorProvider(resolver);
+ HubDescriptor hub;
+ hubResolver.TryGetHub("HubWithoutAttribute", out hub);
+
+ Assert.NotNull(hub);
+ Assert.Equal(hub.Name, "HubWithoutAttribute");
+ }
+
+ [Fact]
+ public void ShouldResolveHubByHubNameAttribute()
+ {
+ var resolver = new DefaultDependencyResolver();
+ var hubResolver = new ReflectedHubDescriptorProvider(resolver);
+ HubDescriptor hub;
+ hubResolver.TryGetHub("NameFromAttribute", out hub);
+
+ Assert.NotNull(hub);
+ Assert.Equal(hub.Name, "NameFromAttribute");
+ }
+
+ [Fact]
+ public void ShouldNotResolveHubByFullTypeName()
+ {
+ var resolver = new DefaultDependencyResolver();
+ var hubResolver = new ReflectedHubDescriptorProvider(resolver);
+ HubDescriptor hub;
+ hubResolver.TryGetHub("SignalR.Tests.HubWithoutAttribute", out hub);
+
+ Assert.Null(hub);
+ }
+
+ [Fact]
+ public void ShouldNotResolveHubByTypeNameIfAttributeExists()
+ {
+ var resolver = new DefaultDependencyResolver();
+ var hubResolver = new ReflectedHubDescriptorProvider(resolver);
+ HubDescriptor hub;
+ hubResolver.TryGetHub("HubWithAttribute", out hub);
+
+ Assert.Null(hub);
+ }
+
+ [Fact]
+ public void ShouldIgnoreCaseWhenDiscoveringHubs()
+ {
+ var resolver = new DefaultDependencyResolver();
+ var hubResolver = new ReflectedHubDescriptorProvider(resolver);
+ HubDescriptor hub;
+ hubResolver.TryGetHub("hubwithoutattribute", out hub);
+
+ Assert.NotNull(hub);
+ Assert.Equal(hub.Name, "HubWithoutAttribute");
+ }
+
+ [Fact]
+ public void ShouldIgnoreCaseWhenDiscoveringHubsUsingManager()
+ {
+ var resolver = new DefaultDependencyResolver();
+ var manager = new DefaultHubManager(resolver);
+ var hub = manager.GetHub("hubwithoutattribute");
+
+ Assert.NotNull(hub);
+ Assert.Equal(hub.Name, "HubWithoutAttribute");
+ }
+
+ [HubName("NameFromAttribute")]
+ public class HubWithAttribute : Hub
+ {
+ }
+
+ public class HubWithoutAttribute : Hub
+ {
+ }
+ }
+}
View
3  SignalR.Tests/SignalR.Tests.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -53,6 +53,7 @@
<ItemGroup>
<Compile Include="ChunkBufferFacts.cs" />
<Compile Include="ConnectionFacts.cs" />
+ <Compile Include="DefaultHubResolverTest.cs" />
<Compile Include="DisconnectFacts.cs" />
<Compile Include="HubProxyTest.cs" />
<Compile Include="InProcessMessageBusFacts.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.