public void Can_Set_And_Get_Errors()
        {
            var obj = new MockValidatableObject();

            Assert.IsFalse(obj.HasErrors);
            Assert.IsNull(obj.GetErrors(() => obj.Name)?.ToList().FirstOrDefault());

            obj.SetError(() => obj.Name, "The name is invalid.");
            obj.SetError(() => obj.Name, "The name is unknown.");

            Assert.IsTrue(obj.HasErrors);

            var errors = obj.GetErrors(() => obj.Name).ToList();

            Assert.AreEqual("The name is invalid.", errors[0]);
            Assert.AreEqual("The name is unknown.", errors[1]);
        }
        public void Set_Errors_Raises_ErrorsChanged_Event()
        {
            var eventIsRaised = false;
            var obj           = new MockValidatableObject();

            obj.ErrorsChanged += (sender, e) => eventIsRaised = true;

            obj.SetError(() => obj.Name, "The name is required.");

            Assert.IsTrue(eventIsRaised);
        }
        public void Can_All_Clear_Errors()
        {
            var obj = new MockValidatableObject();

            Assert.IsFalse(obj.HasErrors);

            obj.SetError(() => obj.Name, "The name is required.");

            Assert.IsTrue(obj.HasErrors);

            obj.ClearAllValidationErrors();

            Assert.IsFalse(obj.HasErrors);
        }