public void Add_NewsRecord_Should_Add_NewsRecord_to_DB()
        {
            //Arrange
            NewsRepository repo = new NewsRepository(new NewsContext());
            var news = new NewsRecord()
            {
                Title = "HardShit",
                Content = "Hard Shit in the mix",
                PublishDate = new DateTime(2015, 08, 30, 14, 04, 30)
            };

            //Act
            repo.Add(news);
            repo.SaveChanges();

            //Assert
            var newsFromDb = repo.FindById(news.Id);

            Assert.IsNotNull(newsFromDb, "NewsRecord is not added to database");
            Assert.IsTrue(newsFromDb.Id != 0, "NewsRecord must have id !=0");
            Assert.AreEqual(news.Title, newsFromDb.Title, "Title is not corect");
            Assert.AreEqual(news.Content, newsFromDb.Content, "Content is not corect");
            Assert.AreEqual(news.PublishDate, newsFromDb.PublishDate, "Date is not corect");
        }
Ejemplo n.º 2
0
 public PartialViewResult NewsDevam(int id)
 {
     return(PartialView(_rep.FindById(id)));
 }
Ejemplo n.º 3
0
 public ActionResult ReadArticle(int id)
 {
     return(View(news.FindById(id)));
 }