public void DoubleSimple() { var n = new DependencyNode(); var e = new Entity { Child = new Entity() }; n.Subscribe(e); n.AddPropertyDependency(new[] { "Number" }, null, "a"); n.AddPropertyDependency(new[] { "Number" }, null, "a"); e.PropertyChangeSubscriptionCountShouldEqual(2); e.Child.PropertyChangeSubscriptionCountShouldEqual(1); n.Unsubscribe(); e.PropertyChangeSubscriptionCountShouldEqual(1); e.Child.PropertyChangeSubscriptionCountShouldEqual(1); }
public void AllProperties() { var n = new DependencyNode(); var e = new Entity { Child = new Entity() }; n.Subscribe(e); var c = new ExecutionCounter(); n.AddPropertyDependency("*", s => c.Execute(), "x"); e.Name = "abc"; e.Number2 = 4; //e.Collection.Add(new Entity()); c.Counter.ShouldEqual(2); }
public void Collection2() { var n = new DependencyNode(); var e = new Entity { Child = new Entity() }; e.Collection.Add(new Entity()); n.Subscribe(e); n.AddPropertyDependency("$Collection", delegate { }, "a"); e.PropertyChangeSubscriptionCountShouldEqual(2); e.Collection[0].PropertyChangeSubscriptionCountShouldEqual(2); n.Unsubscribe(); e.PropertyChangeSubscriptionCountShouldEqual(1); e.Collection[0].PropertyChangeSubscriptionCountShouldEqual(1); }
public void CollectionAddNestedWithNull() { var n = new DependencyNode(); var e = new Entity { Child = new Entity() }; n.Subscribe(e); n.AddPropertyDependency("Collection$Child.Name", delegate { }, "a"); e.Collection.Add(new Entity()); e.PropertyChangeSubscriptionCountShouldEqual(2); e.Collection[0].PropertyChangeSubscriptionCountShouldEqual(2); e.Collection[0].Child = new Entity(); e.Collection[0].Child.PropertyChangeSubscriptionCountShouldEqual(2); n.Unsubscribe(); e.PropertyChangeSubscriptionCountShouldEqual(1); e.Collection[0].PropertyChangeSubscriptionCountShouldEqual(1); e.Collection[0].Child.PropertyChangeSubscriptionCountShouldEqual(1); }
public void CollectionRemove() { var n = new DependencyNode(); var e = new Entity { Child = new Entity() }; var child = new Entity(); e.Collection.Add(child); n.Subscribe(e); n.AddPropertyDependency("Collection$Name", delegate { }, "a"); e.PropertyChangeSubscriptionCountShouldEqual(2); child.PropertyChangeSubscriptionCountShouldEqual(2); e.Collection.RemoveAt(0); child.PropertyChangeSubscriptionCountShouldEqual(1); n.Unsubscribe(); e.PropertyChangeSubscriptionCountShouldEqual(1); }