using Microsoft.Extensions.Logging;
namespace Renci.SshNet.IntegrationTests.TestsFixtures
{
///
/// The base class for integration tests
///
public abstract class IntegrationTestBase
{
private readonly InfrastructureFixture _infrastructureFixture;
private readonly ILogger _logger;
///
/// The SSH Server host name.
///
public string SshServerHostName
{
get
{
return _infrastructureFixture.SshServerHostName;
}
}
///
/// The SSH Server host name
///
public ushort SshServerPort
{
get
{
return _infrastructureFixture.SshServerPort;
}
}
///
/// The admin user that can use SSH Server.
///
public SshUser AdminUser
{
get
{
return _infrastructureFixture.AdminUser;
}
}
///
/// The normal user that can use SSH Server.
///
public SshUser User
{
get
{
return _infrastructureFixture.User;
}
}
protected IntegrationTestBase()
{
_infrastructureFixture = InfrastructureFixture.Instance;
_logger = SshNetLoggingConfiguration.LoggerFactory.CreateLogger(GetType());
_logger.LogDebug("SSH Server: {Host}:{Port}",
_infrastructureFixture.SshServerHostName,
_infrastructureFixture.SshServerPort);
}
///
/// Creates the test file.
///
/// Name of the file.
/// Size in megabytes.
protected void CreateTestFile(string fileName, int size)
{
using (var testFile = File.Create(fileName))
{
var random = new Random();
for (int i = 0; i < 1024 * size; i++)
{
var buffer = new byte[1024];
random.NextBytes(buffer);
testFile.Write(buffer, 0, buffer.Length);
}
}
}
}
}