public void PropertyManager_EndCurrentEdit_IEditableObjectCurrentNotSuccess_DoesNotCallEndEdit(bool cancel, int expectedCallCount) { int callCount = 0; var dataSource = new EditableDataSource { EndEditHandler = () => { callCount++; } }; var manager = new PropertyManager(dataSource); var control = new SubControl { Visible = true }; control.CreateControl(); var controlBindings = new ControlBindingsCollection(control); var cancelBinding = new Binding("Value", dataSource, "Property", true); BindingCompleteEventHandler bindingCompleteHandler = (sender, e) => { e.Cancel = cancel; }; cancelBinding.BindingComplete += bindingCompleteHandler; controlBindings.Add(cancelBinding); manager.Bindings.Add(cancelBinding); manager.EndCurrentEdit(); Assert.Equal(expectedCallCount, callCount); manager.EndCurrentEdit(); Assert.Equal(expectedCallCount * 2, callCount); }
public void ToolTip_SetToolTipToControl_Invokes_SetToolTip_OfControl() { using ToolTip toolTip = new ToolTip(); SubControl control = new SubControl(); control.CreateControl(); Assert.NotEqual(IntPtr.Zero, toolTip.Handle); // A workaroung to create the toolTip native window Handle toolTip.SetToolTip(control, "Some test text"); Assert.Equal(1, control.InvokeSetCount); }
public void ToolTip_RemoveAll_Invokes_RemoveToolTip_OfControl() { using ToolTip toolTip = new ToolTip(); using SubControl control = new SubControl(); // Create a top level control to the toolTip consider // the tested control as created when destroying regions using Control topLevelControl = new Control(); topLevelControl.Controls.Add(control); topLevelControl.CreateControl(); control.CreateControl(); Assert.True(toolTip.Handle != IntPtr.Zero); // A workaroung to create the toolTip native window Handle toolTip.SetToolTip(control, "Some test text"); toolTip.RemoveAll(); Assert.Equal(1, control.InvokeRemoveCount); }