public void Binding_Overridden_Validated_Direct_Property_Calls_UpdateDataValidation() { var target = new Class2(); var source = new Subject <BindingValue <int> >(); // Class2 overrides `NonValidatedDirectProperty`'s metadata to enable data validation. target.Bind(Class1.NonValidatedDirectProperty, source); source.OnNext(1); Assert.Equal(1, target.Notifications.Count); }
public void Bind_Binds_AddOwnered_Property_Value_NonGeneric() { var target = new Class2(); var source = new Subject <string>(); var sub = target.Bind((AvaloniaProperty)Class1.FooProperty, source); Assert.Equal("initial2", target.Foo); source.OnNext("first"); Assert.Equal("first", target.Foo); source.OnNext("second"); Assert.Equal("second", target.Foo); sub.Dispose(); source.OnNext("third"); Assert.Equal("second", target.Foo); }
public void Binding_To_Direct_Property_Does_Not_Get_Collected() { var target = new Class2(); Func <WeakReference> setupBinding = () => { var source = new Subject <string>(); var sub = target.Bind((AvaloniaProperty)Class1.FooProperty, source); source.OnNext("foo"); return(new WeakReference(source)); }; var weakSource = setupBinding(); GC.Collect(); Assert.Equal("foo", target.Foo); Assert.True(weakSource.IsAlive); }
public void Binding_To_Direct_Property_Gets_Collected_When_Completed() { var target = new Class2(); Func <WeakReference> setupBinding = () => { var source = new Subject <string>(); var sub = target.Bind((AvaloniaProperty)Class1.FooProperty, source); return(new WeakReference(source)); }; var weakSource = setupBinding(); Action completeSource = () => { ((ISubject <string>)weakSource.Target).OnCompleted(); }; completeSource(); GC.Collect(); Assert.False(weakSource.IsAlive); }