mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 17:25:51 +00:00
933613e31c
* Update to MSTest 4 * fix TestMethodForPlatformAttribute replace Execute with ExecuteAsync and fix MSTEST0057 https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0057 (link currently dead) * fix compilation error * fix MSTEST0037 https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0037 * fix MSTEST0052 https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0052 * fix MSTEST0045 Fixing this properly would require the tests to respect testContext.CancellationToken. I'm not sure this is worth fixing or how to even do it for the sync methods. https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0045 * fix MSTEST0001 I assume that parallelization would break a lot of stuff. https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0001 * Workaround for new Sonar warnings because of MSTest4 * revert analyzer fixes in OrderedDictionaryTest * use custom sync console logger for MSTest to work around https://github.com/microsoft/testfx/issues/6457 * remove redundant args --------- Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> Co-authored-by: Rob Hague <rob.hague00@gmail.com>
81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using System.Diagnostics;
|
|
|
|
namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
|
{
|
|
/// <summary>
|
|
/// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
|
|
/// </summary>
|
|
public partial class SftpClientTest : IntegrationTestBase
|
|
{
|
|
[TestMethod]
|
|
[TestCategory("Sftp")]
|
|
public void Test_Sftp_SynchronizeDirectories()
|
|
{
|
|
RemoveAllFiles();
|
|
|
|
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
|
{
|
|
sftp.Connect();
|
|
|
|
string uploadedFileName = Path.GetTempFileName();
|
|
|
|
string sourceDir = Path.GetDirectoryName(uploadedFileName);
|
|
string destDir = "/home/sshnet/";
|
|
string searchPattern = Path.GetFileName(uploadedFileName);
|
|
var upLoadedFiles = sftp.SynchronizeDirectories(sourceDir, destDir, searchPattern);
|
|
|
|
Assert.IsGreaterThan(0, upLoadedFiles.Count());
|
|
|
|
foreach (var file in upLoadedFiles)
|
|
{
|
|
Debug.WriteLine(file.FullName);
|
|
}
|
|
|
|
sftp.Disconnect();
|
|
}
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory("Sftp")]
|
|
public void Test_Sftp_BeginSynchronizeDirectories()
|
|
{
|
|
RemoveAllFiles();
|
|
|
|
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
|
{
|
|
sftp.Connect();
|
|
|
|
string uploadedFileName = Path.GetTempFileName();
|
|
|
|
string sourceDir = Path.GetDirectoryName(uploadedFileName);
|
|
string destDir = "/home/sshnet/";
|
|
string searchPattern = Path.GetFileName(uploadedFileName);
|
|
|
|
var asyncResult = sftp.BeginSynchronizeDirectories(sourceDir,
|
|
destDir,
|
|
searchPattern,
|
|
null,
|
|
null
|
|
);
|
|
|
|
// Wait for the WaitHandle to become signaled.
|
|
asyncResult.AsyncWaitHandle.WaitOne(1000);
|
|
|
|
var upLoadedFiles = sftp.EndSynchronizeDirectories(asyncResult);
|
|
|
|
Assert.IsGreaterThan(0, upLoadedFiles.Count());
|
|
|
|
foreach (var file in upLoadedFiles)
|
|
{
|
|
Debug.WriteLine(file.FullName);
|
|
}
|
|
|
|
// Close the wait handle.
|
|
asyncResult.AsyncWaitHandle.Close();
|
|
|
|
sftp.Disconnect();
|
|
}
|
|
}
|
|
}
|
|
}
|