public void TestValidateAll() { var model = new UserValidatableAndEditable { FirstName = "Marie", LastName = "Bellin" }; model.ValidateAll(); Assert.AreEqual(false, model.HasErrors); }
public void TestCanValidateOnChange_WithExplicit() { var model = new UserValidatableAndEditable { ValidationType = ValidationHandling.Explicit, FirstName = "Marie", LastName = "Bellin" }; Assert.AreEqual(ValidationHandling.Explicit, model.ValidationType); Assert.IsFalse(model.CanValidateOnPropertyChanged); model.ValidateAll(); Assert.IsFalse(model.CanValidateOnPropertyChanged); }
public void TestValidateAll_HasErrors() { var model = new UserValidatableAndEditable { FirstName = "M", LastName = "" }; model.ValidateAll(); var r1 = model.GetErrors("FirstName").Cast <string>().ToList(); var r2 = model.GetErrors("LastName").Cast <string>().ToList(); Assert.AreEqual(true, model.HasErrors); Assert.AreEqual(1, r1.Count); Assert.AreEqual("FirstName too short", r1[0]); Assert.AreEqual(1, r2.Count); Assert.AreEqual("LastName required", r2[0]); }