Example #1
0
        public void Queries_Empty_ReturnsGenresBySongRatingDescending()
        {
            var firstGenre = new Genre
            {
                Artists = new List <Artist>
                {
                    new Artist
                    {
                        Songs = new List <Song>
                        {
                            new Song
                            {
                                AverageRating = 5.0,
                                Ratings       = new List <Rating>
                                {
                                    new Rating
                                    {
                                        RatedOn = DateTime.Today
                                    }
                                }
                            }
                        }
                    }
                }
            };
            var secondGenre = new Genre
            {
                Artists = new List <Artist>
                {
                    new Artist
                    {
                        Songs = new List <Song>
                        {
                            new Song
                            {
                                AverageRating = 3.0,
                                Ratings       = new List <Rating>
                                {
                                    new Rating
                                    {
                                        RatedOn = DateTime.Today
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var genres = new List <Genre> {
                firstGenre, secondGenre
            };

            _query = new TopRatedGenreQuery(genres, 3);

            var result = _query.Monthly();

            Assert.AreEqual(firstGenre, result.FirstOrDefault());
        }
Example #2
0
        public void Monthly_Empty_ReturnsGenresRatedInLastMonth()
        {
            var genres = new List <Genre>
            {
                new Genre
                {
                    Artists = new List <Artist>
                    {
                        new Artist
                        {
                            Songs = new List <Song>
                            {
                                new Song
                                {
                                    Ratings = new List <Rating>
                                    {
                                        new Rating
                                        {
                                            RatedOn = DateTime.Today
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                new Genre
                {
                    Artists = new List <Artist>
                    {
                        new Artist
                        {
                            Songs = new List <Song>
                            {
                                new Song
                                {
                                    Ratings = new List <Rating>
                                    {
                                        new Rating
                                        {
                                            RatedOn = new DateTime(2000, 1, 1)
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            _query = new TopRatedGenreQuery(genres, 3);

            var results = _query.Monthly();

            const int expected = 1;

            Assert.AreEqual(expected, results.Count);
        }
        public GenreRatings GenreRatings(int takeAmount)
        {
            var albums = _genreRepository.Get();

            var query = new TopRatedGenreQuery(albums, takeAmount);

            return(new GenreRatings
            {
                TopAllTimeRatedGenres = query.AllTime(),
                TopDailyRatedGenres = query.Daily(),
                TopWeeklyRatedGenres = query.Weekly(),
                TopMonthlyRatedGenres = query.Monthly()
            });
        }