public void Properties() { StoragePath path = new StoragePath("////some\\malformed/path\\\\here"); Assert.AreEqual("here", path.Name); Assert.AreEqual("", path.Extension); path = path.SetExtension("txt"); Assert.AreEqual(".txt", path.Extension); Assert.AreEqual("here.txt", path.Name); Assert.AreEqual(false, path.IsAbsolute); path = new StoragePath("C:\\") + path; Assert.AreEqual(true, path.IsAbsolute); Assert.AreEqual("C:somemalformedpathhere.txt", string.Join("", path.Segments)); Assert.AreEqual(new Uri(path.ToString()), path.ToUri()); }
public void Combining() { StoragePath path = new StoragePath(); path += "C:/"; Assert.AreEqual(@"C:", path.ToString()); path += (StoragePath)(new Uri("some/other", UriKind.RelativeOrAbsolute)); Assert.AreEqual(@"C:\some\other", path.ToString()); path = path.Combine("some///malformed\\\\other.some").SetExtension(".txt"); Assert.AreEqual(@"C:\some\other\some\malformed\other.txt", path.ToString()); path = path.SetExtension("txt"); Assert.AreEqual(@"C:\some\other\some\malformed\other.txt", path.ToString()); Assert.AreEqual("other.txt", path.ScopeToName().ToString()); Assert.AreEqual("other", path.ScopeToNameWithoutExtension().ToString()); Assert.AreEqual(@"C:\some\other\some\malformed", path.ParentDirectory.ToString()); Assert.AreEqual(@"C:\some\other\some", path.GetNthParentDirectory(2).ToString()); }