public void TestValidateAll() { var model = new UserValidatableAndEditable { FirstName = "Marie", LastName = "Bellin" }; model.ValidateAll(); Assert.AreEqual(false, model.HasErrors); }
public void TestCanValidateOnChange_WithOnChange() { var model = new UserValidatableAndEditable { FirstName = "Marie", LastName = "Bellin", ValidationType = ValidationHandling.OnPropertyChange }; Assert.AreEqual(ValidationHandling.OnPropertyChange, model.ValidationType); Assert.IsTrue(model.CanValidateOnPropertyChanged); }
public void TestHasNoError() { var user = new UserValidatableAndEditable { FirstName = "Marie", LastName = "Bellin" }; user.ValidateProperty("FirstName"); var errors = user.GetErrors("FirstName"); Assert.IsFalse(user.HasErrors); Assert.IsNull(errors); }
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 TestHasError() { var user = new UserValidatableAndEditable { FirstName = "M", LastName = "Bellin" }; user.ValidateProperty("FirstName"); var errors = user.GetErrors("FirstName"); var r = errors.Cast <string>().ToList(); Assert.IsTrue(user.HasErrors); Assert.AreEqual(1, r.Count); Assert.AreEqual("FirstName too short", r[0]); }
public void BeginEdit_And_Cancel() { var user = new UserValidatableAndEditable { FirstName = "Marie", LastName = "Bellin" }; user.BeginEdit(); user.FirstName = "updated firstname"; user.LastName = "updated lastname"; user.CancelEdit(); Assert.AreEqual("Marie", user.FirstName); Assert.AreEqual("Bellin", user.LastName); }
public void TestValidate_IsCalledOnPropertyChanged() { var user = new UserValidatableAndEditable { ValidationType = ValidationHandling.OnPropertyChange, FirstName = "M", LastName = "Bellin" }; var r1 = user.GetErrors("FirstName").Cast <string>().ToList(); Assert.AreEqual(1, r1.Count); user.FirstName = "Marie"; var r2 = user.GetErrors("FirstName"); Assert.IsNull(r2); }
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]); }