コード例 #1
0
        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());
        }