예제 #1
0
        public void ShouldHaveValidationErrorWhenBlogDoesNotExist()
        {
            var command       = PostFactories.CreatePostCommand();
            var postRulesMock = new Mock <IPostRules>();
            var blogRulesMock = new Mock <IBlogRules>();

            blogRulesMock.Setup(x => x.DoesBlogExistAsync(command.BlogId)).ReturnsAsync(false);
            var validator = new CreatePostValidator(postRulesMock.Object, blogRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Title, command);
        }
예제 #2
0
        public void ShouldHaveValidationErrorWhenSlugIsNotUnique()
        {
            var command       = PostFactories.CreatePostCommand();
            var postRulesMock = new Mock <IPostRules>();

            postRulesMock.Setup(x => x.IsSlugUniqueAsync(command.BlogId, command.AggregateRootId, command.Slug)).ReturnsAsync(false);
            var blogRulesMock = new Mock <IBlogRules>();
            var validator     = new CreatePostValidator(postRulesMock.Object, blogRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Slug, command);
        }
예제 #3
0
        public void ShouldHaveValidationErrorWhenExcerptIsTooLong()
        {
            var command = PostFactories.CreatePostCommand();

            command.Excerpt = SharedFactories.RandomString(251);
            var postRulesMock = new Mock <IPostRules>();
            var blogRulesMock = new Mock <IBlogRules>();
            var validator     = new CreatePostValidator(postRulesMock.Object, blogRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Excerpt, command);
        }
예제 #4
0
        public void ShouldHaveValidationErrorWhenContentIsEmptyAndStatusIsPublished()
        {
            var command = PostFactories.CreatePostCommand();

            command.Content = string.Empty;
            command.Status  = PostStatus.Published;
            var postRulesMock = new Mock <IPostRules>();
            var blogRulesMock = new Mock <IBlogRules>();
            var validator     = new CreatePostValidator(postRulesMock.Object, blogRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Content, command);
        }
예제 #5
0
        public void ShouldHaveValidationErrorWhenTitleIsTooLong()
        {
            var command = PostFactories.CreatePostCommand();

            command.Title = SharedFactories.RandomString(101);
            var postRulesMock = new Mock <IPostRules>();

            postRulesMock.Setup(x => x.IsTitleUniqueAsync(command.BlogId, command.AggregateRootId, command.Title)).ReturnsAsync(true);
            var blogRulesMock = new Mock <IBlogRules>();
            var validator     = new CreatePostValidator(postRulesMock.Object, blogRulesMock.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Title, command);
        }