public void ShouldEmptyMessageWhenValidationSucceed()
        {
            var validator = new ValidatesPresenceOf();
            var dummy = new VeryDummyClass();
            var property = dummy.GetType().GetProperty("DummyText");
            validator.Validate(dummy, property);
            dummy.DummyText = "dummy dummy";
            validator.Validate(dummy, property);

            Assert.IsNullOrEmpty(validator.Message);
        }
        public void ShouldFormatCustomMessageWhenValidationFailAgain()
        {
            var validator = new ValidatesPresenceOf();
            validator.Message = "{0} can't be empty";
            var dummy = new VeryDummyClass();

            validator.Validate(dummy, dummy.GetType().GetProperty("DummyText"));
            validator.Validate(dummy, dummy.GetType().GetProperty("DummyProperty"));

            Assert.AreEqual("DummyProperty can't be empty", validator.Message);
        }
        public void ShouldFailStringValidation()
        {
            var validator = new ValidatesPresenceOf();
            var dummy = new VeryDummyClass();
            var property = dummy.GetType().GetProperty("DummyText");

            dummy.DummyText = null;
            Assert.IsFalse(validator.Validate(dummy, property));

            dummy.DummyText = string.Empty;
            Assert.IsFalse(validator.Validate(dummy, property));
        }
 public ValidatesPresenceOfAttribute()
 {
     Validator = new ValidatesPresenceOf();
 }
        public void ShouldFormatMessageWhenValidationFail()
        {
            var validator = new ValidatesPresenceOf();
            var dummy = new VeryDummyClass();
            var property = dummy.GetType().GetProperty("DummyText");

            validator.Validate(dummy, property);

            Assert.AreEqual("DummyText can't be blank", validator.Message);
        }
 public void ShouldCustomizeMessage()
 {
     var validator = new ValidatesPresenceOf();
     validator.Message = "{0} não pode ser vazio";
     Assert.AreEqual("{0} não pode ser vazio", validator.Message);
 }
        public void ShouldBeIValidator()
        {
            var validator = new ValidatesPresenceOf() as IValidator;

            Assert.IsNotNull(validator);
        }
        public void ShouldValidateString()
        {
            var validator = new ValidatesPresenceOf();
            var dummy = new VeryDummyClass();
            var property = dummy.GetType().GetProperty("DummyText");
            dummy.DummyText = "Dummy dummy";

            Assert.IsTrue(validator.Validate(dummy, property));
        }
 public void ShouldHaveDefaultMessage()
 {
     var validator = new ValidatesPresenceOf();
     Assert.AreEqual("{0} can't be blank", validator.Message);
 }