public void Given_an_empty_rating_list_when_calculating_average_rating_then_0_is_returned()
        {
            // Arrange
            var emptyPageRatingList = new List<PageRating>();
            var ratingCalculator = new RatingCalculator();

            // Act
            var averageRating = ratingCalculator.CalculateAverageRating(emptyPageRatingList);

            // Assert
            Assert.That(averageRating, Is.EqualTo(0));
        }
        public void Given_a_list_with_multiple_ratings_when_calculating_average_rating_then_the_average_rating_is_returned()
        {
            // Arrange
            const int rating1 = 1;
            const int rating2 = 2;
            const double expectedAverageRating = 1.5;

            var pageRatingList = new List<PageRating>();
            pageRatingList.Add(new PageRating { Rating = rating1 });
            pageRatingList.Add(new PageRating { Rating = rating2 });

            var ratingCalculator = new RatingCalculator();

            // Act
            var averageRating = ratingCalculator.CalculateAverageRating(pageRatingList);

            // Assert
            Assert.That(averageRating, Is.EqualTo(expectedAverageRating));
        }
 public DynamicDataStoreRatingRepository(RatingCalculator ratingCalculator, DynamicDataStoreFactory dynamicDataStoreFactory)
 {
     this.ratingCalculator = ratingCalculator;
     this.ratingStore = dynamicDataStoreFactory.GetStore(typeof(PageRating));
 }
 public PageObjectRatingRepository(RatingCalculator ratingCalculator, PageObjectManagerFactory pageObjectManagerFactory, DynamicDataStoreFactory dynamicDataStoreFactory)
 {
     this.ratingCalculator = ratingCalculator;
     this.pageObjectManagerFactory = pageObjectManagerFactory;
     this.ratingStore = dynamicDataStoreFactory.GetStore(typeof(PageRating));
 }