示例#1
0
 public void Create_Category_With_No_Name_Throws_Exception()
 {
     using (var context = GetContextWithData())
     {
         var validator = new CreateCategoryCommandValidator(context);
         validator.ShouldHaveValidationErrorFor(x => x.Name, string.Empty);
     }
 }
        public void Should_have_error_when_category_title_is_empty()
        {
            var categoryRepository = new Mock <ICategoryRepository>();

            var validator = new CreateCategoryCommandValidator(categoryRepository.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Title, new CreateCategoryCommand(Guid.NewGuid(), ""));
        }
        public void Should_have_error_when_category_title_already_exists()
        {
            var          blogId        = Guid.NewGuid();
            const string categoryTitle = "My Category";

            var categoryRepository = new Mock <ICategoryRepository>();

            categoryRepository.Setup(x => x.GetByBlogIdAndTitle(blogId, categoryTitle)).Returns(Category.CreateNew(blogId, categoryTitle));

            var validator = new CreateCategoryCommandValidator(categoryRepository.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Title, new CreateCategoryCommand(blogId, categoryTitle));
        }
 public void when_name_is_null__should_have_error()
     => _validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);