public void Binding_OnBindingComplete_Invoke_CallsBindingComplete(BindingCompleteEventArgs eventArgs) { var binding = new SubBinding("propertyName", new object(), "dataMember"); // No handler. binding.OnBindingComplete(eventArgs); // Handler. int callCount = 0; BindingCompleteEventHandler handler = (sender, e) => { Assert.Equal(binding, sender); Assert.Same(eventArgs, e); callCount++; }; binding.BindingComplete += handler; binding.OnBindingComplete(eventArgs); Assert.Equal(1, callCount); // Should not call if the handler is removed. binding.BindingComplete -= handler; binding.OnBindingComplete(eventArgs); Assert.Equal(1, callCount); }
public void Binding_OnBindingComplete_InvokeInsideBindingComplete_DoesNotCallBindingComplete(BindingCompleteEventArgs eventArgs) { var binding = new SubBinding("propertyName", new object(), "dataMember"); int callCount = 0; BindingCompleteEventHandler handler = (sender, e) => { Assert.Equal(binding, sender); Assert.Same(eventArgs, e); callCount++; binding.OnBindingComplete(e); }; binding.BindingComplete += handler; binding.OnBindingComplete(eventArgs); Assert.Equal(1, callCount); }
public void Binding_OnBindingComplete_ThrowsNonCriticalException_SetsCancelToTrue(BindingCompleteEventArgs eventArgs, Exception exception) { var binding = new SubBinding("propertyName", new object(), "dataMember"); int callCount = 0; BindingCompleteEventHandler handler = (sender, e) => { Assert.Equal(binding, sender); Assert.Same(eventArgs, e); callCount++; throw exception; }; binding.BindingComplete += handler; binding.OnBindingComplete(eventArgs); if (eventArgs != null) { Assert.True(eventArgs.Cancel); } Assert.Equal(1, callCount); }