forked from sshnet/SSH.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScpClientTests.cs
More file actions
41 lines (33 loc) · 1.15 KB
/
Copy pathScpClientTests.cs
File metadata and controls
41 lines (33 loc) · 1.15 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
namespace IntegrationTests
{
/// <summary>
/// The SCP client integration tests
/// </summary>
[TestClass]
public class ScpClientTests : IntegrationTestBase, IDisposable
{
private readonly ScpClient _scpClient;
public ScpClientTests()
{
_scpClient = new ScpClient(SshServerHostName, SshServerPort, User.UserName, User.Password);
_scpClient.Connect();
}
[TestMethod]
public void Upload_And_Download_FileStream()
{
var file = $"/tmp/{Guid.NewGuid()}.txt";
var fileContent = "File content !@#$%^&*()_+{}:,./<>[];'\\|";
using var uploadStream = new MemoryStream(Encoding.UTF8.GetBytes(fileContent));
_scpClient.Upload(uploadStream, file);
using var downloadStream = new MemoryStream();
_scpClient.Download(file, downloadStream);
var result = Encoding.UTF8.GetString(downloadStream.ToArray());
Assert.AreEqual(fileContent, result);
}
public void Dispose()
{
_scpClient.Disconnect();
_scpClient.Dispose();
}
}
}