コード例 #1
0
        public async void GetWriteComment()// System.NotSupportedException
        {
            var result = await controller.GetAll();

            var viewResult = Assert.IsType <ActionResult <List <Article> > >(result);
            var articleV   = Assert.IsType <OkObjectResult>(viewResult.Result);
            var model      = Assert.IsAssignableFrom <IEnumerable <Article> >(articleV.Value);

            Assert.Equal(2, model.Count());
            var commentText = "Comment";

            foreach (var article in model)
            {
                var commentPage = await controller.AddComment(commentText, article.Id);

                var commentView  = Assert.IsType <ActionResult <Comment> >(commentPage);
                var commentV2    = Assert.IsType <OkObjectResult>(commentView.Result);
                var commentModel = Assert.IsAssignableFrom <Comment>(commentV2.Value);

                Assert.NotNull(commentModel);
                Assert.Equal(commentModel.Text, commentText);
                Assert.Equal(commentModel.ArticleId, article.Id);
                Assert.NotNull(commentModel.UserCreate);
            }
        }