예제 #1
0
        public void ValidatesParentOnPropertyChanged()
        {
            var c = new ValidatableChild();
            var p = new ValidatableParent();

            p.Child = c;

            Assert.IsFalse(p.HasErrors);
            Assert.IsFalse(c.HasErrors);

            c.Name = string.Empty;

            Assert.IsTrue(p.HasErrors);
            Assert.IsTrue(c.HasErrors);

            c.Name = "Funny";

            Assert.IsFalse(p.HasErrors);
            Assert.IsFalse(c.HasErrors);
        }
예제 #2
0
        public void ValidatesParentOnCollectionItemPropertyChanged()
        {
            var c = new ValidatableChild();
            var p = new ValidatableParent();

            p.Collection = new ObservableCollection <ValidatableChild>();
            p.Collection.Add(c);

            Assert.IsFalse(p.HasErrors);
            Assert.IsFalse(c.HasErrors);

            c.Name = string.Empty;

            Assert.IsTrue(p.HasErrors);
            Assert.IsTrue(c.HasErrors);

            c.Name = "Bunny";

            Assert.IsFalse(p.HasErrors);
            Assert.IsFalse(c.HasErrors);
        }