public ChangeTagsCommand(IMp3File mp3File, string mask) { File = mp3File; _maskParser = new MaskParser(mask); OldTags = new Mp3Tags(); File.Tags.CopyTo(OldTags); }
public void SetTest() { Mp3Tags tags = new Mp3Tags(); ArgumentException expectedException = null; try { tags.SetTag(null, "sd"); } catch (ArgumentException e) { expectedException = e; } Assert.IsNotNull(expectedException); tags.SetTag("artist", "test"); Assert.AreEqual("test", tags.Artist); tags.SetTag("album", "test"); Assert.AreEqual("test", tags.Album); tags.SetTag("coMment", "test"); Assert.AreEqual("test", tags.Comment); tags.SetTag("genre", "test"); Assert.AreEqual("test", tags.Genre); tags.SetTag("title", "test"); Assert.AreEqual("test", tags.Title); tags.SetTag("not existing tag", "value"); }
public void YearSetTest() { Mp3Tags tags = new Mp3Tags(); tags.SetTag("year", "2015"); Assert.AreEqual(2015u, tags.Year); tags.SetTag("year", "two thousand fifteen"); }
public void CopyTo(Mp3Tags destination) { destination.Album = Album; destination.Artist = Artist; destination.Genre = Genre; destination.Title = Title; destination.Track = Track; }
public void Init() { _fileLoader = new TestFileLoader(); _testTager = new Tager(_fileLoader); _tesTags = new Mp3Tags() { Album = "Album", Artist = "Artist", Comment = "Comment", Genre = "Genre", Title = "Title", Year = 2015, Track = 1 }; }
public void NameNotChangeIfTagIsEmpty() { var tags = new Mp3Tags() { Album = "Album", Artist = "", Comment = "Comment", Genre = "Genre", Title = "Title", Year = 2015, Track = 1 }; var mask = new Mask("[{track}]. {artist} - {title} {year} live in Russia"); _testTager.Load("oldfilename"); _testTager.ChangeTags(tags); _testTager.ChangeName(mask); }
public void ValidateNameTest() { var tags = new Mp3Tags() { Album = "Album", Artist = "Artist", Comment = "Artist2 cover", Genre = "Genre", Title = "Title", Year = 2015, Track = 1 }; var mask = new Mask("[{track}]. {artist} - {title} {comment} {year} live in Russia"); _testTager.Load("[1]. Artist - Title Artist2 cover 2015 live in Russia"); _testTager.ChangeTags(tags); Assert.AreEqual(true, _testTager.ValidateFileName(mask)); }
public void GetTest() { var tags = new Mp3Tags() { Album = "Album", Artist = "Artist", Comment = "Comment", Genre = "Genre", Title = "Title", Year = 2015 }; Assert.AreEqual(tags.Artist, tags.GetTag("artist")); Assert.AreEqual(tags.Album, tags.GetTag("album")); Assert.AreEqual(tags.Comment, tags.GetTag("comment")); Assert.AreEqual(tags.Genre, tags.GetTag("genRe")); Assert.AreEqual(tags.Title, tags.GetTag("title")); Assert.AreEqual(tags.Year, uint.Parse(tags.GetTag("year"))); tags.GetTag("asrtist"); }
public Mp3Tags GetTags() { var tags = new Mp3Tags { Album = _file.Tag.Album, Artist = _file.Tag.FirstArtist, Comment = _file.Tag.Comment, Genre = _file.Tag.FirstGenre, Title = _file.Tag.Title, Year = _file.Tag.Year, Track = _file.Tag.Track }; return(tags); }
public bool Call(Mp3Tags tags, Tager tager) { _isCanceled = false; _file = tager.CurrentFile; try { _memento = _file.GetMemento(); tager.ChangeTags(tags); return(true); } catch { return(false); } }
public bool Call(Mp3Tags tags, Tager tager) { _isCanceled = false; _file = tager.CurrentFile; try { _memento = _file.GetMemento(); tager.ChangeTags(tags); return true; } catch { return false; } }
Mp3Tags GetTagsFromFileName(IMp3File file) { if (file == null) { throw new ArgumentException("File is not loaded"); } Menu.PrintHelp(); var fileName = file.Name; var mask = new Mask(Menu.GetUserInput("mask:")); var tagValues = Select(mask.GetTagValuesFromString(fileName)); var result = new Mp3Tags(); foreach (var tagValue in tagValues) { result.SetTag(tagValue.Key, tagValue.Value); } return(result); }
public void SetTags(Mp3Tags tags) { OldTags = GetTags(); //[TODO] extract string constants if (!string.IsNullOrEmpty(tags.Album)) { _file.Tag.Album = tags.Album; } if (tags.Year != 0) { _file.Tag.Year = tags.Year; } if (tags.Track != 0) { _file.Tag.Track = tags.Track; } if (!string.IsNullOrEmpty(tags.Comment)) { _file.Tag.Comment = tags.Comment; } if (!string.IsNullOrEmpty(tags.Title)) { _file.Tag.Title = tags.Title; } if (!string.IsNullOrEmpty(tags.Artist)) { _file.Tag.Artists = new[] { tags.Artist } } ; if (!string.IsNullOrEmpty(tags.Genre)) { _file.Tag.Genres = new[] { tags.Genre } } ; TagChanged = true; }
public FakeMp3File(Mp3Tags tags, string path) { Tags = tags; FullName = path; }
public void SetTags(Mp3Tags tags) { Tags = tags; }