예제 #1
0
        public async void GetArticleDetails_ValidArticleWithRanking_Success()
        {
            var result = await ariclesController.SaveArticle(validArticleRequest);

            var okResult          = result.Should().BeOfType <OkObjectResult>().Subject;
            var articleIdResponse = okResult.Value.Should().BeAssignableTo <ArticleId>().Subject;

            var rankRequest = new ArticleRankingRequest()
            {
                ArticleId = articleIdResponse.Id, Rank = Models.Enums.RankEnum.Like
            };

            result = await ariclesController.RankArticle(rankRequest);

            okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var articleRankingResponse = okResult.Value.Should().BeAssignableTo <ArticleRankingDetails>().Subject;

            articleRankingResponse.DidILike.Should().Be(true);
            articleRankingResponse.DidIDislike.Should().Be(false);
            articleRankingResponse.DidIFavor.Should().Be(false);
            articleRankingResponse.DislikesCount.Should().Be(0);
            articleRankingResponse.LikesCount.Should().Be(1);

            result = await ariclesController.GetArticleDetails(articleIdResponse.Id);

            result.Should().BeOfType <OkObjectResult>();
            okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var articleDetailsResponse = okResult.Value.Should().BeAssignableTo <ArticleDetails>().Subject;

            articleDetailsResponse.Should().NotBeNull();
            articleDetailsResponse.Title.Should().Be(validArticleRequest.Title);
            articleDetailsResponse.Abstract.Should().Be(validArticleRequest.Abstract);
            articleDetailsResponse.Content.Should().Be(validArticleRequest.Content);
            articleDetailsResponse.Author.Id.Should().Be(currentUserId);
            articleDetailsResponse.IsPrivate.Should().Be(false);
            articleDetailsResponse.IsApproved.Should().Be(false);
            //articleDetailsResponse.Categories.Should().Be(validArticleRequest.Categories.Count);
            articleDetailsResponse.Content.Should().Be(validArticleRequest.Content);
            articleDetailsResponse.UpdatedOn.Should().BeCloseTo(DateTime.UtcNow, TWO_SECONDS_IN_MILLIONSECONDS);
            articleDetailsResponse.CreatedOn.Should().BeCloseTo(DateTime.UtcNow, TWO_SECONDS_IN_MILLIONSECONDS);
        }