public void GenericMessageHandlingGlobalOrder()
        {
            IServerConnection connection = null;

            var test = new AsyncTest(e =>
            {
                var me = (MessageEventArgs <MockMessage>)e;
                Assert.AreSame(connection, me.Connection);
                Assert.AreEqual("hi", me.Message.Content);
            });

            var server = new TempestServer(MessageTypes.Reliable);

            server.AddConnectionProvider(provider, ExecutionMode.GlobalOrder);
            server.Start();

            Action <MessageEventArgs <MockMessage> > handler = e => test.PassHandler(test, e);

            server.RegisterMessageHandler(handler);

            provider.ConnectionMade += (sender, e) => connection = e.Connection;

            var c = provider.GetClientConnection(protocol);

            c.ConnectAsync(new Target(Target.AnyIP, 0), MessageTypes.Reliable);
            c.SendAsync(new MockMessage {
                Content = "hi"
            });

            test.Assert(10000);
        }
Exemple #2
0
        public void AddConnectionProvider()
        {
            var p = new MockConnectionProvider (protocol);
            Assert.IsFalse (p.IsRunning);

            var server = new TempestServer (provider, MessageTypes.Reliable);
            server.AddConnectionProvider (p);
            Assert.IsFalse (p.IsRunning);
        }
        public void RemoveConnectionProviderGlobalOrder()
        {
            var server = new TempestServer(MessageTypes.Reliable);

            server.AddConnectionProvider(provider, ExecutionMode.GlobalOrder);
            Assert.IsFalse(provider.IsRunning);

            server.RemoveConnectionProvider(provider);
            Assert.IsFalse(provider.IsRunning);
        }
        public void AddConnectionProvider()
        {
            var p = new MockConnectionProvider(protocol);

            Assert.IsFalse(p.IsRunning);

            var server = new TempestServer(provider, MessageTypes.Reliable);

            server.AddConnectionProvider(p);
            Assert.IsFalse(p.IsRunning);
        }
        public void ConnectionMadeGlobalOrder()
        {
            var server = new TempestServer(MessageTypes.Reliable);

            server.AddConnectionProvider(provider, ExecutionMode.GlobalOrder);
            server.Start();

            var test = new AsyncTest();

            server.ConnectionMade += test.PassHandler;

            var client = provider.GetClientConnection(protocol);

            client.ConnectAsync(new Target(Target.AnyIP, 0), MessageTypes.Reliable);

            test.Assert(5000);
        }
        public void AddConnectionProviderNull()
        {
            var server = new TempestServer(provider, MessageTypes.Reliable);

            Assert.Throws <ArgumentNullException> (() => server.AddConnectionProvider(null));
        }
Exemple #7
0
 public void AddConnectionProviderNull()
 {
     var server = new TempestServer (provider, MessageTypes.Reliable);
     Assert.Throws<ArgumentNullException> (() => server.AddConnectionProvider (null));
 }
Exemple #8
0
        public void RemoveConnectionProviderGlobalOrder()
        {
            var server = new TempestServer (MessageTypes.Reliable);
            server.AddConnectionProvider (provider, ExecutionMode.GlobalOrder);
            Assert.IsFalse (provider.IsRunning);

            server.RemoveConnectionProvider (provider);
            Assert.IsFalse (provider.IsRunning);
        }
Exemple #9
0
        public void MessageHandlingGlobalOrder()
        {
            IServerConnection connection = null;

            var test = new AsyncTest(e =>
            {
                var me = (MessageEventArgs)e;
                Assert.AreSame (connection, me.Connection);
                Assert.IsTrue (me.Message is MockMessage);
                Assert.AreEqual ("hi", ((MockMessage)me.Message).Content);
            });

            var server = new TempestServer (MessageTypes.Reliable);
            server.AddConnectionProvider (provider, ExecutionMode.GlobalOrder);
            server.Start();

            Action<MessageEventArgs> handler = e => test.PassHandler (test, e);
            ((IContext)server).RegisterMessageHandler (MockProtocol.Instance, 1, handler);

            provider.ConnectionMade += (sender, e) => connection = e.Connection;

            var c = provider.GetClientConnection (protocol);
            c.ConnectAsync (new Target (Target.AnyIP, 0), MessageTypes.Reliable);
            c.SendAsync (new MockMessage { Content = "hi" });

            test.Assert (10000);
        }
Exemple #10
0
        public void ConnectionMadeGlobalOrder()
        {
            var server = new TempestServer (MessageTypes.Reliable);
            server.AddConnectionProvider (provider, ExecutionMode.GlobalOrder);
            server.Start();

            var test = new AsyncTest();
            server.ConnectionMade += test.PassHandler;

            var client = provider.GetClientConnection (protocol);
            client.ConnectAsync (new Target (Target.AnyIP, 0), MessageTypes.Reliable);

            test.Assert (5000);
        }