public void ValidatingDescriptionOnPersonWithDataAnnotationReturnsValidationError()
        {
            var person = new PersonWithDataAnnotation();
            person.Name = "Edgar";
            person.Age = 42;

            var validationResults = new List<ValidationResult>();
            var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(person);
            var result = false;
            result = Validator.TryValidateObject(person, validationContext, validationResults, true);
            Assert.IsFalse(result);
            Assert.AreEqual(1, validationResults.Count());
            var validationResult = validationResults[0];
            Assert.AreEqual(1, validationResult.MemberNames.Count());
            var memberName = validationResult.MemberNames.First();
            Assert.AreEqual("Description", memberName);
        }
        public void UsingPersonWithDataAnnotationWorksAsExpected()
        {
            var person = new PersonWithDataAnnotation();
            person.Name = "Edgar";
            person.Description = "some description";
            person.Age = 42;

            var validationResults = new List<ValidationResult>();
            var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(person);
            var result = false;
            result = Validator.TryValidateObject(person, validationContext, validationResults, true);
            Assert.IsTrue(result); 
            
            Assert.AreEqual(42, person.Age);
            Assert.AreEqual("Edgar", person.Name);
            Assert.AreEqual("some description", person.Description);            
        }
        public void UsingPersonWithDataAnnotationWorksAsExpected()
        {
            var person = new PersonWithDataAnnotation();

            person.Name        = "Edgar";
            person.Description = "some description";
            person.Age         = 42;

            var validationResults = new List <ValidationResult>();
            var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(person);
            var result            = false;

            result = Validator.TryValidateObject(person, validationContext, validationResults, true);
            Assert.IsTrue(result);

            Assert.AreEqual(42, person.Age);
            Assert.AreEqual("Edgar", person.Name);
            Assert.AreEqual("some description", person.Description);
        }
        public void ValidatingDescriptionOnPersonWithDataAnnotationReturnsValidationError()
        {
            var person = new PersonWithDataAnnotation();

            person.Name = "Edgar";
            person.Age  = 42;

            var validationResults = new List <ValidationResult>();
            var validationContext = new System.ComponentModel.DataAnnotations.ValidationContext(person);
            var result            = false;

            result = Validator.TryValidateObject(person, validationContext, validationResults, true);
            Assert.IsFalse(result);
            Assert.AreEqual(1, validationResults.Count());
            var validationResult = validationResults[0];

            Assert.AreEqual(1, validationResult.MemberNames.Count());
            var memberName = validationResult.MemberNames.First();

            Assert.AreEqual("Description", memberName);
        }