public ArtistRatings ArtistRatings(int takeAmount)
        {
            var artists = _artistRepository.Get();

            var query = new TopRatedArtistsQuery(artists, takeAmount);

            return(new ArtistRatings
            {
                TopAllTimedRatedArtists = query.AllTime(),
                TopDailyRatedArtists = query.Daily(),
                TopWeeklyRatedArtists = query.Weekly(),
                TopMonthlyRatedArtists = query.Monthly()
            });
        }
Beispiel #2
0
        public void AllTime_NoParameter_ReturnsTakeAmount()
        {
            _artists = new List <Artist>
            {
                new Artist
                {
                    Name  = "The Doors",
                    Songs = new List <Song>
                    {
                        new Song
                        {
                            AverageRating = 2.0,
                            Ratings       = new List <Rating>
                            {
                                new Rating
                                {
                                    RatedOn = DateTime.Today
                                }
                            }
                        },
                        new Song
                        {
                            AverageRating = 4.0,
                            Ratings       = new List <Rating>
                            {
                                new Rating
                                {
                                    RatedOn = DateTime.Today
                                }
                            }
                        },
                        new Song
                        {
                            AverageRating = 1.0,
                            Ratings       = new List <Rating>
                            {
                                new Rating
                                {
                                    RatedOn = DateTime.Today
                                }
                            }
                        },
                    },
                    Genres = new List <Genre>
                    {
                        new Genre
                        {
                            Name = "Classic Rock"
                        },
                        new Genre
                        {
                            Name = "Psychadelic Rock"
                        },
                        new Genre
                        {
                            Name = "Alternative Rock"
                        }
                    }
                },
                new Artist
                {
                    Name  = "Van Halen",
                    Songs = new List <Song>
                    {
                        new Song
                        {
                            AverageRating = 1.0,
                            Ratings       = new List <Rating>
                            {
                                new Rating
                                {
                                    RatedOn = DateTime.Today
                                }
                            }
                        },
                        new Song
                        {
                            AverageRating = 2.0,
                            Ratings       = new List <Rating>
                            {
                                new Rating
                                {
                                    RatedOn = DateTime.Today
                                }
                            }
                        },
                        new Song
                        {
                            AverageRating = 3.0,
                            Ratings       = new List <Rating>
                            {
                                new Rating
                                {
                                    RatedOn = DateTime.Today
                                }
                            }
                        },
                    },
                    Genres = new List <Genre>
                    {
                        new Genre
                        {
                            Name = "Classic Rock"
                        },
                        new Genre
                        {
                            Name = "80s Rock"
                        },
                        new Genre
                        {
                            Name = "Glam Rock"
                        }
                    }
                }
            };

            _query = new TopRatedArtistsQuery(_artists, 1);

            var result = _query.AllTime();

            const int expected = 1;

            Assert.AreEqual(expected, result.Count);
        }