public void TestShallowCopy() { ActiveMQMessage msg1 = new ActiveMQMessage(); msg1.NMSMessageId = nmsMessageID; ActiveMQMessage msg2 = (ActiveMQMessage) msg1.Clone(); Assert.IsTrue(msg1 != msg2 && msg1.Equals(msg2)); }
public void TestCopy() { this.nmsMessageID = "ID:1141:45278:429"; this.nmsCorrelationID = "testcorrelationid"; this.nmsDestination = new ActiveMQTopic("test.topic"); this.nmsReplyTo = new ActiveMQTempTopic("test.replyto.topic:001"); this.nmsDeliveryMode = MsgDeliveryMode.NonPersistent; this.nmsType = "test type"; this.nmsPriority = MsgPriority.High; this.nmsTimestamp = DateTime.Now; ActiveMQMessage msg1 = new ActiveMQMessage(); msg1.NMSMessageId = this.nmsMessageID; msg1.NMSCorrelationID = this.nmsCorrelationID; msg1.FromDestination = this.nmsDestination; msg1.NMSReplyTo = this.nmsReplyTo; msg1.NMSDeliveryMode = this.nmsDeliveryMode; msg1.NMSType = this.nmsType; msg1.NMSPriority = this.nmsPriority; msg1.NMSTimestamp = this.nmsTimestamp; msg1.ReadOnlyProperties = true; ActiveMQMessage msg2 = msg1.Clone() as ActiveMQMessage; Assert.IsTrue(msg1.NMSMessageId.Equals(msg2.NMSMessageId)); Assert.IsTrue(msg1.NMSCorrelationID.Equals(msg2.NMSCorrelationID)); Assert.IsTrue(msg1.NMSDestination.Equals(msg2.NMSDestination)); Assert.IsTrue(msg1.NMSReplyTo.Equals(msg2.NMSReplyTo)); Assert.IsTrue(msg1.NMSDeliveryMode == msg2.NMSDeliveryMode); Assert.IsTrue(msg1.NMSRedelivered == msg2.NMSRedelivered); Assert.IsTrue(msg1.NMSType.Equals(msg2.NMSType)); Assert.IsTrue(msg1.NMSPriority == msg2.NMSPriority); Assert.IsTrue(msg1.NMSTimestamp == msg2.NMSTimestamp); }