SftpClientTest.DeleteDirectory.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Renci.SshNet.Common;
  2. namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
  3. {
  4. /// <summary>
  5. /// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
  6. /// </summary>
  7. public partial class SftpClientTest : IntegrationTestBase
  8. {
  9. [TestMethod]
  10. [TestCategory("Sftp")]
  11. public void Test_Sftp_DeleteDirectory_Which_Doesnt_Exists()
  12. {
  13. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
  14. {
  15. sftp.Connect();
  16. Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.DeleteDirectory("abcdef"));
  17. }
  18. }
  19. [TestMethod]
  20. [TestCategory("Sftp")]
  21. public void Test_Sftp_DeleteDirectory_Which_No_Permissions()
  22. {
  23. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, AdminUser.UserName, AdminUser.Password))
  24. {
  25. sftp.Connect();
  26. Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.DeleteDirectory("/usr"));
  27. }
  28. }
  29. [TestMethod]
  30. [TestCategory("Sftp")]
  31. public void Test_Sftp_DeleteDirectory()
  32. {
  33. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
  34. {
  35. sftp.Connect();
  36. sftp.CreateDirectory("abcdef");
  37. sftp.DeleteDirectory("abcdef");
  38. sftp.Disconnect();
  39. }
  40. }
  41. [TestMethod]
  42. [TestCategory("Sftp")]
  43. [Description("Test passing null to DeleteDirectory.")]
  44. public void Test_Sftp_DeleteDirectory_Null()
  45. {
  46. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
  47. {
  48. sftp.Connect();
  49. Assert.ThrowsException<ArgumentNullException>(() => sftp.DeleteDirectory(null));
  50. }
  51. }
  52. }
  53. }