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); }
public void AddPost() { 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")); 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"); }
public void SearchByTag() { 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.Add(new PostDTO("Title1", "Content1", "Tag1", "CategoryName1")); PostLogic.Add(new PostDTO("Title2", "Content2", "Tag2", "CategoryName2")); PostLogic.Add(new PostDTO("Title3", "Content3", "Tag3", "CategoryName3")); PostLogic.Add(new PostDTO("Title4", "Content4", "Tag4", "CategoryName4")); Assert.IsTrue(PostLogic.GetAll().Count() == 5); Assert.AreEqual(PostLogic.SearchByTag("Tag1").ToList()[0].Tags, "Tag1"); Assert.AreEqual(PostLogic.SearchByTag("Tag4").ToList()[0].Tags, "Tag4"); }
public void FindByCategory() { 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", "C#")); PostLogic.Add(new PostDTO("Title1", "Content1", "Tag1", "C++")); PostLogic.Add(new PostDTO("Title2", "Content2", "Tag2", "Java")); PostLogic.Add(new PostDTO("Title3", "Content3", "Tag3", "Python")); PostLogic.Add(new PostDTO("Title4", "Content4", "Tag4", "JS")); Assert.IsTrue(PostLogic.GetAll().Count() == 5); Assert.AreEqual(PostLogic.FindByCategory("C#").ToList()[0].CategoryName, "C#"); Assert.AreEqual(PostLogic.FindByCategory("C++").ToList()[0].CategoryName, "C++"); Assert.AreEqual(PostLogic.FindByCategory("JS").ToList()[0].CategoryName, "JS"); Assert.AreEqual(PostLogic.FindByCategory("Java").ToList()[0].CategoryName, "Java"); }