public void Can_Send_and_Receive_messages_using_QueueNamePrefix() { using (var mqServer = this.CreateMqServer()) { mqServer.RegisterHandler <HelloIntro>(m => new HelloIntroResponse { Result = $"Hello, {m.GetBody().Name}!" }); mqServer.Start(); using (var mqClient = mqServer.CreateMessageQueueClient()) { var request = new HelloIntro { Name = "World" }; var requestInq = MqMessageFactory.Create(request).ToInQueueName(); Assert.That(requestInq, Is.EqualTo("site1.theone:mq.HelloIntro.direct")); mqClient.Publish(request); var responseInq = MqQueueNames <HelloIntroResponse> .Direct; Assert.That(responseInq, Is.EqualTo("site1.theone:mq.HelloIntroResponse.direct")); var responseMsg = mqClient.Get <HelloIntroResponse>(responseInq); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, World!")); } } }
public void Can_serialize_IMqMessage_into_typed_Message() { var dto = new Incr { Value = 1 }; var iMsg = MqMessageFactory.Create(dto); var jsonBytes = MqMessageExtensions.ToJsonBytes((object)iMsg); IMqMessage <Incr> typedMessage = MqMessageExtensions.FromJsonBytes <MqMessage <Incr> >(jsonBytes); Assert.That(typedMessage.GetBody().Value, Is.EqualTo(dto.Value)); }