Ejemplo n.º 1
0
        public void TestFunc_UserIdsAreNotEqual_ShouldSetCanEditEqualToIsAdmin(string userId, bool isAdmin, int commentId, string content, string username)
        {
            // Arrange
            var comment = new Comment
            {
                UserId    = userId,
                CommentId = commentId,
                Content   = content,
                User      = new User {
                    UserName = username
                }
            };

            // Act
            var model = CommentViewModel.FromComment(comment, null, isAdmin);

            // Assert
            Assert.AreEqual(isAdmin, model.CanEdit);
        }
Ejemplo n.º 2
0
        public void TestFunc_ShouldSetCommentIdCorrectly(string userId, bool isAdmin, int commentId, string content, string username)
        {
            // Arrange
            var comment = new Comment
            {
                UserId    = userId,
                CommentId = commentId,
                Content   = content,
                User      = new User {
                    UserName = username
                }
            };

            // Act
            var model = CommentViewModel.FromComment(comment, null, isAdmin);

            // Assert
            Assert.AreEqual(commentId, model.CommentId);
        }
Ejemplo n.º 3
0
        public void TestFunc_ShouldSetDateCorrectly(string userId, bool isAdmin, int commentId, string content, string username)
        {
            // Arrange
            var date    = new DateTime();
            var comment = new Comment
            {
                Date      = date,
                UserId    = userId,
                CommentId = commentId,
                Content   = content,
                User      = new User {
                    UserName = username
                }
            };

            // Act
            var model = CommentViewModel.FromComment(comment, userId, isAdmin);

            // Assert
            Assert.AreEqual(date, model.Date);
        }