using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Renci.SshNet.Tests.Classes
{
[TestClass]
public class RemotePathDoubleQuoteTransformationTest
{
private IRemotePathTransformation _transformation;
[TestInitialize]
public void SetUp()
{
_transformation = new RemotePathDoubleQuoteTransformation();
}
///
/// Test cases from triple-slash comments
///
[TestMethod]
public void Mixed()
{
Assert.AreEqual("\"/var/log/auth.log\"", _transformation.Transform("/var/log/auth.log"));
Assert.AreEqual("\"/var/mp3/Guns N' Roses\"", _transformation.Transform("/var/mp3/Guns N' Roses"));
Assert.AreEqual("\"/var/garbage!/temp\"", _transformation.Transform("/var/garbage!/temp"));
Assert.AreEqual("\"/var/would be 'kewl'!, not?\"", _transformation.Transform("/var/would be 'kewl'!, not?"));
Assert.AreEqual("\"\"", _transformation.Transform(string.Empty));
Assert.AreEqual("\"Hello \\\"World\\\"\"", _transformation.Transform("Hello \"World\""));
}
[TestMethod]
public void Null()
{
const string path = null;
try
{
_transformation.Transform(path);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("path", ex.ParamName);
}
}
[TestMethod]
public void Ampersand_Embedded()
{
const string path = "You&Me";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"You&Me\"", actual);
}
[TestMethod]
public void Ampersand_Leading()
{
const string path = "&Or";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"&Or\"", actual);
}
[TestMethod]
public void Ampersand_LeadingAndTrailing()
{
const string path = "&Or&";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"&Or&\"", actual);
}
[TestMethod]
public void Ampersand_Trailing()
{
const string path = "And&";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"And&\"", actual);
}
[TestMethod]
public void Asterisk_Embedded()
{
const string path = "Love*Hate";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Love*Hate\"", actual);
}
[TestMethod]
public void Asterisk_Leading()
{
const string path = "*Times";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"*Times\"", actual);
}
[TestMethod]
public void Asterisk_LeadingAndTrailing()
{
const string path = "*WAR*";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"*WAR*\"", actual);
}
[TestMethod]
public void Asterisk_Trailing()
{
const string path = "Censor*";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Censor*\"", actual);
}
[TestMethod]
public void Backslash_Embedded()
{
const string path = "Hello\\World";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Hello\\World\"", actual);
}
[TestMethod]
public void Backslash_Leading()
{
const string path = "\\Hello";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"\\Hello\"", actual);
}
[TestMethod]
public void Backslash_LeadingAndTrailing()
{
const string path = "\\Hello\\";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"\\Hello\\\"", actual);
}
[TestMethod]
public void Backslash_Trailing()
{
const string path = "HelloWorld\\";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"HelloWorld\\\"", actual);
}
[TestMethod]
public void Backtick_Embedded()
{
const string path = "back`tick";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"back`tick\"", actual);
}
[TestMethod]
public void Backtick_Leading()
{
const string path = "`front";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"`front\"", actual);
}
[TestMethod]
public void Backtick_LeadingAndTrailing()
{
const string path = "`FrontAndBack`";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"`FrontAndBack`\"", actual);
}
[TestMethod]
public void Backtick_Trailing()
{
const string path = "back`";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"back`\"", actual);
}
[TestMethod]
public void Circumflex_Embedded()
{
const string path = "You^Me";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"You^Me\"", actual);
}
[TestMethod]
public void Circumflex_Leading()
{
const string path = "^Or";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"^Or\"", actual);
}
[TestMethod]
public void Circumflex_LeadingAndTrailing()
{
const string path = "^Or^";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"^Or^\"", actual);
}
[TestMethod]
public void Circumflex_Trailing()
{
const string path = "And^";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"And^\"", actual);
}
[TestMethod]
public void CurlyBrackets_Close_Embedded()
{
const string path = "Halo}Devine";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Halo}Devine\"", actual);
}
[TestMethod]
public void CurlyBrackets_Close_Leading()
{
const string path = "}Open";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"}Open\"", actual);
}
[TestMethod]
public void CurlyBrackets_Close_LeadingAndTrailing()
{
const string path = "}Closed}";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"}Closed}\"", actual);
}
[TestMethod]
public void CurlyBrackets_Close_Trailing()
{
const string path = "Finish}";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Finish}\"", actual);
}
[TestMethod]
public void CurlyBrackets_Open_Embedded()
{
const string path = "Halo{Devine";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Halo{Devine\"", actual);
}
[TestMethod]
public void CurlyBrackets_Open_Leading()
{
const string path = "{Open";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"{Open\"", actual);
}
[TestMethod]
public void CurlyBrackets_Open_LeadingAndTrailing()
{
const string path = "{Closed{";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"{Closed{\"", actual);
}
[TestMethod]
public void CurlyBrackets_Open_Trailing()
{
const string path = "Finish{";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Finish{\"", actual);
}
[TestMethod]
public void Dollar_Embedded()
{
const string path = "IGiveYouOne$ForYourThoughts";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"IGiveYouOne$ForYourThoughts\"", actual);
}
[TestMethod]
public void Dollar_Leading()
{
const string path = "$Blues";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"$Blues\"", actual);
}
[TestMethod]
public void Dollar_LeadingAndTrailing()
{
const string path = "$SUM$";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"$SUM$\"", actual);
}
[TestMethod]
public void Dollar_Trailing()
{
const string path = "NotCravingForMore$";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"NotCravingForMore$\"", actual);
}
[TestMethod]
public void DoubleQuote_Embedded()
{
const string path = "DoNot\"MeOnThis";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"DoNot\\\"MeOnThis\"", actual);
}
[TestMethod]
public void DoubleQuote_Leading()
{
const string path = "\"OrNotToQuote";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"\\\"OrNotToQuote\"", actual);
}
[TestMethod]
public void DoubleQuote_Trailing()
{
const string path = "Famous\"";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Famous\\\"\"", actual);
}
[TestMethod]
public void DoubleQuote_LeadingAndTrailing()
{
const string path = "\"OrNotTo\"";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"\\\"OrNotTo\\\"\"", actual);
}
[TestMethod]
public void Equals_Embedded()
{
const string path = "You=Me";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"You=Me\"", actual);
}
[TestMethod]
public void Equals_Leading()
{
const string path = "=Or";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"=Or\"", actual);
}
[TestMethod]
public void Equals_LeadingAndTrailing()
{
const string path = "=Or=";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"=Or=\"", actual);
}
[TestMethod]
public void Equals_Trailing()
{
const string path = "And=";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"And=\"", actual);
}
[TestMethod]
public void ExclamationMark_Embedded_Single()
{
const string path = "/var/garbage!/temp";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"/var/garbage!/temp\"", actual);
}
[TestMethod]
public void ExclamationMark_Embedded_Sequence()
{
const string path = "/var/garbage!!/temp";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"/var/garbage!!/temp\"", actual);
}
[TestMethod]
public void ExclamationMark_Leading()
{
const string path = "!Error";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"!Error\"", actual);
}
[TestMethod]
public void ExclamationMark_LeadingAndTrailing()
{
const string path = "!ignore!";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"!ignore!\"", actual);
}
[TestMethod]
public void ExclamationMark_Trailing()
{
const string path = "Done!";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Done!\"", actual);
}
[TestMethod]
public void GreaterThan_Embedded()
{
const string path = "You>Me";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"You>Me\"", actual);
}
[TestMethod]
public void GreaterThan_Leading()
{
const string path = ">Or";
var actual = _transformation.Transform(path);
Assert.AreEqual("\">Or\"", actual);
}
[TestMethod]
public void GreaterThan_LeadingAndTrailing()
{
const string path = ">Or>";
var actual = _transformation.Transform(path);
Assert.AreEqual("\">Or>\"", actual);
}
[TestMethod]
public void GreaterThan_Trailing()
{
const string path = "And>";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"And>\"", actual);
}
[TestMethod]
public void Hash_Embedded()
{
const string path = "Smoke#EveryDay";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Smoke#EveryDay\"", actual);
}
[TestMethod]
public void Hash_Leading()
{
const string path = "#4Ever";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"#4Ever\"", actual);
}
[TestMethod]
public void Hash_LeadingAndTrailing()
{
const string path = "#4Ever#";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"#4Ever#\"", actual);
}
[TestMethod]
public void Hash_Trailing()
{
const string path = "Legalize#";
var actual = _transformation.Transform(path);
Assert.AreEqual("\"Legalize#\"", actual);
}
[TestMethod]
public void LessThan_Embedded()
{
const string path = "You