示例#1
0
        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);
        }
示例#2
0
        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());
        }
示例#3
0
        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);
        }