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.AreEqual("My text", sut.Value);
        }
        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 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.IsFalse(hit);
        }
        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);
        }
Example #5
0
        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.AreEqual("Hello world", actualText);
        }
Example #6
0
        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.AreEqual("My text", sut.Value);
        }
Example #7
0
        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.AreEqual("This is the real thing", actualText);
        }
Example #8
0
        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.IsFalse(hit);
        }