Last active
February 19, 2016 08:10
-
-
Save lemmit/1af0289a30021e31da92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.AspNet.SignalR; | |
namespace SignalRHubConvetionTest | |
{ | |
class GoodHub : Hub | |
{ | |
} | |
class BadHub : Hub | |
{ | |
public string Method(string heh) | |
{ | |
return "A"; | |
} | |
public string Method(int heh) | |
{ | |
return "A"; | |
} | |
public string Method(int heh, string hehe) | |
{ | |
return "A"; | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var failedHubs = Test(); | |
foreach (var hub in failedHubs) | |
{ | |
Console.WriteLine(hub.Name); | |
} | |
Console.WriteLine(!failedHubs.Any() ? "Test OK" : "Test Failed"); | |
} | |
static IEnumerable<Type> Test() | |
{ | |
var hubs = AppDomain | |
.CurrentDomain | |
.GetAssemblies() | |
.SelectMany(domainAssembly => | |
domainAssembly | |
.GetTypes() | |
.Where(assemblyType => | |
typeof(Microsoft.AspNet.SignalR.Hub).IsAssignableFrom(assemblyType)) | |
); | |
return hubs.Where(hub => | |
hub.GetMethods() | |
.GroupBy(method => method.GetParameters().Count() + method.Name) | |
.Any(grouping => grouping.Count() > 1) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment