Esempio n. 1
0
        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));
            }
        }