コード例 #1
0
        public void NegativeValidation()
        {
            var target = new GreaterThanZeroTarget(-3);
            var notification = Validator.ValidateObject(target);
            Assert.IsFalse(notification.IsValid());

            var expected = new NotificationMessage("Amount", "Must be a positive number");
            Assert.AreEqual(expected, notification.AllMessages[0]);
            Assert.AreEqual(1, notification.AllMessages.Length);
        }
コード例 #2
0
 public void PositiveValidationWithNonNullGreaterThanZeroNumber()
 {
     var target = new GreaterThanZeroTarget(100);
     INotification notification = Validator.ValidateObject(target);
     Assert.IsTrue(notification.IsValid());
 }
コード例 #3
0
 public void IgnoreValidationOnNullValue()
 {
     var target = new GreaterThanZeroTarget();
     var notification = Validator.ValidateObject(target);
     Assert.IsTrue(notification.IsValid());
 }