public void Set_Errors_Raises_ErrorsChanged_Event() { var eventIsRaised = false; var obj = new MockValidatableObject(); obj.ErrorsChanged += (sender, e) => eventIsRaised = true; obj.Invalidate(); Assert.IsTrue(eventIsRaised); }
public void Can_Set_And_Get_Errors() { var obj = new MockValidatableObject(); Assert.IsFalse(obj.HasErrors); Assert.IsNull(obj.GetErrors(() => obj.Name)?.Cast <string>().ToList().FirstOrDefault()); obj.Invalidate(); Assert.IsTrue(obj.HasErrors); Assert.AreEqual("The name is required.", obj.GetErrors(() => obj.Name).Cast <string>().ToList().FirstOrDefault()); }
public void Can_All_Clear_Errors() { var obj = new MockValidatableObject(); Assert.IsFalse(obj.HasErrors); obj.Invalidate(); Assert.IsTrue(obj.HasErrors); obj.ClearAllValidationErrors(); Assert.IsFalse(obj.HasErrors); }