public void GetValidHubMethodsWithPredicate() { var resolver = new DefaultDependencyResolver(); var hubManager = new DefaultHubManager(resolver); var methodDescriptors = hubManager.GetHubMethods("CoreTestHubWithMethod", descriptor => descriptor.Name == "AddNumbers"); Assert.NotNull(methodDescriptors); Assert.Equal(methodDescriptors.First().Name, "AddNumbers"); }
public void GetValidHubMethodsWithInvalidPredicate() { var resolver = new DefaultDependencyResolver(); var hubManager = new DefaultHubManager(resolver); var methodDescriptors = hubManager.GetHubMethods("CoreTestHubWithMethod", descriptor => descriptor.Name == "______AddNumbers______"); // Still have an ienumerable sequence Assert.NotNull(methodDescriptors); // But there's nothing in the ienumerable Assert.Empty(methodDescriptors); }
public void GetHubMethodsWithInvalidHubThrows() { var hub = new HubDescriptor() { Name = "this.is.not.valid" }; var resolver = new DefaultDependencyResolver(); resolver.Register(typeof(IHubDescriptorProvider), () => new TestHubDescriptorProvider(hub)); var hubManager = new DefaultHubManager(resolver); var ex = Assert.Throws <InvalidOperationException>(() => hubManager.GetHubMethods(hub.Name, predicate: null)); Assert.Equal(string.Format(Resources.Error_HubNameIsInvalid, hub.Name), ex.Message); }
public List <ServiceInfo> GetServiceContracts() { var list = new List <ServiceInfo>(); var serviceInfo = new ServiceInfo(); foreach (var hub in _hubmanager.GetHubs()) { Type hubType = hub.HubType; string moduleName = hubType.Namespace; string interfaceName = hubType.Name; serviceInfo.ModuleName = moduleName; serviceInfo.InterfaceName = interfaceName; Type clientType = TypeHelper.ClientType(hubType); string clientTypeName = clientType != null ? clientType.FullName : "any"; serviceInfo.ClientType = clientTypeName; // Server type and functions string serverType = hubType.Name + "Server"; string serverFullNamespace = hubType.FullName + "Server"; serviceInfo.ServerType = serverType; serviceInfo.ServerTypeFullNamespace = serverFullNamespace; foreach (var method in _hubmanager.GetHubMethods(hub.Name)) { var ps = method.Parameters.Select(x => x.Name + " : " + TypeHelper.GetTypeContractName(x.ParameterType)); var functionDetails = new FunctionDetails() { Name = _typeHelper.FirstCharLowered(method.Name), Arguments = "(" + string.Join(", ", ps) + ")", ReturnType = "JQueryPromise<" + TypeHelper.GetTypeContractName(method.ReturnType) + ">" }; serviceInfo.ServerFunctions.Add(functionDetails); } list.Add(serviceInfo); } return(list); }
public List <ServiceInfo> GetServiceContracts() { var list = new List <ServiceInfo>(); foreach (var hub in hubmanager.GetHubs()) { var hubMethods = hubmanager.GetHubMethods(hub.Name).Select(GetServiceMethod).ToList(); var hubType = hub.HubType; var clientType = typeHelper.ClientType(hubType); string reasonDeprecated; var isDeprecated = hub.HubType.IsDeprecated(out reasonDeprecated); list.Add(new ServiceInfo( hubType.Name, isDeprecated, reasonDeprecated, hubType.Namespace, clientType != null ? clientType.FullName : "any", hubType.Name + "Server", hubMethods)); } return(list); }