Ejemplo n.º 1
0
        public void CanDelete_should_throw_exception_if_comment_not_found()
        {
            var commentId = DomainId.NewGuid();
            var command   = new DeleteComment {
                CommentId = commentId, Actor = user1
            };

            var events = new List <Envelope <CommentsEvent> >();

            Assert.Throws <DomainObjectNotFoundException>(() => GuardComments.CanDelete(commentsId, events, command));
        }
Ejemplo n.º 2
0
        public void CanDelete_should_not_throw_exception_if_comment_from_same_user()
        {
            var commentId = DomainId.NewGuid();
            var command   = new DeleteComment {
                CommentId = commentId, Actor = user1
            };

            var events = new List <Envelope <CommentsEvent> >
            {
                Envelope.Create <CommentsEvent>(new CommentCreated {
                    CommentId = commentId, Actor = user1
                }).To <CommentsEvent>()
            };

            GuardComments.CanDelete(commentsId, events, command);
        }
Ejemplo n.º 3
0
        public void CanDelete_should_not_throw_exception_if_comment_is_own_notification()
        {
            var commentId = DomainId.NewGuid();
            var command   = new DeleteComment {
                CommentId = commentId, Actor = user1
            };

            var events = new List <Envelope <CommentsEvent> >
            {
                Envelope.Create <CommentsEvent>(new CommentCreated {
                    CommentId = commentId, Actor = user1
                }).To <CommentsEvent>()
            };

            GuardComments.CanDelete(command, user1.Identifier, events);
        }
Ejemplo n.º 4
0
        public void CanDelete_should_throw_exception_if_comment_from_another_user()
        {
            var commentId = DomainId.NewGuid();
            var command   = new DeleteComment {
                CommentId = commentId, Actor = user2
            };

            var events = new List <Envelope <CommentsEvent> >
            {
                Envelope.Create <CommentsEvent>(new CommentCreated {
                    CommentId = commentId, Actor = user1
                }).To <CommentsEvent>()
            };

            Assert.Throws <DomainException>(() => GuardComments.CanDelete(commentsId, events, command));
        }
Ejemplo n.º 5
0
        public void CanDelete_should_throw_exception_if_comment_deleted()
        {
            var commentId = DomainId.NewGuid();
            var command   = new DeleteComment {
                CommentId = commentId, Actor = user1
            };

            var events = new List <Envelope <CommentsEvent> >
            {
                Envelope.Create <CommentsEvent>(new CommentCreated {
                    CommentId = commentId, Actor = user1
                }),
                Envelope.Create <CommentsEvent>(new CommentDeleted {
                    CommentId = commentId
                })
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardComments.CanDelete(command, commentsId, events));
        }