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 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); }
public void AddConnectionProviderNull() { var server = new MockServer (provider, MessageTypes.Reliable); Assert.Throws<ArgumentNullException> (() => server.AddConnectionProvider (null)); }
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); }
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 RemoveConnectionProvider() { var server = new MockServer (provider, MessageTypes.Reliable); Assert.IsFalse (provider.IsRunning); server.RemoveConnectionProvider (provider); Assert.IsFalse (provider.IsRunning); }
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 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); }