コード例 #1
0
        public void UpdateCategoryWithEmptyNameAndId()
        {
            NForum.CQS.Commands.Categories.UpdateCategoryCommand update = new CQS.Commands.Categories.UpdateCategoryCommand {
                Id   = String.Empty,
                Name = String.Empty
            };

            NForum.CQS.Validators.Categories.UpdateCategoryValidator validator = new CQS.Validators.Categories.UpdateCategoryValidator(TestUtils.GetInt32IdValidator());

            ValidationResult result = validator.Validate(update);

            result.IsValid.Should().Be(false, "An empty id/name is not allowed");
            result.Errors.Count().Should().Be(2, "An empty name and/or id is not allowed");

            update.Id   = null;
            update.Name = null;
            result      = validator.Validate(update);
            result.IsValid.Should().Be(false, "An empty id/name is not allowed");

            update.Id   = "\t";
            update.Name = "\t";
            result      = validator.Validate(update);
            result.IsValid.Should().Be(false, "An empty id/name is not allowed");

            update.Id   = "something";
            update.Name = String.Empty;
            result      = validator.Validate(update);
            result.IsValid.Should().Be(false, "An empty name is not allowed");

            update.Id   = String.Empty;
            update.Name = "my name";
            result      = validator.Validate(update);
            result.IsValid.Should().Be(false, "An empty name is not allowed");
        }
コード例 #2
0
        public void UpdateCategoryWithNameAndId()
        {
            NForum.CQS.Commands.Categories.UpdateCategoryCommand update = new CQS.Commands.Categories.UpdateCategoryCommand {
                Id   = 6554.ToString(),
                Name = "meh"
            };

            NForum.CQS.Validators.Categories.UpdateCategoryValidator validator = new CQS.Validators.Categories.UpdateCategoryValidator(TestUtils.GetInt32IdValidator());

            ValidationResult result = validator.Validate(update);

            result.IsValid.Should().Be(true, "A name and id was provide");
        }