public void ValidationAttribute_Usage()
        {
            // Arrange
            var poco     = new MyPOCO();
            var propInfo = typeof(MyPOCO)
                           .GetProperty("MyProperty");
            var validation = propInfo
                             .GetCustomAttributes(true)
                             .Single(e => e is MyValidationAttribute) as MyValidationAttribute;
            var propValue = propInfo.GetValue(poco);

            // Act
            var isValid = validation.IsValid(propValue);

            // Assert
            Assert.True(isValid);
        }
        public void Validator_Validate()
        {
            // Arrange
            var poco = new MyPOCO();

            poco.MyProperty = 2;
            var ctx = new ValidationContext(poco);

            // Act
            var isObjectValidate = Validator.TryValidateObject(poco, ctx, null);
            var results          = new List <ValidationResult>();

            ctx.MemberName = "MyProperty";
            var isPropertyValidate    = Validator.TryValidateProperty(poco.MyProperty, ctx, results);
            var isAllPropertyValidate = Validator.TryValidateObject(poco, ctx, results, true);

            // Assert
            Assert.True(isObjectValidate);
        }