public void HubWithMethodsHasHubMethods() { var hubType = typeof(BaseMethodHub); var hubMethods = HubReflectionHelper.GetHubMethods(hubType); Assert.Equal(3, hubMethods.Count()); Assert.Contains(hubMethods, m => m == hubType.GetMethod("VoidMethod")); Assert.Contains(hubMethods, m => m == hubType.GetMethod("IntMethod")); Assert.Contains(hubMethods, m => m == hubType.GetMethod("ArgMethod")); }
public void InheritedHubHasBaseHubMethodsAndOwnMethods() { var hubType = typeof(InheritedMethodHub); var hubMethods = HubReflectionHelper.GetHubMethods(hubType); Assert.Equal(4, hubMethods.Count()); Assert.Contains(hubMethods, m => m == hubType.GetMethod("ExtraMethod")); Assert.Contains(hubMethods, m => m == hubType.GetMethod("VoidMethod")); Assert.Contains(hubMethods, m => m == hubType.GetMethod("IntMethod")); Assert.Contains(hubMethods, m => m == hubType.GetMethod("ArgMethod")); }
private void DiscoverHubMethods() { var hubType = typeof(THub); var hubTypeInfo = hubType.GetTypeInfo(); foreach (var methodInfo in HubReflectionHelper.GetHubMethods(hubType)) { var methodName = methodInfo.Name; if (_methods.ContainsKey(methodName)) { throw new NotSupportedException($"Duplicate definitions of '{methodName}'. Overloading is not supported."); } var executor = ObjectMethodExecutor.Create(methodInfo, hubTypeInfo); var authorizeAttributes = methodInfo.GetCustomAttributes <AuthorizeAttribute>(inherit: true); _methods[methodName] = new HubMethodDescriptor(executor, authorizeAttributes); _logger.HubMethodBound(methodName); } }
public void EmptyHubHasNoHubMethods() { var hubMethods = HubReflectionHelper.GetHubMethods(typeof(EmptyHub)); Assert.Empty(hubMethods); }