Beispiel #1
0
        public void DerivedDependencyObjectObservableForPropertySmokeTest()
        {
            var fixture = new DerivedDepObjFixture();
            var binder  = new DependencyObjectObservableForProperty();

            Assert.NotEqual(0, binder.GetAffinityForObject(typeof(DerivedDepObjFixture), "TestString"));
            Assert.Equal(0, binder.GetAffinityForObject(typeof(DerivedDepObjFixture), "DoesntExist"));

            var results = new List <IObservedChange <object, object?> >();
            Expression <Func <DerivedDepObjFixture, object> > expression = x => x.TestString;
            var propertyName = expression.Body.GetMemberInfo()?.Name;

            if (propertyName is null)
            {
                throw new InvalidOperationException("There is no valid property name");
            }

            var disp1 = binder.GetNotificationForProperty(fixture, expression.Body, propertyName).WhereNotNull().Subscribe(results.Add);
            var disp2 = binder.GetNotificationForProperty(fixture, expression.Body, propertyName).WhereNotNull().Subscribe(results.Add);

            fixture.TestString = "Foo";
            fixture.TestString = "Bar";

            Assert.Equal(4, results.Count);

            disp1.Dispose();
            disp2.Dispose();
        }
Beispiel #2
0
        public void DependencyObjectObservableForPropertySmokeTest()
        {
            var fixture = new DepObjFixture();
            var binder  = new DependencyObjectObservableForProperty();

            Assert.NotEqual(0, binder.GetAffinityForObject(typeof(DepObjFixture)));

            var results = new List <IObservedChange <object, object> >();
            var disp1   = binder.GetNotificationForProperty(fixture, "TestString").Subscribe(results.Add);
            var disp2   = binder.GetNotificationForProperty(fixture, "TestString").Subscribe(results.Add);

            fixture.TestString = "Foo";
            fixture.TestString = "Bar";

            Assert.Equal(4, results.Count);

            disp1.Dispose();
            disp2.Dispose();
        }