Example #1
0
        public void GetCommentsByClientTest()
        {
            Comment comment = new Comment();

            comment.Text     = "Very nice.";
            comment.Date     = DateTime.Now;
            comment.MovieId  = 5;
            comment.ClientId = 10;
            CommentDAO commentDAO = new CommentDAO();

            commentDAO.AddComment(comment);
            List <string> expected = new List <string>();

            expected.Add(ToStringWithoutId(comment));

            comment          = new Comment();
            comment.Text     = "It's the worst movie I've ever seen.";
            comment.Date     = DateTime.Now;
            comment.MovieId  = 7;
            comment.ClientId = 10;
            commentDAO.AddComment(comment);
            expected.Add(ToStringWithoutId(comment));

            List <Comment> list = commentDAO.GetCommentsByClient((int)comment.ClientId);

            if (list == null || list.Count < 2)
            {
                Assert.Fail();
            }
            List <string> actual = new List <string>();

            for (int i = list.Count - 2; i < list.Count; i++)
            {
                actual.Add(ToStringWithoutId(list[i]));
            }

            CollectionAssert.AreEqual(expected, actual);
        }