コード例 #1
0
        public void When_Subscribe_Via_Interface_To_Poco_Source_Then_OnNext_Initial_Value_Only()
        {
            // Arrange
            var obj = new TestPoco {Age = 3} as ITestObject;
            var scheduler = new TestScheduler();
            var observer = scheduler.CreateObserver<IPropertyValueChanged<int>>();
            var expected = new[]
            {
                OnNext(000, PropertyValueChanged.CreateWithValue(obj, "Age", 3)),
            };

            var sut = obj.When(x => x.Age);

            // Act
            sut.Subscribe(observer);
            scheduler.AdvanceTo(10);
            obj.Age = 5;

            // Assert
            Assert.AreEqual(expected, observer.Messages);
        }
コード例 #2
0
        public void When_Subscribe_With_One_Node_Path_To_Property_Then_OnNext_Changes()
        {
            // Arrange
            var obj = new TestPoco() {Age = 5};
            var scheduler = new TestScheduler();
            var observer = scheduler.CreateObserver<IPropertyValueChanged<int>>();
            var expected = new[]
            {
                OnNext(000, PropertyValueChanged.CreateWithValue(obj, "Age", 5)),
            };

            var sut = obj.When(x => x.Age);

            // Act
            sut.Subscribe(observer);
            obj.Age = 3; // This should not fire through.

            // Assert
            Assert.AreEqual(expected, observer.Messages);
        }