public void SetUp() { this.queue = new ReliableQueue(); var provider = new MockConnectionProvider(MockProtocol.Instance); this.connection = provider.GetClientConnection(); }
public void MessageHandling() { 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(provider, MessageTypes.Reliable); 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); }
public void ServerConnectionConnected() { var provider = new MockConnectionProvider (MockProtocol.Instance); provider.Start (MessageTypes.Reliable); var test = new AsyncTest<ConnectionMadeEventArgs> (e => Assert.AreEqual (true, e.Connection.IsConnected)); provider.ConnectionMade += test.PassHandler; var client = provider.GetClientConnection (MockProtocol.Instance); client.ConnectAsync (new Target (Target.AnyIP, 0), MessageTypes.Reliable); test.Assert (5000); }
public void ServerConnectionConnected() { var provider = new MockConnectionProvider(MockProtocol.Instance); provider.Start(MessageTypes.Reliable); var test = new AsyncTest <ConnectionMadeEventArgs> (e => Assert.AreEqual(true, e.Connection.IsConnected)); provider.ConnectionMade += test.PassHandler; var client = provider.GetClientConnection(MockProtocol.Instance); client.ConnectAsync(new Target(Target.AnyIP, 0), MessageTypes.Reliable); test.Assert(5000); }
public void SetUp() { this.queue = new ReliableQueue(); var provider = new MockConnectionProvider (MockProtocol.Instance); this.connection = provider.GetClientConnection(); }