public void GivenSubscriptionToTwoLevelPath_WhenRootChanges_NotificationsShouldArrive() { var changeSource = new DummyViewModel { Child = new DummyViewModel { Text = "Old text" } }; var sut = new ObservablePropertyChain(changeSource, "Child.Text"); object actualText = null; sut.Subscribe(o => actualText = o); changeSource.Child = new DummyViewModel { Text = "This is the real thing" }; Assert.AreEqual("This is the real thing", actualText); }
public void SubscriptionToTwoLevelPath() { var changeSource = new DummyViewModel { Child = new DummyViewModel() }; var sut = new ObservablePropertyChain(changeSource, "Child.Text"); object actualText = null; sut.Subscribe(o => actualText = o); changeSource.Child.Text = "Hello world"; Assert.AreEqual("Hello world", actualText); }
public void GivenSubscriptionToTwoLevelPath_WhenRootChangesButValuesAreSame_NoNotificationIsSent() { var changeSource = new DummyViewModel { Child = new DummyViewModel { Text = "Same" } }; var sut = new ObservablePropertyChain(changeSource, "Child.Text"); bool hit = false; sut.Subscribe(o => hit = true); changeSource.Child = new DummyViewModel { Text = "Same" }; Assert.IsFalse(hit); }