public void UpdateArticleTest()
        {
            ArticleContext articles = new ArticleContext();
            Article        test     = new Article
            {
                ArticleId  = 33,
                Caption    = "TestCaption2Update",
                Text       = "Test text text test test",
                Date       = DateTime.Now,
                Language   = "Eng",
                Video      = "testlinkVideo",
                Image      = "testlinkImage",
                CategoryId = 1,
                User       = new User
                {
                    Name = "Boris"
                }
            };
            string oldName = articles.GetArticle(33).Caption;

            articles.UpdateArticle(test);
            string newName = articles.GetArticle(33).Caption;

            Assert.AreNotEqual(oldName, newName);
        }
 // GET: Article
 public ActionResult Full(int id)
 {
     using (var articleContext = new ArticleContext())
     {
         var article = articleContext.GetArticle(id);
         return(View(article));
     }
 }
Beispiel #3
0
        public async Task <ActionResult> EditArticle(string id)
        {
            Article article = await _articleContext.GetArticle(id);

            if (article == null)
            {
                return(NotFound());
            }
            return(View("Article/EditArticle", article));
        }
        public void DeleteArticleTest()
        {
            ArticleContext articles      = new ArticleContext();
            int            countArticles = articles.GetCountArticles(null);

            articles.DeleteArticle(33);
            int countafteDelete = articles.GetCountArticles(null);

            Assert.AreNotEqual(countArticles, countafteDelete);
            Assert.IsNull(articles.GetArticle(33));
        }
        public void GetArticleTest()
        {
            ArticleContext articles = new ArticleContext();

            var article = articles.GetArticle(1);
            var noart   = articles.GetArticle(12332);

            Assert.AreEqual(article.ArticleId, 1);
            Assert.AreEqual(article.Language, "Eng");
            Assert.AreEqual(article.User.Name, "Boris");
            Assert.AreEqual(article.CategoryId, 3);
            Assert.AreEqual(article.Caption, "Google finally cleans up its Esta ads after eight years");
            Assert.AreEqual(article.Date.ToString("yy-MM-dd"), "18-11-11");
            Assert.AreEqual(article.Video, @"https://www.youtube.com/embed/YuOBzWF0Aws");
            Assert.AreEqual(article.Image,
                            @"https://ichef.bbci.co.uk/news/660/cpsprodpb/8C8E/production/_103928953_est1.png");
            Assert.IsNotNull(article.Text);

            Assert.IsNull(noart);
        }