Exemple #1
0
        public void ValidatorTest()
        {
            Func <int, string> validator = i => i % 2 != 0 ? "The number must be even" : null;

            var validatedProperty = new ValidatedChangeableProperty <int>("abc", 0, validator);

            Assert.IsTrue(validatedProperty.IsValidated);
            Assert.IsTrue(validatedProperty.IsValid);
            Assert.IsNull(validatedProperty.ValidationMessage);

            validatedProperty.CurrentValue = 1;
            Assert.IsTrue(validatedProperty.IsValidated);
            Assert.IsFalse(validatedProperty.IsValid);
            Assert.AreEqual("abc: The number must be even", validatedProperty.ValidationMessage);

            validatedProperty.IsValidated = false;
            Assert.IsFalse(validatedProperty.IsValidated);
            Assert.IsTrue(validatedProperty.IsValid);
            Assert.IsNull(validatedProperty.ValidationMessage);
        }
Exemple #2
0
 set => SetValue(ValidatedChangeableProperty, value);