public void ByteViewer_OnLayout_InvokeWithHandle_CallsLayout(LayoutEventArgs eventArgs) { using var control = new SubByteViewer(); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; int callCount = 0; LayoutEventHandler handler = (sender, e) => { Assert.Same(control, sender); Assert.Same(eventArgs, e); callCount++; }; // Call with handler. control.Layout += handler; control.OnLayout(eventArgs); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); Assert.Equal(1, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); // Remove handler. control.Layout -= handler; control.OnLayout(eventArgs); Assert.Equal(1, callCount); Assert.True(control.IsHandleCreated); Assert.Equal(2, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public void ByteViewer_OnLayout_Invoke_CallsLayout(LayoutEventArgs eventArgs) { using var control = new SubByteViewer(); int callCount = 0; LayoutEventHandler handler = (sender, e) => { Assert.Same(control, sender); Assert.Same(eventArgs, e); callCount++; }; // Call with handler. control.Layout += handler; control.OnLayout(eventArgs); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); // Remove handler. control.Layout -= handler; control.OnLayout(eventArgs); Assert.Equal(1, callCount); Assert.False(control.IsHandleCreated); }
public void ByteViewer_OnLayout_InvokeNullE_ThrowsNullReferenceException() { using var control = new SubByteViewer(); Assert.Throws <NullReferenceException>(() => control.OnLayout(null)); }