SftpClientTest.ListDirectoryAsync.cs 934 B

12345678910111213141516171819202122232425262728293031
  1. using System.Diagnostics;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using Microsoft.VisualStudio.TestTools.UnitTesting;
  5. using Renci.SshNet.Common;
  6. using Renci.SshNet.Tests.Properties;
  7. namespace Renci.SshNet.Tests.Classes
  8. {
  9. /// <summary>
  10. /// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
  11. /// </summary>
  12. public partial class SftpClientTest
  13. {
  14. [TestMethod]
  15. [TestCategory("Sftp")]
  16. [ExpectedException(typeof(SshConnectionException))]
  17. public async Task Test_Sftp_ListDirectoryAsync_Without_ConnectingAsync()
  18. {
  19. using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
  20. {
  21. await foreach (var file in sftp.ListDirectoryAsync(".", CancellationToken.None))
  22. {
  23. Debug.WriteLine(file.FullName);
  24. }
  25. }
  26. }
  27. }
  28. }