public void TestCanUploadUsingChecksumDecorator() { // arrange var sftpClient = SftpTestsHelperRoutines.GenerateBasicSftpClient(); BasicSftpFileUploaderDecorator uploaderDecoratorWithChecksumDecoration = new BasicSftpFileUploaderDecorator( new ChecksumFileDecorator(new NullObjectSftpuploadDecorator())); StandardSftpFileUploader standardSftpFileUploader = new StandardSftpFileUploader(uploaderDecoratorWithChecksumDecoration, testLogger); // act sftpClient.Connect(); using (sftpClient) { string newTempFilePath = Path.GetTempFileName(); standardSftpFileUploader.PerformFileUpload(newTempFilePath, $@"{Path.GetFileName(newTempFilePath)}", sftpClient, testLogger); // assert bool fileWasUploadedAndRenamed = sftpClient.Exists(Path.GetFileName(newTempFilePath)); Assert.IsTrue(fileWasUploadedAndRenamed); // clean up string fileName = Path.GetFileName(newTempFilePath); string filenameExtension = Path.GetExtension(fileName); sftpClient.DeleteFile(fileName); sftpClient.DeleteFile(fileName + ".sha256"); } }
public void TestCanUploadUsingTemporaryIndicatorDecorator() { // arrange var sftpClient = SftpTestsHelperRoutines.GenerateBasicSftpClient(); BasicSftpFileUploaderDecorator uploaderDecoratorWithTemporaryFilesUploadDecoration = new BasicSftpFileUploaderDecorator( new UploadPrefixIndicatorDecorator("foobar", new NullObjectSftpuploadDecorator())); StandardSftpFileUploader standardSftpFileUploader = new StandardSftpFileUploader(uploaderDecoratorWithTemporaryFilesUploadDecoration, testLogger); // act sftpClient.Connect(); using (sftpClient) { string newTempFilePath = Path.GetTempFileName(); standardSftpFileUploader.PerformFileUpload(newTempFilePath, $@"{Path.GetFileName(newTempFilePath)}", sftpClient, testLogger); // assert bool fileWasUploadedAndRenamed = sftpClient.Exists(Path.GetFileName(newTempFilePath)); Assert.IsTrue(fileWasUploadedAndRenamed); // clean up sftpClient.DeleteFile(Path.GetFileName(newTempFilePath)); } }
private ISftpFileUploader CreateSftpUploaderFromTransferSettings(TransferSettings transferSettings, ILogger logger) { // TODO: add decorators based on transfersettings ISftpFileUploadDecorator uploader = new BasicSftpFileUploaderDecorator(new NullObjectSftpuploadDecorator()); if (!string.IsNullOrWhiteSpace(transferSettings.UploadPrefix)) { uploader = new UploadPrefixIndicatorDecorator(transferSettings.UploadPrefix, uploader); } if (transferSettings.CalculateChecksum == true) { uploader = new ChecksumFileDecorator(uploader); } //uploader = new ChecksumFileDecorator(uploader); ISftpFileUploader standardFileUploader = new StandardSftpFileUploader(uploader, logger); return(standardFileUploader); }