コード例 #1
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void AddConnectionProvider()
        {
            var p = new MockConnectionProvider (protocol);
            Assert.IsFalse (p.IsRunning);

            var server = new MockServer (provider, MessageTypes.Reliable);
            server.AddConnectionProvider (p);
            Assert.IsFalse (p.IsRunning);
        }
コード例 #2
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void ConnectionMade()
        {
            var server = new MockServer (provider, MessageTypes.Reliable);
            server.Start();

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

            var client = provider.GetClientConnection (protocol);
            client.ConnectAsync (new IPEndPoint (IPAddress.Any, 0), MessageTypes.Reliable);

            test.Assert (5000);
        }
コード例 #3
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
 public void AddConnectionProviderNull()
 {
     var server = new MockServer (provider, MessageTypes.Reliable);
     Assert.Throws<ArgumentNullException> (() => server.AddConnectionProvider (null));
 }
コード例 #4
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void RemoveNotAddedConnectionProvider()
        {
            var p = new MockConnectionProvider (protocol);
            p.Start (MessageTypes.Reliable);
            Assert.IsTrue (p.IsRunning);

            var server = new MockServer (provider, MessageTypes.Reliable);
            server.RemoveConnectionProvider (p);
            Assert.IsTrue (p.IsRunning);
        }
コード例 #5
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void RemoveConnectionProviderGlobalOrder()
        {
            var server = new MockServer (MessageTypes.Reliable);
            server.AddConnectionProvider (provider, ExecutionMode.GlobalOrder);
            Assert.IsFalse (provider.IsRunning);

            server.RemoveConnectionProvider (provider);
            Assert.IsFalse (provider.IsRunning);
        }
コード例 #6
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void RemoveConnectionProvider()
        {
            var server = new MockServer (provider, MessageTypes.Reliable);
            Assert.IsFalse (provider.IsRunning);

            server.RemoveConnectionProvider (provider);
            Assert.IsFalse (provider.IsRunning);
        }
コード例 #7
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void MessageHandlingGlobalOrder()
        {
            IServerConnection connection = null;

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

            var server = new MockServer (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 IPEndPoint (IPAddress.Any, 0), MessageTypes.Reliable);
            c.Send (new MockMessage { Content = "hi" });

            test.Assert (10000);
        }
コード例 #8
0
ファイル: ServerTests.cs プロジェクト: strager/Tempest
        public void GenericMessageHandling()
        {
            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 MockServer (provider, MessageTypes.Reliable);
            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 IPEndPoint (IPAddress.Any, 0), MessageTypes.Reliable);
            c.Send (new MockMessage { Content = "hi" });

            test.Assert (10000);
        }