Exemplo n.º 1
0
 public void YearSetTest()
 {
     Mp3Tags tags = new Mp3Tags();
     tags.SetTag("year", "2015");
     Assert.AreEqual(2015u, tags.Year);
     tags.SetTag("year", "two thousand fifteen");
 }
Exemplo n.º 2
0
 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");
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void ChangeTags(Mp3Tags tags)
        {
            if (_currentFile == null)
                throw new NullReferenceException("File is not loaded");

            if (tags == null)
                throw new ArgumentException("Incorrect tags");
            _currentFile.SetTags(tags);
        }
Exemplo n.º 5
0
        internal Mp3Tags GetTagsFromName(Mask mask)
        {
            var tags         = new Mp3Tags();
            var tagsFromName = mask.GetTagValuesFromString(CurrentFile.Name);

            foreach (var tag in tagsFromName.First())
            {
                tags.SetTag(tag.Key, tag.Value);
            }
            return(tags);
        }
Exemplo n.º 6
0
 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");
 }
Exemplo n.º 7
0
        public void ChangeTags(Mp3Tags tags)
        {
            if (_currentFile == null)
            {
                throw new NullReferenceException("File is not loaded");
            }

            if (tags == null)
            {
                throw new ArgumentException("Incorrect tags");
            }
            _currentFile.SetTags(tags);
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 internal Mp3Tags GetTagsFromName(Mask mask)
 {
     var tags = new Mp3Tags();
     var tagsFromName = mask.GetTagValuesFromString(CurrentFile.Name);
     foreach (var tag in tagsFromName.First())
     {
         tags.SetTag(tag.Key, tag.Value);
     }
     return tags;
 }
Exemplo n.º 12
0
 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 };
 }
Exemplo n.º 13
0
        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));
        }
Exemplo n.º 14
0
 public void SetTags(Mp3Tags tags)
 {
     Tags = tags;
 }