public void GivenSubscriptionToTwoLevelPathToStruct_RetrievesTheCorrectValue()
        {
            var changeSource = new DummyViewModel { Child = new DummyViewModel { MyStruct = new MyStruct { Text = "My text" } } };
            var sut = new ObservablePropertyChain(changeSource, "Child.MyStruct.Text");

            Assert.Equal("My text", sut.Value);
        }
        public void SubscriptionToOneLevelPath()
        {
            var    changeSource = new DummyViewModel();
            var    sut          = new ObservablePropertyChain(changeSource, "Text");
            object actualText   = null;

            sut.Subscribe(o => actualText = o);
            changeSource.Text             = "Hello world";

            Assert.Equal("Hello world", 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.Equal("Hello world", actualText);
        }
        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.Equal("This is the real thing", actualText);
        }
        public void GivenSubscriptionToTwoLevelPath_WhenRootChangesButValuesAreSame_NoNotificationAreReceived()
        {
            var changeSource = new DummyViewModel { Child = new DummyViewModel { Text = "Same" } };
            var sut = new ObservablePropertyChain(changeSource, "Child.Text");

            var hit = false;
            sut.Subscribe(o => hit = true);
            changeSource.Child = new DummyViewModel { Text = "Same" };

            Assert.False(hit);
        }
        public void GivenSubscriptionToTwoLevelPathToStruct_RetrievesTheCorrectValue()
        {
            var changeSource = new DummyViewModel {
                Child = new DummyViewModel {
                    MyStruct = new MyStruct {
                        Text = "My text"
                    }
                }
            };
            var sut = new ObservablePropertyChain(changeSource, "Child.MyStruct.Text");

            Assert.Equal("My text", sut.Value);
        }
        public void GivenSubscriptionToTwoLevelPath_WhenRootChangesInDifferentSteps_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();
            changeSource.Child.Text       = "This is the real thing";

            Assert.Equal("This is the real thing", actualText);
        }
        public void GivenSubscriptionToTwoLevelPath_WhenRootChangesButValuesAreSame_NoNotificationAreReceived()
        {
            var changeSource = new DummyViewModel {
                Child = new DummyViewModel {
                    Text = "Same"
                }
            };
            var sut = new ObservablePropertyChain(changeSource, "Child.Text");

            var hit = false;

            sut.Subscribe(o => hit = true);
            changeSource.Child     = new DummyViewModel {
                Text = "Same"
            };

            Assert.False(hit);
        }