public void ClearWorks() { var pb = new VirtualPathBuilder("/Foo"); Assert.AreEqual(string.Empty, pb.ToString()); Assert.AreEqual("/Foo/", pb.ApplicationRoot); pb.CombineWith("Doo"); Assert.AreEqual("Doo", pb.ToString()); Assert.AreEqual("/Foo/Doo", pb.Normalize().ToString()); pb.Clear(); Assert.AreEqual(string.Empty, pb.ToString()); pb.CombineWith("."); Assert.AreEqual("", pb.Normalize().ToString()); }
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 PathBuilderWorksWithRootPartAdded() { var pb = new VirtualPathBuilder(); pb.CombineWith("/"); pb.CombineWith("/"); Assert.AreEqual("/", pb.ToString()); }
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 NormalizingToRootRelativeWorksForCurrentDirectory() { var pb = new VirtualPathBuilder(); pb .CombineWith("/") .CombineWith("/./././.") .Normalize() .WithRootOperator(); Assert.AreEqual("~/", pb.ToString()); }
public void NormalizeWorks() { var pb = new VirtualPathBuilder().Normalize(); Assert.IsTrue(pb == ""); Assert.IsTrue(pb.ToString() == ""); pb.Clear().CombineWith(".").Normalize(); Assert.IsTrue(pb == ""); Assert.IsTrue(pb.ToString() == ""); var caught = false; try{ pb.Clear().CombineWith("..").Normalize(); } catch(InvalidOperationException){ caught = true; } Assert.IsTrue(caught); CombineWithWorks(); }