public void DoesNestedPropertyValidateWithARVBGeneric() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(UserWithNestedAddress)); Recreate(); UserWithNestedAddress user = new UserWithNestedAddress(); Assert.IsFalse(user.IsValid()); user.Email = "someemail"; Assert.IsFalse(user.IsValid(), "Nested class not validated"); Assert.IsTrue(user.ValidationErrorMessages.Length == 3, "Both nested props are required and should have error messages"); Assert.IsTrue(user.PropertiesValidationErrorMessages.Count == 2, "Two properties should be invalid"); user.PostalAddress.AddressLine1 = "15st"; //to short user.PostalAddress.Country = "Brazil"; user.Email = "12345"; Assert.IsFalse(user.IsValid()); Assert.IsTrue(user.ValidationErrorMessages.Length == 1, "Should be a too short error message"); Assert.IsTrue(user.PropertiesValidationErrorMessages.Count == 1, "One property should be invalid"); user.PostalAddress.AddressLine1 = "12345"; Assert.IsTrue(user.IsValid()); //setup another nested prop user.BillingAddress = new Address(); user.BillingAddress.AddressLine1 = "12"; // to short user.BillingAddress.Country = "New Zealand"; Assert.IsFalse(user.IsValid()); Assert.IsTrue(user.ValidationErrorMessages.Length == 1, "Should be one error message about required length"); Assert.IsTrue(user.PropertiesValidationErrorMessages.Count == 1, "One property should be invalid"); user.BillingAddress.AddressLine1 = "12345"; Assert.IsTrue(user.IsValid()); }
public void DoesNestedPropertyValidateWithARVBGeneric() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(UserWithNestedAddress)); Recreate(); UserWithNestedAddress user = new UserWithNestedAddress(); Assert.IsFalse(user.IsValid()); user.Email = "someemail"; Assert.IsFalse(user.IsValid(),"Nested class not validated"); Assert.IsTrue(user.ValidationErrorMessages.Length == 3,"Both nested props are required and should have error messages"); Assert.IsTrue(user.PropertiesValidationErrorMessages.Count == 2,"Two properties should be invalid"); user.PostalAddress.AddressLine1 = "15st"; //to short user.PostalAddress.Country = "Brazil"; user.Email = "12345"; Assert.IsFalse(user.IsValid()); Assert.IsTrue(user.ValidationErrorMessages.Length == 1,"Should be a too short error message"); Assert.IsTrue(user.PropertiesValidationErrorMessages.Count ==1,"One property should be invalid") ; user.PostalAddress.AddressLine1 = "12345"; Assert.IsTrue(user.IsValid()); //setup another nested prop user.BillingAddress = new Address(); user.BillingAddress.AddressLine1 = "12"; // to short user.BillingAddress.Country = "New Zealand"; Assert.IsFalse(user.IsValid()); Assert.IsTrue(user.ValidationErrorMessages.Length == 1, "Should be one error message about required length"); Assert.IsTrue(user.PropertiesValidationErrorMessages.Count == 1, "One property should be invalid"); user.BillingAddress.AddressLine1 = "12345"; Assert.IsTrue(user.IsValid()); }