Пример #1
0
        public static PropertyChangedTracker Create(object target)
        {
            var p   = new PropertyChangedTracker();
            var npc = (INotifyPropertyChanged)target;

            npc.PropertyChanged += p.OnPropertyChanged;
            return(p);
        }
        public void NotifyPropertyChanged()
        {
            var e = new AopTestEntityWithNPC();
            var t = PropertyChangedTracker.Create(e);

            e.A += 1;

            t.PropertyShouldBeNotified("A");
        }
        public void DontNotify()
        {
            var e = new AopTestEntityWithNPC();
            var t = PropertyChangedTracker.Create(e);

            e.B += 1;

            t.PropertyShouldBeNotified("B", 0);
        }
        public void RecursiveDependenttNotify()
        {
            var e = new AopTestEntityWithNPC();
            var t = PropertyChangedTracker.Create(e);

            e.A  += 1;
            e.A2 += 1;

            t.PropertyShouldBeNotified("RecursiveA", 2);
        }
        public void EqualValueSet()
        {
            var e = new AopTestEntityWithNPC();
            var t = PropertyChangedTracker.Create(e);

            e.A = 1;
            e.A = 1;

            t.PropertyShouldBeNotified("A", 1);
        }
Пример #6
0
        public void IsDirtyCollection()
        {
            var e = new Entity();

            e.Extensions.StartDirtyTracking();
            e.Extensions.IsDirty.ShouldBeFalse();

            var t = PropertyChangedTracker.Create(e.Extensions);

            var entity = new Entity();

            entity.Child = new Entity();
            e.Collection.Add(entity);

            t.PropertyShouldBeNotified("IsDirty", 1);
            e.Extensions.IsDirty.ShouldBeTrue();
        }
Пример #7
0
        public void IsValidCollectionElement()
        {
            var e = new Entity();

            e.Extensions.InitializeRules();
            e.Extensions.IsValid.ShouldBeTrue();

            var t = PropertyChangedTracker.Create(e.Extensions);

            var entity = new Entity();

            entity.Child = new Entity();
            e.Collection.Add(entity);
            e.Extensions.CreateValidationRule(x => false)
            .WithModeAtStartup(ValidationRuleStartupMode.Validate)
            .Enable();

            t.PropertyShouldBeNotified("IsValid", 1);
        }