OnCollapse() protected method

protected OnCollapse ( EventArgs e ) : void
e System.EventArgs
return void
Ejemplo n.º 1
0
        public void ContextMenu_OnCollapse_Invoke_Success()
        {
            var menu = new ContextMenu();

            // No handler.
            menu.OnCollapse(null);

            // Handler.
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Equal(menu, sender);
                callCount++;
            };

            menu.Collapse += handler;
            menu.OnCollapse(null);
            Assert.Equal(1, callCount);

            // Should not call if the handler is removed.
            menu.Collapse -= handler;
            menu.OnCollapse(null);
            Assert.Equal(1, callCount);
        }