public void sending_a_prepared_message_with_a_fixed_correlation_id_always_uses_that_value()
        {
            messaging.CreateDestination <IMsg>("Test_Destination", Expires.Never);

            var staticId = "OhMyCorrelation!";

            messaging.SendPrepared(new PreparedMessage("Example.Types.IMsg", "{\"CorrelationId\":null}", "Example.Types.IMsg")
            {
                CorrelationId = staticId
            });
            messaging.SendPrepared(new PreparedMessage("Example.Types.IMsg", "{\"CorrelationId\":null}", "Example.Types.IMsg")
            {
                CorrelationId = staticId
            });

            var message1 = messaging.TryStartMessage <IMsg>("Test_Destination");

            Assert.That(message1, Is.Not.Null, "did not get message 1");
            Assert.That(message1.Properties.CorrelationId, Is.EqualTo(staticId), "message 1 had an unexpected correlation ID");

            var message2 = messaging.TryStartMessage <IMsg>("Test_Destination");

            Assert.That(message2, Is.Not.Null, "did not get message 2");
            Assert.That(message2.Properties.CorrelationId, Is.EqualTo(staticId), "message 2 had an unexpected correlation ID");


            message1.Finish();
            message2.Finish();
        }
        public void can_handle_very_long_contract_names()
        {
            messaging.CreateDestination <IMsg>("Test_Destination", Expires.Never);
            IPreparedMessage prepMsg = new PreparedMessage("Example.Types.IMsg", "{}",
                                                           @"Non.eram.nescius;Brute;cum;quae.summis.ingeniis.exquisitaque.doctrina.philosophi.Graeco.sermone.tractavissent;ea.Latinis.litteris.mandaremus;fore.ut.hic.noster.labor.in.varias.reprehensiones.incurreret.nam.quibusdam;et.iis.quidem.non.admodum.indoctis;totum.hoc.displicet.philosophari.quidam.autem.non.tam.id.reprehendunt;si.remissius.agatur;sed.tantum.studium.tamque.multam.operam.ponendam.in.eo.non.arbitrantur.erunt.etiam;et.ii.quidem.eruditi.Graecis.litteris;contemnentes.Latinas;qui.se.dicant.in.Graecis.legendis.operam.malle.consumere.postremo.aliquos.futuros.suspicor;qui.me.ad.alias.litteras.vocent;genus.hoc.scribendi;etsi.sit.elegans;personae.tamen.et.dignitatis.esse.negent.Contra.quos.omnis.dicendum.breviter.existimo.Quamquam.philosophiae.quidem.vituperatoribus.satis.responsum.est.eo.libro;quo.a.nobis.philosophia.defensa.et.collaudata.est;cum.esset.accusata.et.vituperata.ab.Hortensio.qui.liber.cum.et.tibi.probatus.videretur.et.iis;quos.ego.posse.iudicare.arbitrarer;plura.suscepi.veritus.ne.movere.hominum.studia.viderer;retinere.non.posse.Qui.autem;si.maxime.hoc.placeat;moderatius.tamen.id.volunt.fieri;difficilem.quandam.temperantiam.postulant.in.eo;quod.semel.admissum.coerceri.reprimique.non.potest;ut.propemodum.iustioribus.utamur.illis;qui.omnino.avocent.a.philosophia;quam.his;qui.rebus.infinitis.modum.constituant.in.reque.eo.meliore;quo.maior.sit;mediocritatem.desiderent.Sive.enim.ad.sapientiam.perveniri.potest;non.paranda.nobis.solum.ea;sed.fruenda.etiam.[sapientia].est;sive.hoc.difficile.est;tamen.nec.modus.est.ullus.investigandi.veri;nisi.inveneris;et.quaerendi.defatigatio.turpis.est;cum.id;quod.quaeritur;sit.pulcherrimum.etenim.si.delectamur;cum.scribimus;quis.est.tam.invidus;qui.ab.eo.nos.abducat?.sin.laboramus;quis.est;qui.alienae.modum.statuat.industriae?.nam.ut.Terentianus.Chremes.non.inhumanus;qui.novum.vicinum.non.vult.fodere.aut.arare.aut.aliquid.ferre.denique..non.enim.illum.ab.industria;sed.ab.inliberali.labore.deterret;sic.isti.curiosi;quos.offendit.noster.minime.nobis.iniucundus.labor;Example.Types.IMsg");

            messaging.SendPrepared(prepMsg);

            var roundTrip = messaging.TryStartMessageRaw("Test_Destination");

            Assert.That(roundTrip, Is.Not.Null, "Message did not arrive");

            Assert.That(roundTrip.Properties.OriginalType, Is.EqualTo(prepMsg.ContractType), "Contract changed in flight");
        }
        public void Should_be_able_to_send_and_receive_messages_using_prepare_message_intermediates()
        {
            messaging.CreateDestination <IMsg>("Test_Destination", Expires.Never);
            byte[] raw = messaging.PrepareForSend(testMessage).ToBytes();

            messaging.SendPrepared(PreparedMessage.FromBytes(raw));

            var finalObject = (IMetadataFile)messaging.GetMessage <IMsg>("Test_Destination");

            Assert.That(finalObject, Is.Not.Null);
            Assert.That(finalObject.CorrelationId, Is.EqualTo(testMessage.CorrelationId));
            Assert.That(finalObject.Contents, Is.EqualTo(testMessage.Contents));
            Assert.That(finalObject.FilePath, Is.EqualTo(testMessage.FilePath));
            Assert.That(finalObject.HashValue, Is.EqualTo(testMessage.HashValue));
            Assert.That(finalObject.MetadataName, Is.EqualTo(testMessage.MetadataName));
            Assert.That(finalObject.Equals(testMessage), Is.False);
        }