public void Can_Comment_A_Saved_Post() { var newPost = new Post() { Body = "Corpo do post!", Title = "Titulo do post", Slug = "Titulo do post".Slugify(), Author = "Renata Fan" }; var repository = new NHibernateRepository<Post>(SessionFactory, null); repository.Add(newPost); Session.Flush(); Post saved = repository.FirstOrDefault(c => c.Id == newPost.Id); saved.Comment("Eeeeeeeeeeeu!", "Chapolin", "*****@*****.**"); Session.Flush(); Assert.AreEqual(1, saved.Comments.Count()); Assert.AreEqual("Chapolin", saved.Comments.FirstOrDefault().Author); Assert.AreEqual("Eeeeeeeeeeeu!", saved.Comments.FirstOrDefault().Text); Assert.AreEqual("*****@*****.**", saved.Comments.FirstOrDefault().Mail); }
public void Can_Change_A_Saved_Post() { var newPost = new Post() { Body = "Corpo do post!", Title = "Titulo do post", Slug = "Titulo do post".Slugify(), Author = "Renata Fan" }; var repository = new NHibernateRepository<Post>(SessionFactory, null); repository.Add(newPost); Session.Flush(); Post saved = repository.FirstOrDefault(c => c.Id == newPost.Id); saved.Title += "Changed"; saved.Body += "Changed"; saved.Slug += saved.Title.Slugify(); Session.Flush(); Assert.AreEqual("Corpo do post!Changed", saved.Body); Assert.AreEqual("Titulo do postChanged", saved.Title); }
public void Can_Delete_A_Saved_Post() { var newPost = new Post() { Body = "Corpo do post!", Title = "Titulo do post", Slug = "Titulo do post".Slugify(), Author = "Renata Fan" }; var repository = new NHibernateRepository<Post>(SessionFactory, null); repository.Add(newPost); Session.Flush(); Post saved = repository.FirstOrDefault(c => c.Id == newPost.Id); repository.Remove(saved); Session.Flush(); Assert.AreEqual(0, repository.Count); }