| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 | using Microsoft.VisualStudio.TestTools.UnitTesting;using Renci.SshNet.Connection;using System;namespace Renci.SshNet.Tests.Classes.Connection{    [TestClass]    public class SshIdentificationTest    {        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersion()        {            const string protocolVersion = "1.5";            const string softwareVersion = "SSH.NET_2020.0.0";            var sshIdentification = new SshIdentification(protocolVersion, softwareVersion);            Assert.AreSame(protocolVersion, sshIdentification.ProtocolVersion);            Assert.AreSame(softwareVersion, sshIdentification.SoftwareVersion);            Assert.IsNull(sshIdentification.Comments);        }        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersion_ProtocolVersionIsNull()        {            const string protocolVersion = null;            const string softwareVersion = "SSH.NET_2020.0.0";            try            {                _ = new SshIdentification(protocolVersion, softwareVersion);                Assert.Fail();            }            catch (ArgumentNullException ex)            {                Assert.IsNull(ex.InnerException);                Assert.AreEqual("protocolVersion", ex.ParamName);            }        }        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersion_SoftwareVersionIsNull()        {            const string protocolVersion = "2.0";            const string softwareVersion = null;            try            {                _ = new SshIdentification(protocolVersion, softwareVersion);                Assert.Fail();            }            catch (ArgumentNullException ex)            {                Assert.IsNull(ex.InnerException);                Assert.AreEqual("softwareVersion", ex.ParamName);            }        }        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersionAndComments()        {            const string protocolVersion = "1.5";            const string softwareVersion = "SSH.NET_2020.0.0";            const string comments = "Beware, dangerous!";            var sshIdentification = new SshIdentification(protocolVersion, softwareVersion, comments);            Assert.AreSame(protocolVersion, sshIdentification.ProtocolVersion);            Assert.AreSame(softwareVersion, sshIdentification.SoftwareVersion);            Assert.AreSame(comments, sshIdentification.Comments);        }        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersionAndComments_CommentsIsNull()        {            const string protocolVersion = "1.5";            const string softwareVersion = "SSH.NET_2020.0.0";            const string comments = null;            var sshIdentification = new SshIdentification(protocolVersion, softwareVersion, comments);            Assert.AreSame(protocolVersion, sshIdentification.ProtocolVersion);            Assert.AreSame(softwareVersion, sshIdentification.SoftwareVersion);            Assert.IsNull(comments, sshIdentification.Comments);        }        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersionAndComments_ProtocolVersionIsNull()        {            const string protocolVersion = null;            const string softwareVersion = "SSH.NET_2020.0.0";            const string comments = "Beware!";            try            {                _ = new SshIdentification(protocolVersion, softwareVersion, comments);                Assert.Fail();            }            catch (ArgumentNullException ex)            {                Assert.IsNull(ex.InnerException);                Assert.AreEqual("protocolVersion", ex.ParamName);            }        }        [TestMethod]        public void Ctor_ProtocolVersionAndSoftwareVersionAndComments_SoftwareVersionIsNull()        {            const string protocolVersion = "2.0";            const string softwareVersion = null;            const string comments = "Beware!";            try            {                _ = new SshIdentification(protocolVersion, softwareVersion, comments);                Assert.Fail();            }            catch (ArgumentNullException ex)            {                Assert.IsNull(ex.InnerException);                Assert.AreEqual("softwareVersion", ex.ParamName);            }        }        [TestMethod]        public void ToString_Comments()        {            var sshIdentification = new SshIdentification("2.0", "SSH.NET", "Beware, dangerous");            Assert.AreEqual("SSH-2.0-SSH.NET Beware, dangerous", sshIdentification.ToString());        }        [TestMethod]        public void ToString_CommentsIsNull()        {            var sshIdentification = new SshIdentification("2.0", "SSH.NET_2020.0.0");            Assert.AreEqual("SSH-2.0-SSH.NET_2020.0.0", sshIdentification.ToString());            sshIdentification = new SshIdentification("2.0", "SSH.NET_2020.0.0", null);            Assert.AreEqual("SSH-2.0-SSH.NET_2020.0.0", sshIdentification.ToString());        }    }}
 |