예제 #1
0
        public void EditPost()
        {
            var UoW = new Mock <UnitOfWork>();

            UoW.Object.DeleteDB();

            var PostLogic = new PostLogic(UoW.Object);
            var UserLogic = new UserLogic(UoW.Object);

            UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password"));
            UserLogic.Login("Login", "Password");
            PostLogic.Add(new PostDTO("Title", "Content", "Tag", "CategoryName"));

            var Post = PostLogic.GetAll().ToList()[0];

            Assert.AreEqual(PostLogic.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Title, "Title");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Content, "Content");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Tags, "Tag");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].CategoryName, "CategoryName");

            Post.Title        = "Programming";
            Post.CategoryName = "C#";

            PostLogic.EditPost(Post.Id, Post);

            Post = PostLogic.GetAll().ToList()[0];

            Assert.AreEqual(PostLogic.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Title, "Programming");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Content, "Content");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Tags, "Tag");
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].CategoryName, "C#");
        }