Files
dependabot[bot] f5e6ce710c Bump the dependencies group with 11 updates (#1808)
* Bump the dependencies group with 11 updates

Bumps coverlet.collector from 6.0.4 to 10.0.1
Bumps coverlet.msbuild from 6.0.4 to 10.0.1
Bumps GitHubActionsTestLogger from 3.0.1 to 3.0.4
Bumps Meziantou.Analyzer from 3.0.18 to 3.0.114
Bumps Microsoft.Bcl.Cryptography from 10.0.3 to 10.0.9
Bumps Microsoft.Extensions.Logging.Console from 10.0.3 to 10.0.9
Bumps MSTest from 4.1.0 to 4.2.3
Bumps PolySharp from 1.15.0 to 1.16.0
Bumps SonarAnalyzer.CSharp from 10.20.0.135146 to 10.27.0.140913
Bumps System.Formats.Asn1 from 10.0.3 to 10.0.9
Bumps Testcontainers from 4.10.0 to 4.12.0

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>
2026-06-26 17:20:18 +02:00

94 lines
3.0 KiB
C#

using System;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes
{
/// <summary>
/// Provides functionality to connect and interact with SSH server.
/// </summary>
[TestClass]
public class SessionTest : TestBase
{
private Mock<IServiceFactory> _serviceFactoryMock;
private Mock<ISocketFactory> _socketFactoryMock;
protected override void OnInit()
{
base.OnInit();
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
_socketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
}
[TestMethod]
public void ConstructorShouldThrowArgumentNullExceptionWhenConnectionInfoIsNull()
{
const ConnectionInfo connectionInfo = null;
try
{
_ = new Session(connectionInfo, _serviceFactoryMock.Object, _socketFactoryMock.Object);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("connectionInfo", ex.ParamName);
}
}
[TestMethod]
public void ConstructorShouldThrowArgumentNullExceptionWhenServiceFactoryIsNull()
{
var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
IServiceFactory serviceFactory = null;
try
{
_ = new Session(connectionInfo, serviceFactory, _socketFactoryMock.Object);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("serviceFactory", ex.ParamName);
}
}
[TestMethod]
public void ConstructorShouldThrowArgumentNullExceptionWhenSocketFactoryIsNull()
{
var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
const ISocketFactory socketFactory = null;
try
{
_ = new Session(connectionInfo, _serviceFactoryMock.Object, socketFactory);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("socketFactory", ex.ParamName);
}
}
private static ConnectionInfo CreateConnectionInfo(IPEndPoint serverEndPoint, TimeSpan timeout)
{
return new ConnectionInfo(serverEndPoint.Address.ToString(), serverEndPoint.Port, "eric", new NoneAuthenticationMethod("eric"))
{
Timeout = timeout
};
}
}
}