Ejemplo n.º 1
0
 public static Notification GetNotification(ValidationAttribute attribute, object caller, string propertyName)
 {
     var notification = new Notification();
     attribute.Property = caller.GetType().GetProperty(propertyName);
     attribute.Validate(caller, notification);
     return notification;
 }
Ejemplo n.º 2
0
        public static void ThrowsException(ValidationAttribute attribute, object caller, string propertyName, Type expectedException)
        {
            attribute.Property = caller.GetType().GetProperty(propertyName);
            try
            {
                attribute.Validate(caller, new Notification());
                Assert.Fail("Expected exception");
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(AssertionException))
                    throw;

                Assert.IsInstanceOfType(expectedException, ex);
            }
        }