SftpClientTest.DeleteDirectory.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. [ExpectedException(typeof(SftpPathNotFoundException))]
  12. public void Test_Sftp_DeleteDirectory_Which_Doesnt_Exists()
  13. {
  14. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
  15. {
  16. sftp.Connect();
  17. sftp.DeleteDirectory("abcdef");
  18. sftp.Disconnect();
  19. }
  20. }
  21. [TestMethod]
  22. [TestCategory("Sftp")]
  23. [ExpectedException(typeof(SftpPermissionDeniedException))]
  24. public void Test_Sftp_DeleteDirectory_Which_No_Permissions()
  25. {
  26. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, AdminUser.UserName, AdminUser.Password))
  27. {
  28. sftp.Connect();
  29. sftp.DeleteDirectory("/usr");
  30. sftp.Disconnect();
  31. }
  32. }
  33. [TestMethod]
  34. [TestCategory("Sftp")]
  35. public void Test_Sftp_DeleteDirectory()
  36. {
  37. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
  38. {
  39. sftp.Connect();
  40. sftp.CreateDirectory("abcdef");
  41. sftp.DeleteDirectory("abcdef");
  42. sftp.Disconnect();
  43. }
  44. }
  45. [TestMethod]
  46. [TestCategory("Sftp")]
  47. [Description("Test passing null to DeleteDirectory.")]
  48. [ExpectedException(typeof(ArgumentException))]
  49. public void Test_Sftp_DeleteDirectory_Null()
  50. {
  51. using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
  52. {
  53. sftp.Connect();
  54. sftp.DeleteDirectory(null);
  55. sftp.Disconnect();
  56. }
  57. }
  58. }
  59. }