| 12345678910111213141516171819202122232425262728293031323334353637 | using Microsoft.VisualStudio.TestTools.UnitTesting;using Renci.SshNet.Common;using Renci.SshNet.Tests.Common;using Renci.SshNet.Tests.Properties;using System;namespace Renci.SshNet.Tests.Classes{    /// <summary>    /// Represents SSH command that can be executed.    /// </summary>    [TestClass]    public partial class SshCommandTest : TestBase    {        [TestMethod]        [ExpectedException(typeof(SshConnectionException))]        public void Test_Execute_SingleCommand_Without_Connecting()        {            using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))            {                var result = ExecuteTestCommand(client);                Assert.IsTrue(result);            }        }        private static bool ExecuteTestCommand(SshClient s)        {            var testValue = Guid.NewGuid().ToString();            var command = string.Format("echo {0}", testValue);            var cmd = s.CreateCommand(command);            var result = cmd.Execute();            result = result.Substring(0, result.Length - 1);    //  Remove \n character returned by command            return result.Equals(testValue);        }    }}
 |