2
0

SftpClientTest.ListDirectoryAsync.cs 929 B

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