OnPopup() protected method

protected OnPopup ( EventArgs e ) : void
e System.EventArgs
return void
Beispiel #1
0
        public void ContextMenu_OnPopup_Invoke_Success()
        {
            var menu = new ContextMenu();

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

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

            menu.Popup += handler;
            menu.OnPopup(null);
            Assert.Equal(1, callCount);

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