public void Process(CopyItem[] copyItems) { copier.SetWipDir(wipDir); copier.SetCopyArg(copyArgs); copier.SetCopyCmd(copyCmds); Utils.CopyDirectory(srcDir, wipDir); foreach (CopyItem ci in copyItems) { (CopyType ct, string cmd, string args) = copier.GetCpCommand(ci); string srcPath = ci.From; if (ct.Equals(CopyType.Cp)) { srcPath = String.Format("{0}/{1}", srcDir, ci.From); } string dstPath = copier.GetDestPath(ci, ct); if (ct.Equals(CopyType.Cp)) { Utils.CopyFile(srcPath, dstPath); } else { string argv = String.Format("{0} {1} {2}", args, srcPath, dstPath); Utils.Exec(cmd, argv); } } }
public void GetDestPathTest(string toFile, string toDir, CopyType type, string expValue) { string tmpPath = Path.GetTempPath(); var cp = new UtilCopier(); cp.SetCopyArg(copyArgs); cp.SetCopyCmd(copyCmds); cp.SetWipDir(tmpPath); var ci = new CopyItem(); ci.ToFile = toFile; ci.ToDir = toDir; var dstPath = cp.GetDestPath(ci, type); var expPath = String.Format(expValue, tmpPath); Assert.AreEqual(expPath, dstPath); }