public void AddOrReplaceExtensionWorks() { var pb = new VirtualPathBuilder().CombineWith("~/t.cs"); Assert.IsTrue(pb.GetExtension() == "cs"); pb.AddOrReplaceExtension("vb"); Assert.IsTrue(pb.GetExtension() == "vb"); pb.Clear().CombineWith("foo"); Assert.IsFalse(pb.HasExtension()); pb.AddOrReplaceExtension("vb"); Assert.IsTrue(pb.GetExtension() == "vb"); }
public void GetExtensionWorks() { var pb = new VirtualPathBuilder().CombineWith("."); Assert.IsTrue(pb == "."); Assert.IsFalse(pb.HasExtension()); Assert.IsNull(pb.GetExtension()); pb.Clear().CombineWith("~/oops.cshtml"); Assert.IsTrue(pb.HasExtension()); pb.Normalize(); Assert.IsTrue(pb.HasExtension()); Assert.IsTrue(pb.GetExtension() == "cshtml"); Assert.IsTrue(pb.HasExtension()); Assert.IsTrue(pb.GetExtension(true) == "cshtml"); Assert.IsFalse(pb.HasExtension()); }
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()); }
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()); }