public void ExecuteToFileName() { MockFileManager fileSystem = new MockFileManager(); fileSystem.AddFile("file1.mp3", new MockMp3File("file1.mp3", fileSystem) { Artist = "Bon Jovi", Title = "It's my life" }); fileSystem.AddFile("file2.mp3", new MockMp3File("file2.mp3", fileSystem) { Artist = "Imagine Dragons", Title = "Believer" }); RenamerArguments renamerArguments = new RenamerArguments { IsRecursive = false, Action = AllowedActions.ToFileName, Mask = "*.mp3" }; Processor processor = new Processor(renamerArguments, fileSystem); processor.Process(); Assert.IsTrue(fileSystem.Exist("\\Bon Jovi - It's my life.mp3")); Assert.IsTrue(fileSystem.Exist("\\Imagine Dragons - Believer.mp3")); Assert.AreEqual(2, fileSystem.Files.Count); }
public void ExecuteToTag() { MockFileManager fileSystem = new MockFileManager(); fileSystem.AddFile("Bon Jovi - It's my life.mp3", new MockMp3File("Bon Jovi - It's my life.mp3", fileSystem)); fileSystem.AddFile("Imagine Dragons - Believer.mp3", new MockMp3File("Imagine Dragons - Believer.mp3", fileSystem)); RenamerArguments renamerArguments = new RenamerArguments { IsRecursive = false, Action = AllowedActions.ToTag, Mask = "*.mp3" }; Processor processor = new Processor(renamerArguments, fileSystem); processor.Process(); Assert.AreEqual("Bon Jovi", fileSystem.Files["Bon Jovi - It's my life.mp3"].Artist); Assert.AreEqual("It's my life", fileSystem.Files["Bon Jovi - It's my life.mp3"].Title); Assert.AreEqual("Imagine Dragons", fileSystem.Files["Imagine Dragons - Believer.mp3"].Artist); Assert.AreEqual("Believer", fileSystem.Files["Imagine Dragons - Believer.mp3"].Title); Assert.AreEqual(2, fileSystem.Files.Count); }
public Processor(RenamerArguments renamerArguments, ILogger logger) : this(renamerArguments) { if (logger == null) { throw new ArgumentException("RenamerArguments shouldn't be null!"); } _logger = logger; }
public void ParseArgumentsToFileName() { ArgumentsParser parser = new ArgumentsParser(); RenamerArguments renamerArguments = parser.ParseArguments(new string[] { "*.mp3", "-toFileName" }); Assert.AreEqual("*.mp3", renamerArguments.Mask); Assert.IsFalse(renamerArguments.IsRecursive); Assert.AreEqual(AllowedActions.ToFileName, renamerArguments.Action); }
public void ParseArgumentsRecusiveToTag() { ArgumentsParser parser = new ArgumentsParser(); RenamerArguments renamerArguments = parser.ParseArguments(new string[] { "*.mp3", "-recursive", "-toTag" }); Assert.AreEqual("*.mp3", renamerArguments.Mask); Assert.IsTrue(renamerArguments.IsRecursive); Assert.AreEqual(AllowedActions.ToTag, renamerArguments.Action); }
public Processor(RenamerArguments renamerArguments, IFileManager fileManager) { if (renamerArguments == null) { throw new ArgumentException("RenamerArguments shouldn't be null!"); } _arguments = renamerArguments; _logger = null; _fileManager = fileManager; }
public void Execute(RenamerArguments renamerArguments, ILogger logger) { try { Processor processor = new Processor(renamerArguments, logger); processor.Process(); } catch (Exception e) { logger.WriteMessage(e.Message, Status.Error); Console.WriteLine("Process failed! See log.txt for full information"); } }
public static RenamerArguments GetArguments(string[] args, ILogger logger) { ArgumentsParser parser = new ArgumentsParser(); RenamerArguments renamerArguments = null; try { renamerArguments = parser.ParseArguments(args); } catch (ArgumentException e) { logger.WriteMessage(e.Message, Status.Error); Console.WriteLine("Process failed! See log.txt for full information"); } return(renamerArguments); }
public Processor(RenamerArguments renamerArguments, ILogger logger, IFileManager fileManager) : this(renamerArguments, logger) { _fileManager = fileManager; }
public void ParseWithMoreArguments() { ArgumentsParser parser = new ArgumentsParser(); RenamerArguments renamerArguments = parser.ParseArguments(new string[] { "*.mp3", "-recursive", "-toFileName", "-toTag" }); }
public void ParseWithLessArguments() { ArgumentsParser parser = new ArgumentsParser(); RenamerArguments renamerArguments = parser.ParseArguments(new string[] { "*.mp3" }); }
public void ParseWithNoArguments() { ArgumentsParser parser = new ArgumentsParser(); RenamerArguments renamerArguments = parser.ParseArguments(new string[] { }); }