public void Can_Bind_Completed_Binding_Back_To_Original_Value_When_Ending_Batch_Update() { var target = new TestClass(); var raised = 0; var notifications = new List <AvaloniaPropertyChangedEventArgs>(); var observable1 = new TestObservable <string>("foo"); var observable2 = new TestObservable <string>("foo"); target.Bind(TestClass.FooProperty, observable1); target.BeginBatchUpdate(); observable1.OnCompleted(); target.PropertyChanged += (sender, e) => { if (e.Property == TestClass.FooProperty && e.NewValue is null) { target.Bind(TestClass.FooProperty, observable2); ++raised; } notifications.Add(e); }; target.EndBatchUpdate(); Assert.Equal("foo", target.Foo); Assert.Equal(1, raised); Assert.Equal(2, notifications.Count); Assert.Equal(null, notifications[0].NewValue); Assert.Equal("foo", notifications[1].NewValue); }
public void Binding_Completion_Should_Not_Raise_Property_Changes_During_Batch_Update() { var target = new TestClass(); var observable = new TestObservable <string>("foo"); var raised = new List <string>(); target.Bind(TestClass.FooProperty, observable, BindingPriority.LocalValue); target.GetObservable(TestClass.FooProperty).Skip(1).Subscribe(x => raised.Add(x)); target.BeginBatchUpdate(); observable.OnCompleted(); Assert.Empty(raised); }
public void Binding_Completion_Should_Be_Raised_After_Batch_Update() { var target = new TestClass(); var observable = new TestObservable <string>("foo"); var raised = new List <AvaloniaPropertyChangedEventArgs>(); target.Bind(TestClass.FooProperty, observable, BindingPriority.LocalValue); target.PropertyChanged += (s, e) => raised.Add(e); target.BeginBatchUpdate(); observable.OnCompleted(); target.EndBatchUpdate(); Assert.Equal(1, raised.Count); Assert.Null(target.Foo); Assert.Equal("foo", raised[0].OldValue); Assert.Null(raised[0].NewValue); Assert.Equal(BindingPriority.Unset, raised[0].Priority); }