public AlbumRatings AlbumRatings(int takeAmount)
        {
            var albums = _albumRepository.Get();

            var query = new TopRatedAlbumsQuery(albums, takeAmount);

            return(new AlbumRatings
            {
                TopAllTimeRatedAlbums = query.AllTime(),
                TopDailyRatedAlbums = query.Daily(),
                TopWeeklyRatedAlbums = query.Weekly(),
                TopMonthlyRatedAlbums = query.Monthly()
            });
        }
Exemplo n.º 2
0
        public void Daily_Empty_ReturnsAlbumsRatedThatDay()
        {
            _albums = new List <Album>
            {
                new Album
                {
                    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
                                }
                            }
                        }
                    }
                },
                new Album
                {
                    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 = new DateTime(1999, 1, 1)
                                }
                            }
                        }
                    }
                }
            };

            _query = new TopRatedAlbumsQuery(_albums, 3);

            var result = _query.Daily();

            const int expected = 1;

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