Ejemplo n.º 1
0
        public IActionResult NewReview(int MovieId, string Title)
        {
            List <Review>   reviews   = _context.GetReviews(MovieId);
            ReviewViewModel ViewModel = new ReviewViewModel
            {
                Reviews           = reviews,
                MovieId           = MovieId,
                MovieTitle        = Title,
                AverageRating     = _context.AverageRating(reviews),
                RatingPercentages = _context.GetRatingPercentages(reviews)
            };

            return(View(ViewModel));
        }
Ejemplo n.º 2
0
        public void TestRatingAverages()
        {
            List <Review> Reviews = new List <Review>
            {
                new Review(DateTime.Now, "Great Movie", "Simon", 4),
                new Review(DateTime.Now, "Excellent", "Henk", 5),
                new Review(DateTime.Now, "Superb", "Pieter", 5)
            };
            List <double> averages = logic.GetRatingPercentages(Reviews);

            //Method will always make 5 averages for all 5 StarRating possibilities
            Assert.Equal(5, averages.Count);
            //averages list should have one item with 33% and one with 67%
            Assert.True(averages.IndexOf(33) != 0 && averages.IndexOf(100 - 33) != 0);
        }