상속: IHubManager
        public void EnsureHubThrowsWhenCantResolve()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);

            Assert.Throws<InvalidOperationException>(() => hubManager.EnsureHub("__ELLO__"));
        }
        public void GetInValidHub()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptor = hubManager.GetHub("__ELLO__");

            Assert.Null(hubDescriptor);
        }
        public void GetValidHubsWithValidPredicate()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(descriptor => descriptor.Name == "CoreTestHub");

            Assert.NotNull(hubDescriptors);
            Assert.Equal(hubDescriptors.First().Name, "CoreTestHub");
        }
예제 #4
0
        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 GetValidHub()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptor = hubManager.GetHub("CoreTestHub");

            Assert.NotNull(hubDescriptor);
            Assert.False(hubDescriptor.NameSpecified);
        }
예제 #6
0
        public void GetHubMethodFromInvalidHub()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            // There is no ________________CoreTestHubWithMethod________________ name
            var methodDescriptor = hubManager.GetHubMethod("________________CoreTestHubWithMethod________________", "AddNumbers", null, null);

            Assert.Null(methodDescriptor);
        }
        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");
            Assert.Equal(hub.NameSpecified, false);
        }
        public void GetValidHubsWithInvalidPredicate()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(descriptor => descriptor.Name == "CoreTestHub_INVALIDHUB_____");

            // Still have an ienumerable sequence
            Assert.NotNull(hubDescriptors);
            // But there's nothing in the ienumerable
            Assert.Empty(hubDescriptors);
        }
예제 #9
0
        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 GetValidHubsWithoutPredicate()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(predicate: null);

            Assert.NotNull(hubDescriptors);

            HubDescriptor coreTestHub = hubDescriptors.First(descriptor => descriptor.Name == "CoreTestHub");

            Assert.NotNull(coreTestHub);
        }
예제 #11
0
        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 EnsureHubSuccessfullyResolves()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var TestHubName = "CoreTestHubWithMethod";

            HubDescriptor hub = null,
                          actualDescriptor = hubManager.GetHub(TestHubName);

            Assert.DoesNotThrow(() =>
            {
                hub = hubManager.EnsureHub(TestHubName);
            });

            Assert.Equal(hub, actualDescriptor);
        }
        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));
        }
예제 #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var hubManager = new DefaultHubManager(GlobalHost.DependencyResolver);
        _hub = hubManager.ResolveHub("WebHub") as WebHub;
        string req = Request.QueryString["op"];
        Response.Clear();
        OutputCls status = new OutputCls();
        if (req == "signin")
        {
            string username = Request["username"];
            string password = Request["password"];
            var output = _hub.Login(username, password);

            Response.ContentType = "application/json; charset=utf-8";
            
            if (output.Result.Value)
            {
                FormsAuthentication.SetAuthCookie(username, false);
               
                //var test = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
                status.Result = true;
                Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(status));
            }
            else
            {
                status.Result = false;
                Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(status));
            }

        }
        else
        {
            status.Result = false;
            Response.ContentType = "application/json";
            HttpContext.Current.Session.Abandon();
            FormsAuthentication.SignOut();
            Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(status));
        }
        Response.End();
        
    }
        public void ResolveHubsIsNotEmpty()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptor = hubManager.ResolveHubs();

            Assert.NotNull(hubDescriptor);
            Assert.NotEmpty(hubDescriptor);
        }
        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");
        }
 protected override void PreStart()
 {
     var hubManager = new DefaultHubManager(GlobalHost.DependencyResolver);
     _hub = hubManager.ResolveHub("itemStatusHub") as ItemStatusHub;
 }
        public void ResolveInvalidHub()
        {
            var resolver = new DefaultDependencyResolver();
            var hubManager = new DefaultHubManager(resolver);
            var hubDescriptor = hubManager.ResolveHub("____CoreTestHub____");

            Assert.Null(hubDescriptor);
        }