public void TimeMeasureRenamerWithNullFile() { FileRenamer baseRenamer = new FileRenamer(); FileRenamerTimeMeasure renamer = new FileRenamerTimeMeasure(baseRenamer); renamer.Rename(null); }
public void TimeMeasureRenamerSuccessful() { FileRenamer baseRenamer = new FileRenamer(); FileRenamerTimeMeasure renamer = new FileRenamerTimeMeasure(baseRenamer); MP3File file = new MP3File("test.mp3"); Assert.AreEqual(new TimeSpan(0L), renamer.ElapsedTime); renamer.Rename(file); Assert.AreEqual("test_(new).mp3", file.Path); Assert.IsNotNull(renamer.ElapsedTime); Assert.AreNotEqual(new TimeSpan(0L), renamer.ElapsedTime); }
public void Process(string[] args, MP3File[] files, Permitions userPermitions = Permitions.Guest) { if (files == null || files.Length == 0) { throw new ArgumentException("No files to process"); } ArgumentsParser parser = new ArgumentsParser(); Arguments arguments = parser.ParseArguments(args); foreach (var file in files) { string message = file.Path; IFileRenamer fileRenamer = new FileRenamer(); if (arguments.IsCheckPermitions) { IFileRenamer oldFileRenamer = fileRenamer; IPermitionsChecker checker = new PermitionsChecker(); fileRenamer = new FileRenamerPermitionsChecker(oldFileRenamer, checker, userPermitions); } if (arguments.IsTimeMeasure) { IFileRenamer oldFileRenamer = fileRenamer; fileRenamer = new FileRenamerTimeMeasure(oldFileRenamer); } fileRenamer.Rename(file); message += " successfully renamed to " + file.Path; if (arguments.IsTimeMeasure) { message += " in " + ((FileRenamerTimeMeasure)fileRenamer).ElapsedTime; } Console.WriteLine(message); } }