public void AddCommentTest() { if (File.Exists("\\XML_Data\\PostsDB.xml")) { File.Delete("\\XML_Data\\PostsDB.xml"); File.Delete("\\XML_Data\\CommentsDB.xml"); } IForumRepository xmlRepo = new ForumXmlRepository("\\XML_Data\\PostsDB.xml", "\\XML_Data\\CommentsDB.xml"); Assert.IsTrue(xmlRepo.AddComment(new Comment(1, 1, commentBody1))); Assert.IsTrue(xmlRepo.AddComment(new Comment(2, 1, commentBody2))); List <IComment> comments = xmlRepo.GetAllComments().ToList <IComment>(); Assert.AreEqual(comments.Count, 2); }
public void GetCommentTest() { if (File.Exists("\\XML_Data\\PostsDB.xml")) { File.Delete("\\XML_Data\\PostsDB.xml"); File.Delete("\\XML_Data\\CommentsDB.xml"); } IForumRepository xmlRepo = new ForumXmlRepository("\\XML_Data\\PostsDB.xml", "\\XML_Data\\CommentsDB.xml"); xmlRepo.AddComment(new Comment(1, 1, commentBody1)); xmlRepo.AddComment(new Comment(2, 1, commentBody2)); IComment comment = xmlRepo.GetComment(1); Assert.IsNotNull(comment); Assert.AreEqual <string>(comment.Body, commentBody1); Assert.AreEqual <string>(xmlRepo.GetComment(2).Body, commentBody2); Assert.IsNull(xmlRepo.GetComment(3)); }