Exemple #1
0
        public void ComplexPersonState(HostType hostType, TransportType transportType)
        {
            using (var host = CreateHost(hostType, transportType))
            {
                host.Initialize();
                var connection = new Client.Hubs.HubConnection(host.Url);

                var hub = connection.CreateHubProxy("demo");

                var wh = new ManualResetEvent(false);

                connection.Start(host.Transport).Wait();

                var person = new SignalR.Samples.Hubs.DemoHub.DemoHub.Person
                {
                    Address = new SignalR.Samples.Hubs.DemoHub.DemoHub.Address
                    {
                        Street = "Redmond",
                        Zip    = "98052"
                    },
                    Age  = 25,
                    Name = "David"
                };

                var     person1 = hub.InvokeWithTimeout <SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("ComplexType", person);
                var     person2 = hub.GetValue <SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("person");
                JObject obj     = ((dynamic)hub).person;
                var     person3 = obj.ToObject <SignalR.Samples.Hubs.DemoHub.DemoHub.Person>();

                Assert.NotNull(person1);
                Assert.NotNull(person2);
                Assert.NotNull(person3);
                Assert.Equal("David", person1.Name);
                Assert.Equal("David", person2.Name);
                Assert.Equal("David", person3.Name);
                Assert.Equal(25, person1.Age);
                Assert.Equal(25, person2.Age);
                Assert.Equal(25, person3.Age);
                Assert.Equal("Redmond", person1.Address.Street);
                Assert.Equal("Redmond", person2.Address.Street);
                Assert.Equal("Redmond", person3.Address.Street);
                Assert.Equal("98052", person1.Address.Zip);
                Assert.Equal("98052", person2.Address.Zip);
                Assert.Equal("98052", person3.Address.Zip);

                connection.Stop();
            }
        }
Exemple #2
0
        public void ComplexPersonState()
        {
            using (var host = new MemoryHost())
            {
                host.MapHubs();
                var connection = new Client.Hubs.HubConnection("http://site/");

                var hub = connection.CreateHubProxy("demo");

                var wh = new ManualResetEvent(false);

                connection.Start(host).Wait();

                var person = new SignalR.Samples.Hubs.DemoHub.DemoHub.Person
                {
                    Address = new SignalR.Samples.Hubs.DemoHub.DemoHub.Address
                    {
                        Street = "Redmond",
                        Zip    = "98052"
                    },
                    Age  = 25,
                    Name = "David"
                };

                var     person1 = hub.Invoke <SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("ComplexType", person).Result;
                var     person2 = hub.GetValue <SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("person");
                JObject obj     = ((dynamic)hub).person;
                var     person3 = obj.ToObject <SignalR.Samples.Hubs.DemoHub.DemoHub.Person>();

                Assert.NotNull(person1);
                Assert.NotNull(person2);
                Assert.NotNull(person3);
                Assert.Equal("David", person1.Name);
                Assert.Equal("David", person2.Name);
                Assert.Equal("David", person3.Name);
                Assert.Equal(25, person1.Age);
                Assert.Equal(25, person2.Age);
                Assert.Equal(25, person3.Age);
                Assert.Equal("Redmond", person1.Address.Street);
                Assert.Equal("Redmond", person2.Address.Street);
                Assert.Equal("Redmond", person3.Address.Street);
                Assert.Equal("98052", person1.Address.Zip);
                Assert.Equal("98052", person2.Address.Zip);
                Assert.Equal("98052", person3.Address.Zip);

                connection.Stop();
            }
        }
Exemple #3
0
        public void ComplexPersonState()
        {
            var host = new MemoryHost();
            host.MapHubs();
            var connection = new Client.Hubs.HubConnection("http://site/");

            var hub = connection.CreateProxy("demo");

            var wh = new ManualResetEvent(false);

            connection.Start(host).Wait();

            var person = new SignalR.Samples.Hubs.DemoHub.DemoHub.Person
            {
                Address = new SignalR.Samples.Hubs.DemoHub.DemoHub.Address
                {
                    Street = "Redmond",
                    Zip = "98052"
                },
                Age = 25,
                Name = "David"
            };

            var person1 = hub.Invoke<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("ComplexType", person).Result;
            var person2 = hub.GetValue<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("person");
            JObject obj = ((dynamic)hub).person;
            var person3 = obj.ToObject<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>();

            Assert.NotNull(person1);
            Assert.NotNull(person2);
            Assert.NotNull(person3);
            Assert.Equal("David", person1.Name);
            Assert.Equal("David", person2.Name);
            Assert.Equal("David", person3.Name);
            Assert.Equal(25, person1.Age);
            Assert.Equal(25, person2.Age);
            Assert.Equal(25, person3.Age);
            Assert.Equal("Redmond", person1.Address.Street);
            Assert.Equal("Redmond", person2.Address.Street);
            Assert.Equal("Redmond", person3.Address.Street);
            Assert.Equal("98052", person1.Address.Zip);
            Assert.Equal("98052", person2.Address.Zip);
            Assert.Equal("98052", person3.Address.Zip);

            connection.Stop();
        }
Exemple #4
0
        public void ComplexPersonState(HostType hostType, TransportType transportType)
        {
            using (var host = CreateHost(hostType, transportType))
            {
                host.Initialize();
                var connection = new Client.Hubs.HubConnection(host.Url);

                var hub = connection.CreateHubProxy("demo");

                var wh = new ManualResetEvent(false);

                connection.Start(host.Transport).Wait();

                var person = new SignalR.Samples.Hubs.DemoHub.DemoHub.Person
                {
                    Address = new SignalR.Samples.Hubs.DemoHub.DemoHub.Address
                    {
                        Street = "Redmond",
                        Zip = "98052"
                    },
                    Age = 25,
                    Name = "David"
                };

                var person1 = hub.InvokeWithTimeout<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("ComplexType", person);
                var person2 = hub.GetValue<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("person");
                JObject obj = ((dynamic)hub).person;
                var person3 = obj.ToObject<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>();

                Assert.NotNull(person1);
                Assert.NotNull(person2);
                Assert.NotNull(person3);
                Assert.Equal("David", person1.Name);
                Assert.Equal("David", person2.Name);
                Assert.Equal("David", person3.Name);
                Assert.Equal(25, person1.Age);
                Assert.Equal(25, person2.Age);
                Assert.Equal(25, person3.Age);
                Assert.Equal("Redmond", person1.Address.Street);
                Assert.Equal("Redmond", person2.Address.Street);
                Assert.Equal("Redmond", person3.Address.Street);
                Assert.Equal("98052", person1.Address.Zip);
                Assert.Equal("98052", person2.Address.Zip);
                Assert.Equal("98052", person3.Address.Zip);

                connection.Stop();
            }
        }
Exemple #5
0
        public void ComplexPersonState(HostType hostType, TransportType transportType, MessageBusType messageBusType)
        {
            using (var host = CreateHost(hostType, transportType))
            {
                host.Initialize(messageBusType: messageBusType);
                HubConnection connection = CreateHubConnection(host);

                using (connection)
                {
                    var hub = connection.CreateHubProxy("demo");

                    connection.Start(host.Transport).Wait();

                    var person = new SignalR.Samples.Hubs.DemoHub.DemoHub.Person
                    {
                        Address = new SignalR.Samples.Hubs.DemoHub.DemoHub.Address
                        {
                            Street = "Redmond",
                            Zip = "98052"
                        },
                        Age = 25,
                        Name = "David"
                    };

                    var person1 = hub.InvokeWithTimeout<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("ComplexType", person);
                    var person2 = hub.GetValue<SignalR.Samples.Hubs.DemoHub.DemoHub.Person>("person");

                    Assert.NotNull(person1);
                    Assert.NotNull(person2);
                    Assert.Equal("David", person1.Name);
                    Assert.Equal("David", person2.Name);
                    Assert.Equal(25, person1.Age);
                    Assert.Equal(25, person2.Age);
                    Assert.Equal("Redmond", person1.Address.Street);
                    Assert.Equal("Redmond", person2.Address.Street);
                    Assert.Equal("98052", person1.Address.Zip);
                    Assert.Equal("98052", person2.Address.Zip);
                }
            }
        }