Update UriBuilder.Path once the Uri has been created
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 17 Sep 2010 11:55:39 +0000 (07:55 -0400)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 17 Sep 2010 21:25:34 +0000 (17:25 -0400)
* System/UriBuilder.cs: Update UriBuilder.Path once the Uri has been
created using Uri.AbsolutePath

* Test/System/UriBuilderTest.cs: Add test case with path missing the
initial / which shows the UriBuilder.Path property is being updated
after the creation of the Uri instance.

mcs/class/System/System/UriBuilder.cs
mcs/class/System/Test/System/UriBuilderTest.cs

index 3e779b5b54e93a1cdc43d86873e3a262323aa725..b43c2db5c25d182d636b77b2d7bd55df9a2d6379 100644 (file)
@@ -210,6 +210,7 @@ namespace System
                                uri = new Uri (ToString (), true);
                                // some properties are updated once the Uri is created - see unit tests
                                host = uri.Host;
+                               path = uri.AbsolutePath;
                                modified = false;
                                return uri;
                        }
index 31769ad994bdfb316f1e849971a42be467a69517..86f22e41574d576398a4591711977895807004ba 100644 (file)
@@ -275,6 +275,16 @@ namespace MonoTests.System
                        // once the Uri is created then some builder properties may change
                        Assert.AreEqual ("[0001:0002:0003:0004:0005:0006:0007:0008]", ub.Host, "Host.2");
                }
+
+               [Test]
+               public void Path_UriAbsolutePath_Path ()
+               {
+                       UriBuilder ub = new UriBuilder ("http", "127.0.0.1", 80, "dir/subdir/file");
+                       Assert.AreEqual ("dir/subdir/file", ub.Path, "Path.1");
+                       Assert.AreEqual ("/dir/subdir/file", ub.Uri.AbsolutePath, "Uri.AbsolutePath");
+                       // once the Uri is created then some builder properties may change
+                       Assert.AreEqual ("/dir/subdir/file", ub.Path, "Path.2");
+               }
        }
 }