Example #1
0
        public void MultipleYearsTagsPresent_FirstAppliedToAlbum()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Year",
                Value = "1999"
            });
            tags.Add(new FileTag()
            {
                Key   = "Year",
                Value = "2001"
            });

            accumulator.AccumulateTags(tags);
            var result = accumulator.GetAccumulatedResult();
            var album  = result.SingleOrDefault().Albums.SingleOrDefault();

            Assert.IsNotNull(album);
            Assert.AreEqual(1999, album.Year.Year);
        }
Example #2
0
        public void AlbumSingleGenreAttached_Success()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Genre",
                Value = "Genre1"
            });

            accumulator.AccumulateTags(tags);
            var result = accumulator.GetAccumulatedResult();
            var album  = result.SingleOrDefault().Albums.SingleOrDefault();

            Assert.NotNull(album);
            Assert.NotNull(album.Genres);
            Assert.AreEqual(1, album.Genres.Count);
            Assert.AreEqual("Genre1", album.Genres.SingleOrDefault().Name);
        }
Example #3
0
        public void AccumulateMultiArtistNonTrimmed_ReturnsMultipleArtists()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1, Artist2 ",
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1",
            });

            accumulator.AccumulateTags(tags);

            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(2, result.Count());

            var firstArtist = result.FirstOrDefault();

            Assert.NotNull(firstArtist);
            Assert.AreEqual("Artist1", firstArtist.Name);

            var secondArtist = result.LastOrDefault();

            Assert.NotNull(secondArtist);
            Assert.AreEqual("Artist2", secondArtist.Name);
        }
Example #4
0
        public void MultiArtistAlbum_ArtistsAreAttachedToAlbum()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1,Artist2"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album2"
            });

            accumulator.AccumulateTags(tags);

            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(2, result.Count());

            var artist1 = result.Where(a => a.Name == "Artist1").FirstOrDefault();
            var artist2 = result.Where(a => a.Name == "Artist2").FirstOrDefault();

            Assert.AreEqual(2, artist1.Albums.Count);
            Assert.AreEqual(2, artist2.Albums.Count);

            Assert.AreNotSame(artist1.Albums[0], artist1.Albums[1]);
            Assert.AreNotSame(artist2.Albums[0], artist2.Albums[1]);

            //first artist albums test
            var firstAlbum   = artist1.Albums.Where(a => a.Name == "Album1").FirstOrDefault();
            var secondtAlbum = artist1.Albums.Where(a => a.Name == "Album2").FirstOrDefault();

            Assert.NotNull(firstAlbum);
            Assert.NotNull(secondtAlbum);
            Assert.AreEqual(2, firstAlbum.Artists.Count);
            Assert.AreEqual(2, secondtAlbum.Artists.Count);
            Assert.True(firstAlbum.Artists.Contains(artist1) && firstAlbum.Artists.Contains(artist2));
            Assert.True(secondtAlbum.Artists.Contains(artist1) && secondtAlbum.Artists.Contains(artist2));

            //second artists albums test
            firstAlbum   = artist2.Albums.Where(a => a.Name == "Album1").FirstOrDefault();
            secondtAlbum = artist2.Albums.Where(a => a.Name == "Album2").FirstOrDefault();
            Assert.NotNull(firstAlbum);
            Assert.NotNull(secondtAlbum);
            Assert.AreEqual(2, firstAlbum.Artists.Count);
            Assert.AreEqual(2, secondtAlbum.Artists.Count);
            Assert.True(firstAlbum.Artists.Contains(artist1) && firstAlbum.Artists.Contains(artist2));
            Assert.True(secondtAlbum.Artists.Contains(artist1) && secondtAlbum.Artists.Contains(artist2));
        }
Example #5
0
        public void AccumulateMissingAlbum_ReturnsArtistOnly()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1"
            });

            accumulator.AccumulateTags(tags);

            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(1, result.Count());

            var artist = result.SingleOrDefault();

            Assert.NotNull(artist);
            Assert.AreEqual("Artist1", artist.Name);

            Assert.NotNull(artist.Albums);
            Assert.AreEqual(0, artist.Albums.Count);
        }
Example #6
0
        public void AccumulateMultipleAlbumsForOneArtist_ReturnsTwoAlbums()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1",
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1",
            });
            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1",
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album2",
            });

            accumulator.AccumulateTags(tags);

            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(1, result.Count());

            var artist = result.SingleOrDefault();

            Assert.NotNull(artist);
            Assert.AreEqual("Artist1", artist.Name);

            Assert.NotNull(artist.Albums);
            Assert.AreEqual(2, artist.Albums.Count);
            Assert.AreEqual("Album1", artist.Albums[0].Name);
            Assert.AreEqual("Album2", artist.Albums[1].Name);
        }
Example #7
0
        public void AccumulateDuplicateArtistsTwoAlbums_ReturnsTwoAlbums()
        {
            var accumulator = CreateAccumulator();

            var tags1 = new FileTagCollection();

            tags1.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1",
            });
            tags1.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1",
            });

            var tags2 = new FileTagCollection();

            tags2.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1",
            });
            tags2.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album2",
            });

            accumulator.AccumulateTags(tags1);
            accumulator.AccumulateTags(tags2);

            var result = accumulator.GetAccumulatedResult();
            var artist = result.SingleOrDefault();

            Assert.NotNull(artist.Albums);
            Assert.AreEqual(2, artist.Albums.Count);
            Assert.AreEqual("Album1", artist.Albums[0].Name);
            Assert.AreEqual("Album2", artist.Albums[1].Name);
        }
Example #8
0
        public void AlbumMultipleGenresAttached_Success()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Genre",
                Value = "Genre1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Genre",
                Value = "Genre2"
            });

            accumulator.AccumulateTags(tags);
            var result = accumulator.GetAccumulatedResult();
            var album  = result.SingleOrDefault().Albums.SingleOrDefault();

            Assert.NotNull(album);
            Assert.NotNull(album.Genres);
            Assert.AreEqual(2, album.Genres.Count);

            var firstGenre  = album.Genres.Where(g => g.Name == "Genre1").FirstOrDefault();
            var secondGenre = album.Genres.Where(g => g.Name == "Genre2").FirstOrDefault();

            Assert.NotNull(firstGenre);
            Assert.NotNull(secondGenre);
        }
Example #9
0
        public void SingleArtistAlbum_ArtistsAreAttachedToAlbum()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album2"
            });

            accumulator.AccumulateTags(tags);

            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(1, result.Count());

            var artist      = result.SingleOrDefault();
            var firstAlbum  = artist.Albums.Where(a => a.Name == "Album1").FirstOrDefault();
            var secondAlbum = artist.Albums.Where(a => a.Name == "Album2").FirstOrDefault();

            Assert.NotNull(firstAlbum);
            Assert.NotNull(secondAlbum);
            Assert.AreEqual(1, firstAlbum.Artists.Count);
            Assert.AreEqual(1, secondAlbum.Artists.Count);
            Assert.AreSame(artist, firstAlbum.Artists[0]);
            Assert.AreSame(artist, secondAlbum.Artists[0]);
        }
Example #10
0
        public void AccumulateMultipleArtists_OneAlbum_ArtistsAreAddedToAlbum()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1, Artist2",
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1",
            });

            accumulator.AccumulateTags(tags);

            var result       = accumulator.GetAccumulatedResult();
            var firstArtist  = result.FirstOrDefault();
            var secondArtist = result.LastOrDefault();

            var firstAlbums  = firstArtist.Albums;
            var secondAlbums = secondArtist.Albums;

            Assert.NotNull(firstAlbums);
            Assert.NotNull(secondAlbums);
            Assert.AreEqual(1, firstAlbums.Count);
            Assert.AreEqual(firstAlbums.Count, secondAlbums.Count);

            var album = firstAlbums[0];

            Assert.NotNull(album);
            Assert.AreSame(firstAlbums[0], secondAlbums[0]);

            Assert.AreEqual(2, album.Artists.Count);
        }
        public FileTagCollection GetTags(string filePath)
        {
            FileTagCollection result = new FileTagCollection();

            FlacParser parser         = new FlacParser();
            var        vorbisComments = parser.ReadVorbisComments(filePath);

            foreach (var c in vorbisComments)
            {
                result.Add(new FileTag()
                {
                    Key   = c.Key,
                    Value = c.Value
                });
            }

            return(result);
        }
Example #12
0
        public void AccumulateMultipleArtistsOneRun_ReturnsAll()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist2"
            });
            tags.Add(new FileTag()
            {
                Key   = "Artist",
                Value = "Artist3"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album2"
            });
            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album3"
            });

            accumulator.AccumulateTags(tags);
            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(3, result.Count());

            var firstArtist  = result.Where(a => a.Name == "Artist1");
            var secondArtist = result.Where(a => a.Name == "Artist2");
            var thirdArtist  = result.Where(a => a.Name == "Artist2");

            Assert.NotNull(firstArtist);
            Assert.NotNull(secondArtist);
            Assert.NotNull(thirdArtist);
        }
Example #13
0
        public void AccumulateMissingArtist_ReturnsEmptyResult()
        {
            var accumulator = CreateAccumulator();

            var tags = new FileTagCollection();

            tags.Add(new FileTag()
            {
                Key   = "Album",
                Value = "Album1"
            });

            accumulator.AccumulateTags(tags);

            var result = accumulator.GetAccumulatedResult();

            Assert.NotNull(result);
            Assert.AreEqual(0, result.Count());
        }