Ejemplo n.º 1
0
        public void ShouldIdentify()
        {
            var tagInfoWithTitleAndArtist = new TagInfo { Artist = "artist", Title = "title" };
            var tagInfoWithISRC = new TagInfo { ISRC = "ISRC" };

            Assert.IsTrue(tagInfoWithISRC.IsTrackUniquelyIdentifiable());
            Assert.IsTrue(tagInfoWithTitleAndArtist.IsTrackUniquelyIdentifiable());
        }
Ejemplo n.º 2
0
        public void ShouldNotIdentify()
        {
            var tagInfoWithoutTitle = new TagInfo { Artist = "artist" };
            var tagInfoWithoutArtist = new TagInfo { Title = "title" };
            var tagInfoWithoutISRC = new TagInfo();

            Assert.IsFalse(tagInfoWithoutArtist.IsTrackUniquelyIdentifiable());
            Assert.IsFalse(tagInfoWithoutTitle.IsTrackUniquelyIdentifiable());
            Assert.IsFalse(tagInfoWithoutISRC.IsTrackUniquelyIdentifiable());
        }
Ejemplo n.º 3
0
 private string ToTrackString(TagInfo tag)
 {
     return string.Format("{0}-{1}", tag.Artist, tag.Title);
 }
Ejemplo n.º 4
0
 private object[] GetNotFoundLine(TagInfo tags)
 {
     return new object[] { ToTrackString(tags), "No match found!", false, 0, 0, 0, 0, 0 };
 }
Ejemplo n.º 5
0
 private TrackData GetActualTrack(TagInfo tags)
 {
     return !string.IsNullOrEmpty(tags.ISRC)
                ? modelService.ReadTrackByISRC(tags.ISRC)
                : modelService.ReadTrackByArtistAndTitleName(tags.Artist, tags.Title).FirstOrDefault();
 }
Ejemplo n.º 6
0
        private Album GetCoresspondingAlbum(TagInfo tags)
        {
            string album = tags.Album;
            Album albumToInsert = null;
            if (string.IsNullOrEmpty(album))
            {
                albumToInsert = unknownAlbum; // The album is unknown
            }
            else
            {
                lock (lockObject)
                {
                    albumToInsert = listOfAllAlbums.FirstOrDefault(a => a.Name == album);
                    if (albumToInsert == null)
                    {
                        // No such album in the database INSERT!
                        int releaseYear = -1;
                        try
                        {
                            releaseYear = Convert.ToInt32(tags.Year.Split('-')[0].Trim());
                        }
                        catch (Exception)
                        {
                            /*swallow*/
                            Debug.WriteLine("Release Year is in a bad format. Continuw processing...");
                        }

                        albumToInsert = new Album(0, album, releaseYear);
                        try
                        {
                            modelService.InsertAlbum(albumToInsert); // Insert new ALBUM
                        }
                        catch (Exception ex)
                        {
                            if (MessageBox.Show(ex.Message + "\n Continue?", Resources.ExceptioInDal, MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
                                == DialogResult.Cancel)
                            {
                                return null;
                            }

                            albumToInsert = unknownAlbum;
                        }

                        if (albumToInsert != unknownAlbum)
                        {
                            listOfAllAlbums.Add(albumToInsert); // Modify Local Variable
                        }
                    }
                }
            }

            return albumToInsert;
        }