public void ConsumeMessage() { Mock <ILogger <DefaultRabbitMQPersistentConnection> > logger = new Mock <ILogger <DefaultRabbitMQPersistentConnection> >(); Mock <ILogger <Messaging> > logger2 = new Mock <ILogger <Messaging> >(); using (DefaultRabbitMQPersistentConnection con = new DefaultRabbitMQPersistentConnection(_rabbitMqConnection, logger.Object)) { Messaging msg = new Messaging(con, logger2.Object); //msg.PublishMessage(); var result = msg.ConsumeMessage(); Assert.AreEqual("new message", result); } }