Ejemplo n.º 1
0
        public async Task Get_ReturnsReview_WhenReviewExistsInTheDatabase()
        {
            //Arrange
            var review         = FluentReview.Init.WithData(1, "Test Title", "Reviewer", "ReviewContent");
            var article        = FluentArticle.Init.WithData(1, "Test Title", "Author", "ArticleContent", DateTime.Now.Date, 5);
            var articleRequest = new CreateArticleCommand {
                ArticleContent = article.ArticleContent, Author = article.Author, PublishDate = article.PublishDate.ToString(), StarCount = article.StarCount, Title = article.Title
            };

            await CreateArticleAsync(articleRequest);

            var reviewRequest = new AddReviewCommand {
                ArticleId = article.ArticleId, ReviewContent = review.ReviewContent, Reviewer = review.Reviewer
            };

            await AddReviewAsync(reviewRequest);

            // Act
            var response = await TestClient.GetAsync("odata/reviews");

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);
            var createdReview = await response.Content.ReadAsAsync <OData <FluentReview> >();

            createdReview.Value.FirstOrDefault(c => c.ReviewContent == review.ReviewContent).Should().NotBeNull().And.BeEquivalentTo(review);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddReview([FromForm] AddReviewCommand command)
        {
            command.UserId = HttpContext.User.Identity.Name;
            await CommandAsync(command);

            return(Ok());
        }
        public static RecordingDataSet.Review AddReview(RecordingDataSet dataSet,
                                                        string name, string content, int rating, long recordingId)
        {
            AddReviewCommand command =
                new AddReviewCommand(dataSet, name, content, rating, recordingId);

            executor.Execute(command);

            return(command.Result);
        }
Ejemplo n.º 4
0
        public void AddReviewCommandValidationShouldReturnFalse()
        {
            var request = new AddReviewCommand();

            addReviewCommandValidator.Validate(request).IsValid.Should().BeFalse();
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <long> > AddReview([FromRoute] ReviewType reviewType, [FromBody] AddReviewCommand query)
        {
            query.ReviewType = reviewType;
            var result = await _mediator.Send(query);

            return(Ok(result));
        }
Ejemplo n.º 6
0
 protected async Task AddReviewAsync(AddReviewCommand request)
 {
     await TestClient.PostAsJsonAsync("api/reviews/add", request);
 }
Ejemplo n.º 7
0
 public async Task <int> AddReview(AddReviewCommand command)
 {
     return(await this._mediator.Send(command));
 }
Ejemplo n.º 8
0
        public async Task <ActionResult <Review> > Create([FromBody] AddReviewCommand request)
        {
            var article = await mediator.Send(request);

            return(Ok());
        }