示例#1
0
        public async Task Post_User_Rating_With_Created_Response()
        {
            // Arrange
            const int articleId      = 1;
            var       mockUserRating = new UserRating();

            _articleRepository.Setup(x => x.ExistsAsync(It.IsAny <int>())).ReturnsAsync(true);
            _articleRepository.Setup(x => x.AddUserRatingAsync(It.IsAny <int>(), It.IsAny <UserRating>()))
            .Returns(Task.FromResult(mockUserRating));

            // Act
            var articlesController = new ArticlesController(_articleRepository.Object);
            var actionResult       = await articlesController.PostArticleUserRatingAsync(articleId, mockUserRating);

            // Assert
            Assert.IsType <CreatedAtActionResult>(actionResult);
        }