public void message_is_produced() { var block = new ManualResetEvent(false); var received = false; var consumer = new TestConsumer(); var producer = new ZeroProducer<Message>("tcp://*:5562"); producer.AttachConsumer(consumer); ThreadPool.QueueUserWorkItem(s => { using (var context = new Context()) { using (var socket = context.Socket(SocketType.REQ)) { socket.Connect("tcp://localhost:5562"); using (var ms = new MemoryStream()) { new BinaryFormatter().Serialize(ms, new TestMessage()); socket.Send(ms.ToArray()); socket.Recv(); // ACK } } } received = true; block.Set(); }); block.WaitOne(); Assert.IsTrue(received); producer.Stop(); }
public void timeouts_occur_gracefully() { var block = new ManualResetEvent(false); var consumer = new TestConsumer(); var producer = new ZeroProducer<Message>("tcp://*:5562"); producer.AttachConsumer(consumer); producer.TimedOut += delegate { block.Set(); }; block.WaitOne(); }