| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 | using System;using Microsoft.VisualStudio.TestTools.UnitTesting;using Renci.SshNet.Common;namespace Renci.SshNet.Tests.Classes.Common{    [TestClass]    public class PosixPathTest_GetFileName    {        [TestMethod]        public void Path_Null()        {            const string path = null;            try            {                _ = PosixPath.GetFileName(path);                Assert.Fail();            }            catch (ArgumentNullException ex)            {                Assert.IsNull(ex.InnerException);                Assert.AreEqual("path", ex.ParamName);            }        }        [TestMethod]        public void Path_Empty()        {            var path = string.Empty;            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreSame(path, actual);        }        [TestMethod]        public void Path_TrailingForwardSlash()        {            var path = "/abc/";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual(string.Empty, actual);        }        [TestMethod]        public void Path_FileWithoutNoDirectory()        {            var path = "abc.log";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreSame(path, actual);        }        [TestMethod]        public void Path_FileInRootDirectory()        {            var path = "/abc.log";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual("abc.log", actual);        }        [TestMethod]        public void Path_RootDirectoryOnly()        {            var path = "/";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual(string.Empty, actual);        }        [TestMethod]        public void Path_FileInNonRootDirectory()        {            var path = "/home/sshnet/xyz";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual("xyz", actual);        }        [TestMethod]        public void Path_BackslashIsNotConsideredDirectorySeparator()        {            var path = "/home\\abc.log";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual("home\\abc.log", actual);        }        [TestMethod]        public void Path_ColonIsNotConsideredPathSeparator()        {            var path = "/home:abc.log";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual("home:abc.log", actual);        }        [TestMethod]        public void Path_LeadingWhitespace()        {            var path = "  / \tabc";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual(" \tabc", actual);        }        [TestMethod]        public void Path_TrailingWhitespace()        {            var path = "/abc \t ";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual("abc \t ", actual);        }        [TestMethod]        public void Path_OnlyWhitespace()        {            var path = " ";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual(" ", actual);        }        [TestMethod]        public void Path_FileNameOnlyWhitespace()        {            var path = "/home/\t ";            var actual = PosixPath.GetFileName(path);            Assert.IsNotNull(actual);            Assert.AreEqual("\t ", actual);        }    }}
 |