Example #1
0
        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");
        }