Esempio n. 1
0
        public static void Apply(this SingleFile step, TemporaryFile downloadedFile, TemporaryDirectory workingDir)
        {
            #region Sanity checks
            if (step == null)
            {
                throw new ArgumentNullException(nameof(step));
            }
            if (downloadedFile == null)
            {
                throw new ArgumentNullException(nameof(downloadedFile));
            }
            if (workingDir == null)
            {
                throw new ArgumentNullException(nameof(workingDir));
            }
            #endregion

            if (string.IsNullOrEmpty(step.Destination))
            {
                throw new IOException(Resources.FileMissingDest);
            }

            var    builder         = new DirectoryBuilder(workingDir);
            string destinationPath = builder.NewFilePath(
                FileUtils.UnifySlashes(step.Destination),
                FileUtils.FromUnixTime(0),
                step.Executable);
            FileUtils.Replace(downloadedFile, destinationPath);
            builder.CompletePending();
        }
        public void Basic()
        {
            _builder.EnsureDirectory();
            _builder.CreateDirectory("dir", TestFile.DefaultLastWrite);
            File.WriteAllText(_builder.NewFilePath("dir/file", TestFile.DefaultLastWrite), TestFile.DefaultContents);
            _builder.QueueHardlink("dir/hardlink", "dir/file");
            File.WriteAllText(_builder.NewFilePath("dir/executable", TestFile.DefaultLastWrite, executable: true), TestFile.DefaultContents);
            _builder.CreateSymlink("dir/symlink", "target");
            _builder.CompletePending();

            new TestRoot
            {
                new TestDirectory("dir")
                {
                    new TestFile("file"),
                    new TestFile("hardlink"),
                    new TestFile("executable")
                    {
                        IsExecutable = true
                    },
                    new TestSymlink("symlink", "target")
                }
            }.Verify(_tempDir);
        }