public async Task GetReviewSummary_Returns_Empty_Summary_When_No_Reviews_Exist() { const int productId = 290; var product = _fixture.Create <Product>(); var expectedReview = new ProductReviewSummary(productId, 0, 0); _productRepositoryMock .Setup(x => x.GetProduct(productId)) .ReturnsAsync(product); _reviewRepositoryMock .Setup(x => x.GetReviews(productId)) .ReturnsAsync(Enumerable.Empty <ProductReview>()); var reviewSummary = await _reviewManager.ProductReviewSummary(productId); Assert.Equal(expectedReview, reviewSummary); }
public async Task GetReviewSummary_Returns_Calculated_Summary() { const int productId = 33; var product = _fixture.Create <Product>(); var expectedReview = new ProductReviewSummary(productId, 3.0m, 0.5m); _productRepositoryMock .Setup(x => x.GetProduct(productId)) .ReturnsAsync(product); _reviewRepositoryMock.Setup(x => x.GetReviews(productId)) .ReturnsAsync(new List <ProductReview> { new ProductReview(productId, 4, "product", "comment", true), new ProductReview(productId, 2, "another product", "another comment", false), }); var reviewSummary = await _reviewManager.ProductReviewSummary(productId); Assert.Equal(expectedReview, reviewSummary); }