public void Response_should_be_handled_properly()
            {
                IBasicProperties properties;
                _awaiter.RegisterResponseAction(m =>
                                                    {
                                                        _threadLock.Set();
                                                    }, out properties);

                var subscriptionId = properties.CorrelationId;
                var queueName = properties.ReplyTo;

                subscriptionId.Should().NotBeEmpty();
                queueName.Should().NotBeEmpty();

                var formatter = new MessageFormatter(new Utf8MessageSerializer(null), new JsonMessageStringifier(null),
                                                     null);

                var message = formatter.Format(new StringMessage()
                                                   {
                                                       Content = "abc"
                                                   });

                var channel = ComponentLocator.Current.Get<IModel>();
                channel.BasicPublish(String.Empty, queueName, new BasicProperties()
                                                                  {
                                                                      CorrelationId = subscriptionId
                                                                  }, message );

                _threadLock.WaitOne();
            }
        public void Should_be_reversive()
        {
            var messageFormatter = new MessageFormatter(new Utf8MessageSerializer(null), new JsonMessageStringifier(null), null);

            var x = messageFormatter.Deformat(messageFormatter.Format(new MyTestMessage()
                                                                  {
                                                                      Set = "DDDDD"
                                                                  }));

            ((MyTestMessage) x).Set.Should().Be("DDDDD");
        }
        public void It_should_sent_messages_which_will_be_received()
        {
            var model1 = ComponentLocator.Current.Get<IModel>();
            var publisher = new MessagePublisher(model1,
                                                 new MessageFormatter(new Utf8MessageSerializer(null),
                                                                      new JsonMessageStringifier(null), null), new ResponseAwaiter(new MessageFormatter(new Utf8MessageSerializer(null), new JsonMessageStringifier(null), null ), null ),  null);
            publisher.Publish(new SampleMessage(){ Message = "Hello"}, "TestQueue1_1" );

            var model = ComponentLocator.Current.Get<IModel>();
            var subs = new RabbitMQ.Client.MessagePatterns.Subscription(model, "TestQueue1_1");
            var args = subs.Next();

            var messageFormatter = new MessageFormatter(new Utf8MessageSerializer(null), new JsonMessageStringifier(null), null);
            var obj = messageFormatter.Deformat(args.Body);

            obj.Should().NotBeNull();
            obj.Should().BeOfType<SampleMessage>();

            ((SampleMessage) obj).Message.Should().Be("Hello");

            subs.Close();
        }