public void Should_Calculate_Average_Rating_Of_Reviews() { var reviews = new List <Review> { new Review { Rating = Rating.Five }, new Review { Rating = Rating.Seven }, new Review { Rating = Rating.Two }, new Review { Rating = Rating.Ten } }; var average = _userStatisticProvider.CalculateAverageRating(reviews); Assert.AreEqual(6, average); }
public UserStatisticsDto GetForUserStatistics(int userId) { _userRepository.FindById(userId); var reviews = _reviewRepository.GetReviews().Where(e => e.UserId == userId).ToList(); var escapeRooms = _escapeRoomRepository.GetEscapeRooms().ToList(); return(new UserStatisticsDto { AverageRating = _userStatisticProvider.CalculateAverageRating(reviews), AverageReviewLength = _userStatisticProvider.CalculateAverageReviewLength(reviews), ReviewsNumber = reviews.Count, FavoriteEscapeRoomType = _userStatisticProvider.FindFavoriteEscapeRoom(reviews, escapeRooms), }); }