コード例 #1
0
        public void SendDefaultMessage()
        {
            string path = MQUtil.CreateQueueName();
            Thingy body = new Thingy();

            body.MyProperty1 = 42;
            body.MyProperty2 = "Something";
            body.MyProperty3 = "Something else";
            Message m1 = new Message(body);

            Assert.IsNull(m1.Formatter);

            MessageQueue q = MQUtil.GetQueue(path, new XmlMessageFormatter());

            q.Send(m1);

            Message m2 = q.Receive();

            m2.Formatter = new XmlMessageFormatter(new Type[] { typeof(Thingy) });
            Assert.IsNotNull(m2.Formatter);
            Assert.AreEqual(typeof(XmlMessageFormatter), m2.Formatter.GetType());
            Thingy body2 = (Thingy)m2.Formatter.Read(m2);

            Assert.AreEqual(body.MyProperty1, body2.MyProperty1);
            Assert.AreEqual(body.MyProperty2, body2.MyProperty2);
            Assert.AreEqual(body.MyProperty3, body2.MyProperty3);
        }
コード例 #2
0
        public void SendBinaryMessage()
        {
            Thingy body = new Thingy();

            body.MyProperty1 = 42;
            body.MyProperty2 = "Something";
            body.MyProperty3 = "Something else";
            Message m1 = new Message(body);

            m1.Formatter = new BinaryMessageFormatter();

            MessageQueue q = MQUtil.GetQueue();

            q.Send(m1);

            Message m2 = q.Receive();

            m2.Formatter = new BinaryMessageFormatter();
            Assert.IsNotNull(m2.Formatter);
            Assert.AreEqual(typeof(BinaryMessageFormatter), m2.Formatter.GetType());
            Thingy body2 = (Thingy)m2.Formatter.Read(m2);

            Assert.AreEqual(body.MyProperty1, body2.MyProperty1);
            Assert.AreEqual(body.MyProperty2, body2.MyProperty2);
            Assert.AreEqual(body.MyProperty3, body2.MyProperty3);
        }
コード例 #3
0
        public void SendBinaryObject()
        {
            Thingy body = new Thingy();

            body.MyProperty1 = 42;
            body.MyProperty2 = "Something";
            body.MyProperty3 = "Something else";

            MessageQueue q = MQUtil.GetQueue();

            q.Formatter = new BinaryMessageFormatter();

            q.Send(body);

            Message m2    = q.Receive();
            Thingy  body2 = (Thingy)m2.Body;

            Assert.AreEqual(typeof(BinaryMessageFormatter), m2.Formatter.GetType());
            Assert.AreEqual(body.MyProperty1, body2.MyProperty1);
            Assert.AreEqual(body.MyProperty2, body2.MyProperty2);
            Assert.AreEqual(body.MyProperty3, body2.MyProperty3);
            Assert.AreEqual(768, m2.BodyType);
        }
コード例 #4
0
		public void SendDefaultMessage ()
		{
			string path = MQUtil.CreateQueueName ();
			Thingy body = new Thingy ();
			body.MyProperty1 = 42;
			body.MyProperty2 = "Something";
			body.MyProperty3 = "Something else";
			Message m1 = new Message (body);
			Assert.IsNull (m1.Formatter);

			MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());

			q.Send (m1);

			Message m2 = q.Receive ();
			m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (Thingy) });
			Assert.IsNotNull (m2.Formatter);
			Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
			Thingy body2 = (Thingy) m2.Formatter.Read (m2);

			Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
			Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
			Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
		}			  
コード例 #5
0
		public void SendBinaryMessage ()
		{
			Thingy body = new Thingy ();
			body.MyProperty1 = 42;
			body.MyProperty2 = "Something";
			body.MyProperty3 = "Something else";
			Message m1 = new Message (body);
			m1.Formatter = new BinaryMessageFormatter ();

			MessageQueue q = MQUtil.GetQueue ();

			q.Send (m1);

			Message m2 = q.Receive ();
			m2.Formatter = new BinaryMessageFormatter ();
			Assert.IsNotNull (m2.Formatter);
			Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
			Thingy body2 = (Thingy) m2.Formatter.Read (m2);

			Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
			Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
			Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
		}
コード例 #6
0
		public void SendBinaryObject ()
		{
			Thingy body = new Thingy ();
			body.MyProperty1 = 42;
			body.MyProperty2 = "Something";
			body.MyProperty3 = "Something else";

			MessageQueue q = MQUtil.GetQueue ();

			q.Formatter = new BinaryMessageFormatter ();

			q.Send (body);
		   
			Message m2 = q.Receive ();
			Thingy body2 = (Thingy) m2.Body;

			Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
			Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
			Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
			Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
			Assert.AreEqual (768, m2.BodyType);
		}