using System.IO; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Renci.SshNet.Tests.Classes { /// /// Tests for and /// with a root directory as the destination, /// which a download test cannot use. Other cases are covered by /// . /// [TestClass] public class ScpClientTest_ResolveChild_RootDirectory { [TestMethod] public void RootDirectory_ShouldReturnDirectChild() { var root = ScpClient.NormalizeDirectory(Path.GetPathRoot(Path.GetTempPath())); Assert.AreEqual(Path.Combine(root, "file.txt"), ScpClient.ResolveChild(root, "file.txt")); } [TestMethod] [DataRow(".")] [DataRow("..")] public void RootDirectory_DotOrDotDot_ShouldBeRejected(string name) { // "." and ".." resolve to the root itself, which has no parent directory. var root = ScpClient.NormalizeDirectory(Path.GetPathRoot(Path.GetTempPath())); Assert.IsNull(ScpClient.ResolveChild(root, name)); } } }