activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r831469 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
Date Fri, 30 Oct 2009 22:10:33 GMT
Author: tabish
Date: Fri Oct 30 22:10:32 2009
New Revision: 831469

URL: http://svn.apache.org/viewvc?rev=831469&view=rev
Log:
* NMSTestSupport.cs: 

Add some additional methods for tests to use

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=831469&r1=831468&r2=831469&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Fri Oct 30
22:10:32 2009
@@ -419,7 +419,15 @@
 
         public IDestination CreateDestination(ISession session, DestinationType type)
         {
-            string name = "TEST." + this.GetType().Name + "." + Guid.NewGuid();
+            return CreateDestination(session, type, "");
+        }
+        
+        public IDestination CreateDestination(ISession session, DestinationType type, string
name)
+        {
+            if(name == "")
+            {
+                name = "TEST." + this.GetType().Name + "." + Guid.NewGuid();
+            }
 
             switch(type)
             {
@@ -435,5 +443,66 @@
                 throw new ArgumentException("type: " + type);
             }
         }
+
+        protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet)

+        {
+            AssertTextMessagesEqual(firstSet, secondSet, "");
+        }
+    
+        protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet,
string messsage) 
+        {
+            Assert.AreEqual(firstSet.Length, secondSet.Length, "Message count does not match:
" + messsage);
+    
+            for(int i = 0; i < secondSet.Length; i++)
+            {
+                ITextMessage m1 = firstSet[i] as ITextMessage;
+                ITextMessage m2 = secondSet[i] as ITextMessage;
+                
+                AssertTextMessageEqual(m1, m2, "Message " + (i + 1) + " did not match : ");
+            }
+        }
+    
+        protected void AssertEquals(ITextMessage m1, ITextMessage m2) 
+        {
+            AssertEquals(m1, m2, "");
+        }
+    
+        protected void AssertTextMessageEqual(ITextMessage m1, ITextMessage m2, string message)

+        {
+            Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but
was {" + m2 + "}");
+    
+            if(m1 == null) 
+            {
+                return;
+            }
+    
+            Assert.AreEqual(m1.Text, m2.Text, message);
+        }
+    
+        protected void AssertEquals(IMessage m1, IMessage m2)
+        {
+            AssertEquals(m1, m2, "");
+        }
+    
+        protected void AssertEquals(IMessage m1, IMessage m2, string message)
+        {
+            Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but
was {" + m2 + "}");
+    
+            if(m1 == null)
+            {
+                return;
+            }
+    
+            Assert.IsTrue(m1.GetType() == m2.GetType(), message + ": expected {" + m1 + "},
but was {" + m2 + "}");
+    
+            if(m1 is ITextMessage) 
+            {
+                AssertTextMessageEqual((ITextMessage)m1, (ITextMessage)m2, message);
+            } 
+            else
+            {
+                Assert.AreEqual(m1, m2, message);
+            }
+        }
     }
 }



Mime
View raw message