Пример #1
0
        public void AddPostTest()
        {
            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.AddPost(new Post(1, postBody1)));
            Assert.IsTrue(xmlRepo.AddPost(new Post(2, postBody2)));

            List <IPost> posts = xmlRepo.GetAllPosts().ToList <IPost>();

            Assert.AreEqual(posts.Count, 2);
        }
Пример #2
0
        public void GetPostTest()
        {
            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.AddPost(new Post(1, postBody1));
            xmlRepo.AddPost(new Post(2, postBody2));

            IPost post = xmlRepo.GetPost(1);

            Assert.IsNotNull(post);
            Assert.AreEqual <string>(post.Body, postBody1);
            Assert.AreEqual <string>(xmlRepo.GetPost(2).Body, postBody2);
            Assert.IsNull(xmlRepo.GetPost(3));
        }