Exemplo n.º 1
0
        public async Task <IActionResult> Details(int id)
        {
            bool isReviewExistingById = await this.reviewService.IsReviewExistingById(id, false);

            if (!isReviewExistingById)
            {
                TempData.AddErrorMessage(string.Format(EntityNotFound, ReviewEntity));

                return(this.RedirectToHomeIndex());
            }

            ReviewDetailsServiceModel model = await this.reviewService.GetDetailsByIdAsync(id);

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task GetDetailsByIdAsync_WithReviewId_ShouldReturnValidServiceModel()
        {
            // Arrange
            FitStoreDbContext database = this.Database;

            DatabaseHelper.SeedData(database);

            IReviewService reviewService = new ReviewService(database);

            // Act
            ReviewDetailsServiceModel result = await reviewService.GetDetailsByIdAsync(reviewId);

            // Assert
            result.Id.Should().Be(1);
            result.Content.Should().Be("Content 1");
            result.Author.Should().Be("User_1");
            result.SupplementId.Should().Be(1);
            result.SupplementName.Should().Be("Supplement 1");
            result.ManufacturerId.Should().Be(1);
            result.ManufacturerName.Should().Be("Manufacturer 1");
            result.Rating.Should().Be(1);
            result.IsDeleted.Should().Be(false);
        }