-
-
Notifications
You must be signed in to change notification settings - Fork 980
Expand file tree
/
Copy pathSftpClientTest.RenameFileAsync.cs
More file actions
53 lines (44 loc) · 1.84 KB
/
SftpClientTest.RenameFileAsync.cs
File metadata and controls
53 lines (44 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 async Task Test_Sftp_RenameFileAsync()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
await sftp.ConnectAsync(default);
string uploadedFileName = Path.GetTempFileName();
string remoteFileName1 = Path.GetRandomFileName();
string remoteFileName2 = Path.GetRandomFileName();
CreateTestFile(uploadedFileName, 1);
using (var file = File.OpenRead(uploadedFileName))
{
using (Stream remoteStream = await sftp.OpenAsync(remoteFileName1, FileMode.CreateNew, FileAccess.Write, default))
{
await file.CopyToAsync(remoteStream, 81920, default);
}
}
await sftp.RenameFileAsync(remoteFileName1, remoteFileName2, default);
File.Delete(uploadedFileName);
sftp.Disconnect();
}
RemoveAllFiles();
}
[TestMethod]
[TestCategory("Sftp")]
[Description("Test passing null to RenameFile.")]
public async Task Test_Sftp_RenameFileAsync_Null()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
await sftp.ConnectAsync(default);
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => sftp.RenameFileAsync(null, null, default));
}
}
}
}