public async Task <IActionResult> Index(int page = 1) { var reviewsToShow = await this.reviews.All(ReviewsMinRatingToPublish, page, ReviewsPerPage); var model = new ReviewListingViewModel { Reviews = reviewsToShow, Navigation = new NavigationViewModel { TotalCount = await this.reviews.TotalCount(ReviewsMinRatingToPublish), PerPage = ReviewsPerPage, CurrentPage = page } }; return(View(model)); }
public async Task CheckIfGetReviewByIdWorksCorrectly() { this.SeedDatabase(); var expectedModel = new ReviewListingViewModel { Id = this.firstReview.Id, RecipeId = this.firstRecipe.Id, Title = this.firstReview.Title, Description = this.firstReview.Description, Rate = this.firstReview.Rate, UserUsername = this.firstCookingHubUser.UserName, }; var viewModel = await this.reviewService.GetViewModelByIdAsync <ReviewListingViewModel>(this.firstReview.Id); var expectedObj = JsonConvert.SerializeObject(expectedModel); var actualResultObj = JsonConvert.SerializeObject(viewModel); Assert.Equal(expectedObj, actualResultObj); }