Exemple #1
0
        public void ExtractsFiles()
        {
            _engine       = new AutomationEngineInstance(null);
            _extractFiles = new ExtractFilesCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\compressed.zip");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string outputPath = Environment.CurrentDirectory;

            VariableMethods.CreateTestVariable(outputPath, _engine, "outputPath", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(List <>));

            _extractFiles.v_FilePathOrigin         = "{inputPath}";
            _extractFiles.v_PathDestination        = "{outputPath}";
            _extractFiles.v_OutputUserVariableName = "{output}";

            _extractFiles.RunCommand(_engine);

            Assert.True(IO.File.Exists(Path.Combine(outputPath, @"compressed\compressed.txt")));
            Assert.True(Directory.Exists(Path.Combine(outputPath, @"compressed\emptyFolder")));
            Assert.True(IO.File.Exists(Path.Combine(outputPath, @"compressed\subfolder\subfolder2\deepfile.txt")));

            IO.File.Delete(Path.Combine(outputPath, @"compressed\compressed.txt"));
            Directory.Delete(Path.Combine(outputPath, @"compressed\emptyFolder"));
            IO.File.Delete(Path.Combine(outputPath, @"compressed\subfolder\subfolder2\deepfile.txt"));
            Directory.Delete(Path.Combine(outputPath, @"compressed\subfolder\subfolder2"));
            Directory.Delete(Path.Combine(outputPath, @"compressed\subfolder"));
            Directory.Delete(Path.Combine(outputPath, @"compressed"));
        }
Exemple #2
0
        public async global::System.Threading.Tasks.Task HandlesNonDirectoryOutputTarget()
        {
            _engine       = new AutomationEngineInstance(null);
            _extractFiles = new ExtractFilesCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\compressed.zip");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string outputPath = inputPath;

            VariableMethods.CreateTestVariable(outputPath, _engine, "outputPath", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(List <>));

            _extractFiles.v_FilePathOrigin         = "{inputPath}";
            _extractFiles.v_PathDestination        = "{outputPath}";
            _extractFiles.v_OutputUserVariableName = "{output}";

            await Assert.ThrowsAsync <DirectoryNotFoundException>(() => _extractFiles.RunCommand(_engine));
        }
Exemple #3
0
        public void HandlesNonZipInput()
        {
            _engine       = new AutomationEngineInstance(null);
            _extractFiles = new ExtractFilesCommand();

            string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            string inputPath        = Path.Combine(projectDirectory, @"Resources\toCompress.txt");

            VariableMethods.CreateTestVariable(inputPath, _engine, "inputPath", typeof(string));

            string outputPath = Environment.CurrentDirectory;

            VariableMethods.CreateTestVariable(outputPath, _engine, "outputPath", typeof(string));
            VariableMethods.CreateTestVariable(null, _engine, "output", typeof(List <>));

            _extractFiles.v_FilePathOrigin         = "{inputPath}";
            _extractFiles.v_PathDestination        = "{outputPath}";
            _extractFiles.v_OutputUserVariableName = "{output}";

            Assert.Throws <FileNotFoundException>(() => _extractFiles.RunCommand(_engine));
        }