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); }
public void AddConnectionProviderNull() { var server = new MockServer (provider, MessageTypes.Reliable); Assert.Throws<ArgumentNullException> (() => server.AddConnectionProvider (null)); }
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); }
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); }
public void ConnectionMadeGlobalOrder() { var server = new MockServer (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 IPEndPoint (IPAddress.Any, 0), MessageTypes.Reliable); test.Assert (5000); }