Exemple #1
0
        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),
            });
        }
Exemple #2
0
        public void Should_Calculate_Average_Description_Length()
        {
            var reviews = new List <Review>
            {
                new Review {
                    Content = "TEST CONTENT"
                },
                new Review {
                    Content = "EXAMPLE CONTENT1"
                }
            };
            var average = _userStatisticProvider.CalculateAverageReviewLength(reviews);

            Assert.AreEqual(14, average);
        }