public EfCreatePostCommand(FotobloggerContext context, CreatePostValidator validator, IApplicationActor actor, IMapper mapper)
 {
     _context   = context;
     _validator = validator;
     _actor     = actor;
     _mapper    = mapper;
 }
예제 #2
0
 public PostController(IMapper mapper, CreatePostValidator validator, ProjekatContext context, UseCaseExecutor executor)
 {
     _context   = context;
     _mapper    = mapper;
     _validator = validator;
     _executor  = executor;
 }
예제 #3
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);
        }
        public void NullContentInvalid()
        {
            var validator = new CreatePostValidator();

            ValidationResult result = validator.Validate(new Post { Author = "Test", Content = null });

            Assert.That(result, Is.Not.Null);
            Assert.That(result.IsValid, Is.False);
            Assert.That(
                result.Errors.Count(x => x.PropertyName == "Content" && x.ErrorMessage.Contains("empty")), Is.EqualTo(1));
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
 public EfCreatePostCommand(BlogContext context, CreatePostValidator validator, IMapper mapper)
 {
     _context   = context;
     _validator = validator;
     _mapper    = mapper;
 }
 public void TearDown()
 {
     this.createValidator = null;
     this.updateValidator = null;
 }
 public void Setup()
 {
     this.createValidator = A.Fake<CreatePostValidator>();
     this.updateValidator = A.Fake<UpdatePostValidator>();
 }
예제 #12
0
 public EfUpdatePostCommand(BlogContext context, IMapper mapper, CreatePostValidator validator)
 {
     this.context   = context;
     this.mapper    = mapper;
     this.validator = validator;
 }
        public void Valid()
        {
            var validator = new CreatePostValidator();

            ValidationResult result = validator.Validate(new Post { Author = "Test", Content = "Test" });

            Assert.That(result, Is.Not.Null);
            Assert.That(result.IsValid, Is.True);
            Assert.That(result.Errors.Count, Is.EqualTo(0));
        }
예제 #14
0
 public EfCreatePostCommand(PhoTexBlogContext context, CreatePostValidator validator)
 {
     _context   = context;
     _validator = validator;
 }