public async Task HandleTest() { var methodCommandInfo = new MethodCommandInfo(typeof(TestClass), typeof(TestClass).GetMethod("TestCalled"), typeof(TestClass).GetMethod("TestCalled").GetParameters().First(), typeof(TestClass).GetMethod("TestCalled").ReturnType, "queue"); var target = new CommandListener(methodCommandInfo); var hostMock = new Mock <IMicroserviceHost>(MockBehavior.Strict); hostMock.Setup(m => m.CreateInstanceOfType(typeof(TestClass))).Returns(new TestClass()); var commandReceiverMock = new Mock <ICommandReceiver>(MockBehavior.Strict); commandReceiverMock.Setup(m => m.DeclareCommandQueue()).Verifiable(); commandReceiverMock.Setup(m => m.StartReceivingCommands(target.Handle)); var iBusContextMock = new Mock <IBusContext <IConnection> >(MockBehavior.Strict); iBusContextMock.Setup(m => m.CreateCommandReceiver("queue")).Returns(commandReceiverMock.Object); target.DeclareQueue(iBusContextMock.Object); target.StartListening(hostMock.Object); TestCommand command = new TestCommand() { Message = "message" }; var message = new CommandRequestMessage(JsonConvert.SerializeObject(command), null); var result = await target.Handle(message); var objectResult = JsonConvert.DeserializeObject <TestCommand>(result.Message); Assert.AreEqual("Message2", objectResult.Message); }