Ejemplo n.º 1
0
        public void MainForm_RecreateHandleWithThreadExit_DoesNotCallHandler()
        {
            var          mainForm  = new SubForm();
            var          context   = new ApplicationContext(mainForm);
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(context, sender);
                Assert.Same(EventArgs.Empty, e);
                callCount++;
            };

            context.ThreadExit += handler;

            Assert.NotEqual(IntPtr.Zero, mainForm.Handle);
            Assert.Equal(0, callCount);

            mainForm.RecreateHandle();
            Assert.Equal(0, callCount);

            // Call again.
            mainForm.RecreateHandle();
            Assert.Equal(0, callCount);
        }