Exemplo n.º 1
0
        public void UpdateForumWithNameAndId()
        {
            NForum.CQS.Commands.Forums.UpdateForumCommand update = new CQS.Commands.Forums.UpdateForumCommand {
                Id   = 634634.ToString(),
                Name = "meh"
            };

            NForum.CQS.Validators.Forums.UpdateForumValidator validator = new NForum.CQS.Validators.Forums.UpdateForumValidator(TestUtils.GetInt32IdValidator());

            ValidationResult result = validator.Validate(update);

            result.IsValid.Should().Be(true, "A name and id was provide");
        }
Exemplo n.º 2
0
        public void UpdateForumWithEmptyNameAndId()
        {
            NForum.CQS.Commands.Forums.UpdateForumCommand update = new CQS.Commands.Forums.UpdateForumCommand {
                Id   = String.Empty,
                Name = String.Empty
            };

            NForum.CQS.Validators.Forums.UpdateForumValidator validator = new NForum.CQS.Validators.Forums.UpdateForumValidator(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");
            result.Errors.Count().Should().Be(2, "An empty name and/or id 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");
            result.Errors.Count().Should().Be(2, "An empty name and/or id is not allowed");

            update.Id   = 2153.ToString();
            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 id is not allowed");
        }