public void TcpChannel_Send_Queued() { StartRouters(false); g1r1.IdleCheck = false; g1r2.IdleCheck = false; try { g1r1.Transmit(new ChannelEP(Transport.Tcp, g1r2.TcpEP), new TcpTestMsg("Sent #1")); g1r1.QueueTo(new ChannelEP(Transport.Tcp, g1r2.TcpEP), new TcpTestMsg("Queued #1")); g1r1.QueueTo(new ChannelEP(Transport.Tcp, g1r2.TcpEP), new TcpTestMsg("Queued #2")); g1r1.Transmit(new ChannelEP(Transport.Tcp, g1r2.TcpEP), new TcpTestMsg("Sent #2")); g1r2.WaitReceived(4); Dictionary <string, TcpTestMsg> received = new Dictionary <string, TcpTestMsg>(); for (int i = 0; i < 4; i++) { TcpTestMsg msg = (TcpTestMsg)g1r2.DequeueReceived(); received.Add(msg.Value, msg); } Assert.IsTrue(received.ContainsKey("Sent #1")); Assert.IsTrue(received.ContainsKey("Queued #1")); Assert.IsTrue(received.ContainsKey("Queued #2")); Assert.IsTrue(received.ContainsKey("Sent #2")); } finally { StopRouters(); } }
public void UdpChannel_Send_Queued() { // This test is dependant on the fact that the UDP packets will delivered // in the same order that they were sent. This is probably a reasonable // assumption since this test is being done on the loopback network driver. UdpTestMsg msg; int cSent, cQueued1, cQueued2; StartRouters(false); try { g1r1.QueueTo(new ChannelEP(Transport.Udp, g1r2.UdpEP), new UdpTestMsg("Queued #1")); g1r1.QueueTo(new ChannelEP(Transport.Udp, g1r2.UdpEP), new UdpTestMsg("Queued #2")); g1r1.Transmit(new ChannelEP(Transport.Udp, g1r2.UdpEP), new UdpTestMsg("Sent")); g1r2.WaitReceived(3); cSent = 0; cQueued1 = 0; cQueued2 = 0; msg = (UdpTestMsg)g1r2.DequeueReceived(); switch (msg.Value) { case "Sent": cSent++; break; case "Queued #1": cQueued1++; break; case "Queued #2": cQueued2++; break; } msg = (UdpTestMsg)g1r2.DequeueReceived(); switch (msg.Value) { case "Sent": cSent++; break; case "Queued #1": cQueued1++; break; case "Queued #2": cQueued2++; break; } msg = (UdpTestMsg)g1r2.DequeueReceived(); switch (msg.Value) { case "Sent": cSent++; break; case "Queued #1": cQueued1++; break; case "Queued #2": cQueued2++; break; } Assert.AreEqual(1, cQueued1); Assert.AreEqual(1, cQueued2); } finally { StopRouters(); } }