| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using Renci.SshNet.Tests.Common;
- using Renci.SshNet.Tests.Properties;
- using System;
- using System.IO;
- namespace Renci.SshNet.Tests.Classes
- {
- /// <summary>
- /// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
- /// </summary>
- public partial class SftpClientTest : TestBase
- {
- [TestMethod]
- [TestCategory("Sftp")]
- public void Test_Sftp_Rename_File()
- {
- using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
- {
- sftp.Connect();
- string uploadedFileName = Path.GetTempFileName();
- string remoteFileName1 = Path.GetRandomFileName();
- string remoteFileName2 = Path.GetRandomFileName();
- this.CreateTestFile(uploadedFileName, 1);
- using (var file = File.OpenRead(uploadedFileName))
- {
- sftp.UploadFile(file, remoteFileName1);
- }
- sftp.RenameFile(remoteFileName1, remoteFileName2);
- File.Delete(uploadedFileName);
- sftp.Disconnect();
- }
- }
- [TestMethod]
- [TestCategory("Sftp")]
- [Description("Test passing null to RenameFile.")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void Test_Sftp_RenameFile_Null()
- {
- using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
- {
- sftp.Connect();
- sftp.RenameFile(null, null);
- sftp.Disconnect();
- }
- }
- }
- }
|