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 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); }
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); }
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); }
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); }