mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 17:25:51 +00:00
16d84d0395
* Bump coverlet.collector from 6.0.2 to 6.0.4 Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.2 to 6.0.4. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.2...v6.0.4) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * update test deps * update test deps * some fixes * group dependencies * analyzer fixes * just group them all together * more cleanup * silent analyzers -> suggestion * restore constant --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Robert Hague <rh@johnstreetcapital.com> Co-authored-by: Rob Hague <rob.hague00@gmail.com>
142 lines
5.0 KiB
C#
142 lines
5.0 KiB
C#
using System;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
using Renci.SshNet.Connection;
|
|
|
|
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.AreEqual(protocolVersion, sshIdentification.ProtocolVersion);
|
|
Assert.AreEqual(softwareVersion, sshIdentification.SoftwareVersion);
|
|
Assert.AreEqual(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.AreEqual(protocolVersion, sshIdentification.ProtocolVersion);
|
|
Assert.AreEqual(softwareVersion, sshIdentification.SoftwareVersion);
|
|
Assert.IsNull(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());
|
|
}
|
|
}
|
|
}
|