예제 #1
0
        public void Test_FileExtension()
        {
            IFilePath filePath = @".\File.txt".ToRelativeFilePath();

            Assert.IsTrue(filePath.FileExtension == @".txt");
            Assert.IsTrue(filePath.HasExtension(@".txt"));
            Assert.IsTrue(filePath.HasExtension(@".TxT"));
            Assert.IsTrue(filePath.HasExtension(@".TXT"));


            filePath = @"%E%\File.txt".ToEnvVarFilePath();
            Assert.IsTrue(filePath.FileExtension == @".txt");
            Assert.IsTrue(filePath.HasExtension(@".txt"));
            Assert.IsTrue(filePath.HasExtension(@".TxT"));
            Assert.IsTrue(filePath.HasExtension(@".TXT"));

            filePath = @".\File".ToRelativeFilePath();
            Assert.IsTrue(filePath.FileExtension == string.Empty);

            filePath = @".\File.".ToRelativeFilePath();
            Assert.IsTrue(filePath.FileExtension == string.Empty);

            filePath = @"C:\dir1\\//dir2\File.txt.Exe".ToAbsoluteFilePath();
            Assert.IsTrue(filePath.FileExtension == @".Exe");
            Assert.IsTrue(filePath.HasExtension(@".exe"));
        }