public void ComponentEditorForm_OnHandleDestroyed_InvokeWithHandle_CallsHandleDestroyed(EventArgs eventArgs) { using var component = new Component(); using var control = new SubComponentEditorForm(component, Array.Empty <Type>()); Assert.NotEqual(IntPtr.Zero, control.Handle); int callCount = 0; EventHandler handler = (sender, e) => { Assert.Same(control, sender); Assert.Same(eventArgs, e); callCount++; }; // Call with handler. control.HandleDestroyed += handler; control.OnHandleDestroyed(eventArgs); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); // Remove handler. control.HandleDestroyed -= handler; control.OnHandleDestroyed(eventArgs); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); }
public void ComponentEditorForm_OnHandleDestroyed_Invoke_CallsHandleDestroyed(EventArgs eventArgs) { using var component = new Component(); using var control = new SubComponentEditorForm(component, new Type[0]); int callCount = 0; EventHandler handler = (sender, e) => { Assert.Same(control, sender); Assert.Same(eventArgs, e); callCount++; }; // Call with handler. control.HandleDestroyed += handler; control.OnHandleDestroyed(eventArgs); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); // Remove handler. control.HandleDestroyed -= handler; control.OnHandleDestroyed(eventArgs); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); }