2009-05-23 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / Mono.Messaging / Test / Mono.Messaging / QueueReferenceTest.cs
1 //
2 // Test.Mono.Messaging
3 //
4 // Authors:
5 //      Michael Barker (mike@middlesoft.co.uk)
6 //
7 // (C) 2008 Michael Barker
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Text.RegularExpressions;
33
34 using Mono.Messaging;
35 using NUnit.Framework;
36
37 namespace MonoTests.Mono.Messaging
38 {
39         [TestFixture]
40         public class QueueReferenceTest
41         {
42                 [Test]
43                 public void Equals ()
44                 {
45                         QueueReference qr1 = new QueueReference ("abc", "def", false);
46                         QueueReference qr2 = new QueueReference ("abc", "def", false);
47                         //Assert.IsTrue(qr1.Equals(qr2), "QueueReferences should be equal");
48                         Assert.AreEqual (qr1, qr2, "QueueReferences should be equal");
49                 }
50                 
51                 [Test]
52                 public void Parse ()
53                 {
54                         string[] s = @".\def\ghi".Split (new char[] { '\\' }, 3);
55                         Assert.AreEqual (3, s.Length, "Fail");
56                         Assert.AreEqual (".", s[0], "Fail");
57                 
58                         QueueReference qr0 = QueueReference.Parse (@"\\host\private$\myqueue");
59                         Assert.AreEqual ("host", qr0.Host);
60                         Assert.AreEqual (true, qr0.IsPrivate);
61                         Assert.AreEqual (@"private$\myqueue", qr0.Queue);
62                         
63                         QueueReference qr1 = QueueReference.Parse (@"\\host\myqueue");
64                         Assert.AreEqual ("host", qr1.Host);
65                         Assert.AreEqual (false, qr1.IsPrivate);
66                         Assert.AreEqual ("myqueue", qr1.Queue);
67                         
68                         QueueReference qr2 = QueueReference.Parse ("myqueue");
69                         Assert.AreEqual ("localhost", qr2.Host);
70                         Assert.AreEqual (false, qr2.IsPrivate);
71                         Assert.AreEqual ("myqueue", qr2.Queue);                 
72                 }
73                 
74                 [Test]
75                 public void StringLeadingChars ()
76                 {
77                         Assert.AreEqual (@"asdfb\asdfasd", 
78                                         QueueReference.RemoveLeadingSlashes (@"\\asdfb\asdfasd"), 
79                                         "Failed to removed slashes");
80                 }
81         }
82
83         
84 }
85