public void Daily_Empty_ReturnsSongsRatedOnThatDay()
        {
            _songs = new List <Song>
            {
                new Song
                {
                    Ratings = new List <Rating>
                    {
                        new Rating {
                            RatedOn = DateTime.Today
                        }
                    }
                },
                new Song
                {
                    Ratings = new List <Rating>
                    {
                        new Rating {
                            RatedOn = new DateTime(2000, 1, 1)
                        }
                    }
                }
            };

            _query = new TopRatedSongsQuery(_songs, 3);

            var result = _query.Daily();

            const int expected = 1;

            Assert.AreEqual(expected, result.Count);
        }
        public SongRatings SongRatings(int takeAmount)
        {
            var songs = _songRepository.Get();

            var query = new TopRatedSongsQuery(songs, takeAmount);

            return(new SongRatings
            {
                TopAllTimeRatedSongs = query.AllTime(),
                TopDailyRatedSongs = query.Daily(),
                TopWeeklyRatedSongs = query.Weekly(),
                TopMonthlyRatedSongs = query.Monthly()
            });
        }
        public void Monthly_NoParameter_ReturnsTakeAmount()
        {
            _songs = new List <Song>
            {
                new Song
                {
                    AverageRating = 1.0,
                    Ratings       = new List <Rating>
                    {
                        new Rating
                        {
                            RatedOn = DateTime.Today
                        }
                    }
                },
                new Song
                {
                    AverageRating = 3.0,
                    Ratings       = new List <Rating>
                    {
                        new Rating
                        {
                            RatedOn = DateTime.Today
                        }
                    }
                }
            };

            _query = new TopRatedSongsQuery(_songs, 1);

            var result = _query.Monthly();

            const int expected = 1;

            Assert.AreEqual(expected, result.Count);
        }
        public void AllTime_NoParameter_ReturnsSongsByRatingDescending()
        {
            _songs = new List <Song>
            {
                new Song
                {
                    AverageRating = 1.0,
                    Ratings       = new List <Rating>
                    {
                        new Rating
                        {
                            RatedOn = DateTime.Today
                        }
                    }
                },
                new Song
                {
                    AverageRating = 3.0,
                    Ratings       = new List <Rating>
                    {
                        new Rating
                        {
                            RatedOn = DateTime.Today
                        }
                    }
                }
            };

            _query = new TopRatedSongsQuery(_songs, 3);

            var result = _query.AllTime();

            const double expected = 3.0;

            Assert.AreEqual(expected, result.First().AverageRating);
        }
        public void Weekly_NoParameter_ReturnsSongsRatedInLastWeek()
        {
            _songs = new List <Song>
            {
                new Song
                {
                    AverageRating = 1.0,
                    Ratings       = new List <Rating>
                    {
                        new Rating
                        {
                            RatedOn = new DateTime(2000, 1, 1)
                        }
                    }
                },
                new Song
                {
                    AverageRating = 3.0,
                    Ratings       = new List <Rating>
                    {
                        new Rating
                        {
                            RatedOn = DateTime.Today
                        }
                    }
                }
            };

            _query = new TopRatedSongsQuery(_songs, 3);

            var result = _query.Weekly();

            const int expected = 1;

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