示例#1
0
        public async void PublishArticleInvalidIdTest()
        {
            var controller = new ArticlesController(_context, _userManager);

            var result = await controller.PostPublishArticle(40);

            Assert.IsType <NotFoundResult>(result);

            var result2 = await controller.PostPublishArticle(-1);

            Assert.IsType <BadRequestResult>(result2);
        }
示例#2
0
        public async void PublishArticleAlreadyPublishedTest()
        {
            var controller = new ArticlesController(_context, _userManager);

            var article = _articleDTOs.First(a => a.IsPublished == true);

            Assert.True(article.IsPublished == true);
            Assert.True(article.PublishedAt != null);

            //POST TEST (Lead empty)
            var result = await controller.PostPublishArticle(article.Id);

            var objectResult = Assert.IsType <OkResult>(result);

            //GET TEST (Article published)
            var result2 = await controller.GetArticle(article.Id);

            var objectResult2 = Assert.IsType <OkObjectResult>(result2);
            var model         = Assert.IsAssignableFrom <ArticleDTO>(objectResult2.Value);

            Assert.True(model.IsPublished == true);
            Assert.True(model.PublishedAt != null);
        }