public void WithRootOperatorWorks() { var pb = new VirtualPathBuilder("/Foo"); var caught = false; try{ pb.WithRootOperator(); } catch(InvalidOperationException){ caught = true; } Assert.IsTrue(caught); Assert.IsTrue(pb.CombineWith("/Foo").WithRootOperator() == "~/"); Assert.IsTrue(pb.Clear().CombineWith("Doo").WithRootOperator() == "~/Doo"); }
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()); }
public void PathBuilderCanBeCreatedFromTwoParts() { var pb = new VirtualPathBuilder(); pb.CombineWith("~/part1", "part2").Normalize(); Assert.AreEqual("/part1/part2",pb.ToString()); pb.WithRootOperator(); Assert.AreEqual("~/part1/part2", pb.ToString()); }
public void HasRootOperatorWorks() { var pb = new VirtualPathBuilder().CombineWith("~/"); Assert.IsTrue(pb.HasRootOperator()); Assert.IsFalse(pb.Normalize().HasRootOperator()); Assert.IsTrue(pb == "/"); Assert.IsTrue(pb.WithRootOperator().HasRootOperator()); pb = new VirtualPathBuilder().CombineWith("~"); Assert.IsTrue(pb.HasRootOperator()); Assert.IsFalse(pb.Normalize().HasRootOperator()); Assert.IsTrue(pb == "/"); Assert.IsTrue(pb.WithRootOperator().HasRootOperator()); pb = new VirtualPathBuilder().CombineWith("~/Foo"); Assert.IsTrue(pb.HasRootOperator()); Assert.IsFalse(pb.Normalize().HasRootOperator()); Assert.IsTrue(pb == "/Foo"); Assert.IsTrue(pb.WithRootOperator().HasRootOperator()); }