-
-
Notifications
You must be signed in to change notification settings - Fork 980
Expand file tree
/
Copy pathSftpClientTest.RenameFile.cs
More file actions
50 lines (41 loc) · 1.55 KB
/
SftpClientTest.RenameFile.cs
File metadata and controls
50 lines (41 loc) · 1.55 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
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_Rename_File()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
sftp.Connect();
string uploadedFileName = Path.GetTempFileName();
string remoteFileName1 = Path.GetRandomFileName();
string remoteFileName2 = Path.GetRandomFileName();
CreateTestFile(uploadedFileName, 1);
using (var file = File.OpenRead(uploadedFileName))
{
sftp.UploadFile(file, remoteFileName1);
}
sftp.RenameFile(remoteFileName1, remoteFileName2);
File.Delete(uploadedFileName);
sftp.Disconnect();
}
RemoveAllFiles();
}
[TestMethod]
[TestCategory("Sftp")]
[Description("Test passing null to RenameFile.")]
public void Test_Sftp_RenameFile_Null()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
sftp.Connect();
Assert.ThrowsExactly<ArgumentNullException>(() => sftp.RenameFile(null, null));
}
}
}
}