2
0

SftpClientTest.GetAttributesAsync.cs 1022 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  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. public partial class SftpClientTest
  10. {
  11. [TestMethod]
  12. public async Task GetAttributesAsync_Throws_WhenNotConnected()
  13. {
  14. using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
  15. {
  16. await Assert.ThrowsExceptionAsync<SshConnectionException>(() => sftp.GetAttributesAsync(".", CancellationToken.None));
  17. }
  18. }
  19. [TestMethod]
  20. public async Task GetAttributesAsync_Throws_WhenDisposed()
  21. {
  22. var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD);
  23. sftp.Dispose();
  24. await Assert.ThrowsExceptionAsync<ObjectDisposedException>(() => sftp.GetAttributesAsync(".", CancellationToken.None));
  25. }
  26. }
  27. }