2008-09-07 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 7 Sep 2009 08:21:16 +0000 (08:21 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 7 Sep 2009 08:21:16 +0000 (08:21 -0000)
* UriTemplate.cs : implement IsEquivalentTo().
* UriTemplateEquivalenceComparer.cs : implement.

* UriTemplateEquivalenceComparerTest.cs : new test.

* System.ServiceModel.Web_test.dll.sources :
  added UriTemplateEquivalenceComparerTest.cs.

svn path=/trunk/mcs/; revision=141409

mcs/class/System.ServiceModel.Web/ChangeLog
mcs/class/System.ServiceModel.Web/System.ServiceModel.Web_test.dll.sources
mcs/class/System.ServiceModel.Web/System/ChangeLog
mcs/class/System.ServiceModel.Web/System/UriTemplate.cs
mcs/class/System.ServiceModel.Web/System/UriTemplateEquivalenceComparer.cs
mcs/class/System.ServiceModel.Web/Test/System/ChangeLog
mcs/class/System.ServiceModel.Web/Test/System/UriTemplateEquivalenceComparerTest.cs [new file with mode: 0644]

index 37ebe41554a7ad7c470145a469379eb1b8acb343..96184eb5d076272478401f2ffcd0f4b58a1ee6d4 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.Web_test.dll.sources :
+         added UriTemplateEquivalenceComparerTest.cs.
+
 2009-09-02  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Makefile : use System.Core.
index 536633f0a76ff8bc2df7404db7293e972196fc0a..5d926929bc0f5af44d15b6f979bf944c5ca40e26 100644 (file)
@@ -27,3 +27,4 @@ System.ServiceModel.Web/WebOperationContextTest.cs
 System.ServiceModel.Web/WebServiceHostTest.cs
 System.ServiceModel/WebHttpBindingTest.cs
 System/UriTemplateTest.cs
+System/UriTemplateEquivalenceComparerTest.cs
index bf9280d0d934f3821f79548d9140288a8ae16491..6cbea6dc9c4bf61d90ed0b3b5c1efbd1784ed24c 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UriTemplate.cs : implement IsEquivalentTo().
+       * UriTemplateEquivalenceComparer.cs : implement.
+
 2008-09-07  Atsushi Enomoto  <atsushi@ximian.com>
 
        * UriTemplate.cs : add BindByName() overloads with Dictionary.
index 99ad6583c8bcb3564c4b6d482a92b9547f703427..38daeb2de5fabbcecb929a2465d90e2612d11fd4 100644 (file)
@@ -181,12 +181,11 @@ namespace System
 
                // Compare
 
-               [MonoTODO]
                public bool IsEquivalentTo (UriTemplate other)
                {
                        if (other == null)
                                throw new ArgumentNullException ("other");
-                       return new UriTemplateEquivalenceComparer ().Equals (this, other);
+                       return this.template == other.template;
                }
 
                // Match
index ea1fb74cca04d7b91c9eb03d74d510d2d63132d1..b169a203b8e897a58f13fa48f68146d875a1b658 100644 (file)
@@ -36,16 +36,17 @@ namespace System
                {
                }
 
-               [MonoTODO]
                public bool Equals (UriTemplate x, UriTemplate y)
                {
-                       throw new NotImplementedException ();
+                       if (x == null)
+                               return y == null;
+                       return y != null && x.IsEquivalentTo (y);
                }
 
-               [MonoTODO]
                public int GetHashCode (UriTemplate obj)
                {
-                       throw new NotImplementedException ();
+                       // gets string's hash code
+                       return obj.ToString ().GetHashCode ();
                }
        }
 }
index 8b7aec97d261b87066b5f5fe3852216de5a78538..5608e3a51515f4bd4d2850edb5d0c58851c01970 100644 (file)
@@ -1,3 +1,7 @@
+2009-09-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UriTemplateEquivalenceComparerTest.cs : new test.
+
 2009-09-07  Atsushi Enomoto  <atsushi@ximian.com>
 
        * UriTemplateTest.cs :
diff --git a/mcs/class/System.ServiceModel.Web/Test/System/UriTemplateEquivalenceComparerTest.cs b/mcs/class/System.ServiceModel.Web/Test/System/UriTemplateEquivalenceComparerTest.cs
new file mode 100644 (file)
index 0000000..6acd62a
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// UriTemplateEquivalenceComparerTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using NUnit.Framework;
+
+namespace MonoTests.System
+{
+       [TestFixture]
+       public class UriTemplateEquivalenceComparerTest
+       {
+               [Test]
+               public void Compare ()
+               {
+                       var t1 = new UriTemplate ("urn:foo");
+                       var t2 = new UriTemplate ("urn:bar");
+                       var t3 = new UriTemplate ("urn:foo", true);
+                       var dic = new Dictionary<string,string> ();
+                       dic.Add ("foo", "v1");
+                       var t4 = new UriTemplate ("urn:foo", dic);
+                       var c = new UriTemplateEquivalenceComparer ();
+                       Assert.IsFalse (c.Equals (t1, t2), "#1");
+                       Assert.IsTrue (c.Equals (t1, t3), "#2");
+                       Assert.IsTrue (c.Equals (t1, t4), "#3");
+                       Assert.IsTrue (c.Equals (null, null), "#4");
+                       Assert.IsFalse (c.Equals (null, t1), "#5");
+                       Assert.IsFalse (c.Equals (t1, null), "#6");
+               }
+       }
+}