mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 09:15:47 +00:00
d40bc43ac1
* Refactor logging to allow a loggerfactory per session specified in the ConnectionInfo. This commit introduces an `ILoggerFactory` to various classes, replacing the static logger factory with an instance-based approach for more flexible and session-specific logging. These changes improve the logging framework's flexibility and maintainability and allow unit testing of logging. * Improvements bases on feedback. Fixed tests. Added documentation. * Update src/Renci.SshNet/ConnectionInfo.cs --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com>
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using System.Net;
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
using Moq;
|
|
|
|
using Renci.SshNet.Connection;
|
|
using Renci.SshNet.Tests.Common;
|
|
|
|
namespace Renci.SshNet.Tests.Classes.Connection
|
|
{
|
|
public abstract class Socks4ConnectorTestBase : TripleATestBase
|
|
{
|
|
internal Mock<ISocketFactory> SocketFactoryMock { get; private set; }
|
|
internal Socks4Connector Connector { get; private set; }
|
|
internal SocketFactory SocketFactory { get; private set; }
|
|
|
|
protected virtual void CreateMocks()
|
|
{
|
|
SocketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
|
|
}
|
|
|
|
protected virtual void SetupData()
|
|
{
|
|
Connector = new Socks4Connector(SocketFactoryMock.Object, NullLoggerFactory.Instance);
|
|
SocketFactory = new SocketFactory();
|
|
}
|
|
|
|
protected virtual void SetupMocks()
|
|
{
|
|
}
|
|
|
|
protected sealed override void Arrange()
|
|
{
|
|
CreateMocks();
|
|
SetupData();
|
|
SetupMocks();
|
|
}
|
|
|
|
protected ConnectionInfo CreateConnectionInfo(string proxyUser, string proxyPassword)
|
|
{
|
|
return new ConnectionInfo(IPAddress.Loopback.ToString(),
|
|
1030,
|
|
"user",
|
|
ProxyTypes.Socks4,
|
|
IPAddress.Loopback.ToString(),
|
|
8122,
|
|
proxyUser,
|
|
proxyPassword,
|
|
new KeyboardInteractiveAuthenticationMethod("user"));
|
|
}
|
|
}
|
|
}
|