Beispiel #1
0
        public void ServerRecievesObjects <T>(int clients, T obj)
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer(clients);

            S.StartServer();

            Client[] Clients = TestDefaults.GetClientList(() =>
            {
                Client c = new Client();
                c.Connect(IPAddress.Loopback, 9090);
                return(c);
            }, clients);

            foreach (Client c in Clients)
            {
                c.SendObject(obj);
            }

            bool b = TestDefaults.TimeOut(() =>
            {
                for (int i = 0; i < clients; i++)
                {
                    S.WaitForPullFromClient <T>((ushort)i);
                }
            }, 6000);

            Assert.True(b);

            S.Close();
        }
Beispiel #2
0
        public void RecievesInherited()
        {
            TestDefaults.SetGlobalDefaults();

            Server S = TestDefaults.GetServer();

            S.StartServer();

            Client c = new Client();

            c.Connect(IPAddress.Loopback, 9090);

            var test = new TestDefaults.TestClass()
            {
                ID = 42, Foo = "foos", Str = "String"
            };

            S.SendToAll(test);
            S.SendToAll(test);
            S.SendToAll(test);
            S.SendToAll(test);

            Assert.True(TestDefaults.TimeOut(() =>
            {
                var v1 = c.WaitForPullObject <TestDefaults.TestClass>();
                var v2 = c.WaitForPullObject <TestDefaults.TestBase>();
                var v3 = c.WaitForPullObject <TestDefaults.TestInterface>();
                var v4 = c.WaitForPullObject <object>();
                while (v1.ID != 42 || v1.GetFoo() != "foos" || v1.st != "String")
                {
                    ;
                }
                while (v2.GetFoo() != "foos" || v2.GetID() != 42)
                {
                    ;
                }
                while (v3.GetVal() != 42 || v3.Str != "String")
                {
                    ;
                }
                while ((v4 as TestDefaults.TestClass).ID != 42)
                {
                    ;
                }
            }, 50000));
        }