-
-
Notifications
You must be signed in to change notification settings - Fork 980
Expand file tree
/
Copy pathSftpClientTest.GetAttributesAsync.cs
More file actions
59 lines (48 loc) · 1.99 KB
/
SftpClientTest.GetAttributesAsync.cs
File metadata and controls
59 lines (48 loc) · 1.99 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
54
55
56
57
58
59
using Renci.SshNet.Common;
namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
{
/// <summary>
/// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
/// </summary>
public partial class SftpClientTest
{
[TestMethod]
[TestCategory("Sftp")]
public async Task Test_Sftp_GetAttributesAsync_Not_Exists()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
await sftp.ConnectAsync(cts.Token);
await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(async () => await sftp.GetAttributesAsync("/asdfgh", cts.Token));
}
}
[TestMethod]
[TestCategory("Sftp")]
public async Task Test_Sftp_GetAttributesAsync_Null()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
await sftp.ConnectAsync(cts.Token);
await Assert.ThrowsExactlyAsync<ArgumentNullException>(async () => await sftp.GetAttributesAsync(null, cts.Token));
}
}
[TestMethod]
[TestCategory("Sftp")]
public async Task Test_Sftp_GetAttributesAsync_Current()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
await sftp.ConnectAsync(cts.Token);
var fileAttributes = await sftp.GetAttributesAsync(".", cts.Token);
Assert.IsNotNull(fileAttributes);
sftp.Disconnect();
}
}
}
}