public void GetHubMethodFromValidHubWhenInvalidHubIsRegisteredDoesNotThrow() { var validHub = new HubDescriptor() { Name = "Valid" }; var invalidHub = new HubDescriptor() { Name = "this.is.not.valid" }; var method = new MethodDescriptor() { Name = "Method", Parameters = new List <ParameterDescriptor>() }; var resolver = new DefaultDependencyResolver(); resolver.Register(typeof(IHubDescriptorProvider), () => new TestHubDescriptorProvider(validHub, invalidHub)); resolver.Register(typeof(IMethodDescriptorProvider), () => new TestMethodDescriptorProvider(validHub.Name, method)); var hubManager = new DefaultHubManager(resolver); Assert.Same( method, hubManager.GetHubMethod(validHub.Name, "Method", Array.Empty <IJsonValue>())); }
public void GetInvalidHubMethod() { var resolver = new DefaultDependencyResolver(); var hubManager = new DefaultHubManager(resolver); // The AddNumbers method has 2 parameters, so should not find the method var methodDescriptor = hubManager.GetHubMethod("CoreTestHubWithMethod", "AddNumbers", null); Assert.Null(methodDescriptor); }
public void GetHubMethodFromInvalidHub() { var resolver = new DefaultDependencyResolver(); var hubManager = new DefaultHubManager(resolver); // There is no ________________CoreTestHubWithMethod________________ name var methodDescriptor = hubManager.GetHubMethod("________________CoreTestHubWithMethod________________", "AddNumbers", new IJsonValue[] { null, null }); Assert.Null(methodDescriptor); }
public void MatchSuccessful() { var resolver = new DefaultDependencyResolver(); var hubManager = new DefaultHubManager(resolver); // Should be AddNumbers MethodDescriptor methodDescriptor = hubManager.GetHubMethod("CoreTestHubWithMethod", "AddNumbers", new IJsonValue[] { null, null }); // We should find our method descriptor Assert.NotNull(methodDescriptor); // Value does not matter, hence the null; Assert.True(methodDescriptor.Matches(new IJsonValue[] { null, null })); }
public void GetHubMethodFromInvalidHubThrows() { 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.GetHubMethod(hub.Name, "Method", new IJsonValue[] { null, null })); Assert.Equal(string.Format(Resources.Error_HubNameIsInvalid, hub.Name), ex.Message); }
public void GetValidHubMethod() { var resolver = new DefaultDependencyResolver(); var hubManager = new DefaultHubManager(resolver); var methodDescriptor = hubManager.GetHubMethod("CoreTestHubWithMethod", "AddNumbers", new IJsonValue[] { null, null }); Assert.NotNull(methodDescriptor); Assert.Equal(methodDescriptor.Name, "AddNumbers"); Assert.Equal(methodDescriptor.ReturnType, typeof(int)); IList <ParameterDescriptor> parameters = methodDescriptor.Parameters; Assert.Equal(parameters.Count, 2); Assert.Equal(parameters[0].Name, "first"); Assert.Equal(parameters[0].ParameterType, typeof(int)); Assert.Equal(parameters[1].Name, "second"); Assert.Equal(parameters[1].ParameterType, typeof(int)); }