コード例 #1
0
ファイル: LogicTest.cs プロジェクト: elizabethbril/Blog
        public void AddCommentToPost()
        {
            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"));
            PostLogic.AddComment(PostLogic.GetAll().ToList()[0].Id, new CommentsDTO("Great Post", 0, true));

            Assert.AreEqual(UoW.Object.Comments.GetAll().Count(), 1);
            Assert.AreEqual(PostLogic.GetAll().ToList()[0].Comments[0].Comment_Content, "Great Post");
            Assert.IsTrue(PostLogic.GetAll().ToList()[0].Comments[0].Publish == true);
            Assert.IsTrue(PostLogic.GetAll().ToList()[0].Comments[0].Post.Id == PostLogic.GetAll().ToList()[0].Id);
        }