public void Should_notify_model_and_then_consumer(Expression <Action <IModel> > close) { var model = connection.CreateModel(); var consumer = new SpyConsumer(wh, cancel: true, shutdown: true); model.BasicConsume(model.QueueDeclare(), false, consumer); wh.CaptureMethod <string>(consumer.HandleBasicCancel); wh.CaptureMethod <IModel, ShutdownEventArgs>(consumer.HandleModelShutdown); model.ModelShutdown += wh.CaptureEvent <ModelShutdownEventHandler>(); close.Compile().Invoke(model); }
public void ManualTest() { connection.CallbackException += LoggingConnectionCallbackException(1); //connection.CallbackException += ThrowingConnectionCallbackException; //connection.CallbackException += LoggingConnectionCallbackException(2); connection.ConnectionShutdown += LoggingConnectionOnConnectionShutdown(1); //connection.ConnectionShutdown += ThrowingConnectionOnConnectionShutdown; //connection.ConnectionShutdown += LoggingConnectionOnConnectionShutdown(2); var model = connection.CreateModel(); //model.TxSelect(); //model.ConfirmSelect(); model.CallbackException += LoggingModelOnCallbackException(1); //model.CallbackException += ThrowingModelOnCallbackException; //model.CallbackException += LoggingModelOnCallbackException(2); model.ModelShutdown += LoggingModelOnModelShutdown(1); //model.ModelShutdown += ThrowingModelOnModelShutdown; //model.ModelShutdown += LoggingModelOnModelShutdown(2); var consumer = new SpyConsumer(); var queue = model.QueueDeclare("", false, true, true, null); log.Debug("Invoking basic consume"); model.BasicConsume(queue, true, consumer); log.Debug("Invoking basic publish"); model.BasicPublish("", queue, null, "Ciao".Bytes()); Thread.Sleep(2000); //model.BasicAck(2, false); Thread.Sleep(2000); //model.QueueDelete(queue); Thread.Sleep(2000); //log.Debug("Closing model"); //model.Close(); Thread.Sleep(2000); log.Debug("Closing connection"); //connection.Close(); }
public void Should_notify_model_and_then_consumer(Expression<Action<IModel>> close) { var model = connection.CreateModel(); var consumer = new SpyConsumer(wh, cancel: true, shutdown: true); model.BasicConsume(model.QueueDeclare(), false, consumer); wh.CaptureMethod<string>(consumer.HandleBasicCancel); wh.CaptureMethod<IModel, ShutdownEventArgs>(consumer.HandleModelShutdown); model.ModelShutdown += wh.CaptureEvent<ModelShutdownEventHandler>(); close.Compile().Invoke(model); }