Exemplo n.º 1
0
        public async void GetRanking_ValidArticleId_Success()
        {
            // Create article
            var result = await ariclesController.SaveArticle(validArticleRequest);

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

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

            result = await ariclesController.RankArticle(rankRequest);

            okResult = result.Should().BeOfType <OkObjectResult>().Subject;

            // Get article ranking
            result = await ariclesController.GetArticleRanking(articleIdResponse.Id);

            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);
        }