private static void AssertIsValidRoot(VirtualPathBuilder pb) { Assert.IsTrue(pb.IsAbsolutePath()); Assert.IsTrue(pb.IsApplicationRoot()); Assert.IsFalse(pb.IsRelativePath()); Assert.IsFalse(pb.HasRootOperator()); Assert.IsFalse(pb.HasExtension()); Assert.IsFalse(pb.HasTrailingSlash(ignoreRoot:true)); Assert.IsTrue(pb.IsValidAbsolutePath()); }
private static void MonkeyTest(string appName) { var pb = new VirtualPathBuilder(appName); Assert.AreEqual("", pb.ToString()); Assert.AreEqual((appName+"/").Replace("//","/"), pb.ApplicationRoot); Assert.AreEqual(pb.Length, 0); Assert.IsTrue(pb == ""); Assert.IsFalse(pb.IsAbsolutePath()); Assert.IsFalse(pb.IsApplicationRoot()); Assert.IsFalse(pb.IsRelativePath()); Assert.IsFalse(pb.HasRootOperator()); Assert.IsFalse(pb.HasExtension()); Assert.IsFalse(pb.HasTrailingSlash()); Assert.IsFalse(pb.IsValidAbsolutePath()); }
public void IsAbsolutePathWorks() { var pb = new VirtualPathBuilder().CombineWith("~/"); Assert.IsFalse(pb.IsAbsolutePath()); pb.Normalize(); Assert.IsTrue(pb.IsAbsolutePath()); pb = new VirtualPathBuilder().CombineWith("~"); Assert.IsFalse(pb.IsAbsolutePath()); pb.Normalize(); Assert.IsTrue(pb.IsAbsolutePath()); pb = new VirtualPathBuilder().CombineWith("~/Foo"); Assert.IsFalse(pb.IsAbsolutePath()); pb.Normalize(); Assert.IsTrue(pb.IsAbsolutePath()); pb = new VirtualPathBuilder("/Foo"); Assert.IsFalse(pb.IsAbsolutePath()); Assert.IsTrue(pb.CombineWith("/Foo/").IsAbsolutePath()); Assert.IsTrue(pb.Clear().CombineWith("/Foo").IsAbsolutePath()); Assert.IsTrue(pb.Clear().CombineWith("/Foo/Doo").IsAbsolutePath()); Assert.IsTrue(pb.Clear().CombineWith("/Foo/Doo/Boo").IsAbsolutePath()); Assert.IsTrue(pb.CombineWith("../..") == "/Foo"); Assert.IsTrue(pb.WithRootOperator().HasRootOperator()); pb = new VirtualPathBuilder("/Foo"); pb.CombineWith("/Doo/Foo"); Assert.IsTrue(pb.IsAbsolutePath()); Assert.IsFalse(pb.IsValidAbsolutePath()); }