Пример #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());
        }
Пример #2
0
        public void Weekly_Empty_ReturnsGenresRatedInLastWeek()
        {
            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 = DateTime.Today - TimeSpan.FromDays(8)
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            _query = new TopRatedGenreQuery(genres, 3);

            var results = _query.Weekly();

            const int expected = 1;

            Assert.AreEqual(expected, results.Count);
        }
Пример #3
0
        public void AllTime_Empty_ReturnsAllRatedGenres()
        {
            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 = DateTime.Today - TimeSpan.FromDays(1)
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            _query = new TopRatedGenreQuery(genres, 3);

            var results = _query.AllTime();

            const int expected = 2;

            Assert.AreEqual(expected, results.Count);
        }
Пример #4
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()
            });
        }
Пример #6
0
        public void Queries_Empty_ReturnsTakeAmount()
        {
            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, 1);

            var result = _query.AllTime();

            const int expected = 1;

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