Example #1
0
 public void FontDialog_Ctor_Default()
 {
     using var dialog = new SubFontDialog();
     Assert.True(dialog.AllowScriptChange);
     Assert.True(dialog.AllowSimulations);
     Assert.True(dialog.AllowVectorFonts);
     Assert.True(dialog.AllowVerticalFonts);
     Assert.True(dialog.CanRaiseEvents);
     Assert.Equal(Color.Black, dialog.Color);
     Assert.Null(dialog.Container);
     Assert.False(dialog.DesignMode);
     Assert.NotNull(dialog.Events);
     Assert.Same(dialog.Events, dialog.Events);
     Assert.False(dialog.FixedPitchOnly);
     Assert.Equal(Control.DefaultFont, dialog.Font);
     Assert.False(dialog.FontMustExist);
     Assert.Equal(0, dialog.MaxSize);
     Assert.Equal(0, dialog.MinSize);
     Assert.Equal(0x40101, dialog.Options);
     Assert.False(dialog.ScriptsOnly);
     Assert.False(dialog.ShowApply);
     Assert.False(dialog.ShowColor);
     Assert.True(dialog.ShowEffects);
     Assert.False(dialog.ShowHelp);
     Assert.Null(dialog.Site);
     Assert.Null(dialog.Tag);
 }
Example #2
0
        public void FontDialog_HookProc_Invoke_InvalidCommandHWnd(bool showColor)
        {
            using var dialog = new SubFontDialog
                  {
                      ShowColor = showColor
                  };
            int applyCallCount = 0;

            dialog.Apply += (sender, e) => applyCallCount++;
            Assert.Throws <ArgumentException>(null, () => dialog.HookProc(IntPtr.Zero, (int)User32.WM.COMMAND, (IntPtr)0x402, IntPtr.Zero));
        }
Example #3
0
        public void FontDialog_HookProc_Invoke_ReturnsZero(bool showColor, int msg, IntPtr wparam)
        {
            using var dialog = new SubFontDialog
                  {
                      ShowColor = showColor
                  };
            int applyCallCount = 0;

            dialog.Apply += (sender, e) => applyCallCount++;
            Assert.Equal(IntPtr.Zero, dialog.HookProc(IntPtr.Zero, msg, wparam, IntPtr.Zero));
            Assert.Equal(0, applyCallCount);
        }
Example #4
0
        public void FontDialog_HookProc_InvokeWithHWnd_ReturnsZero(bool showColor, int msg, IntPtr wparam, int expectedApplyCallCount)
        {
            using var control = new CustomClass();
            using var dialog  = new SubFontDialog
                  {
                      ShowColor = showColor
                  };
            int applyCallCount = 0;

            dialog.Apply += (sender, e) => applyCallCount++;
            Assert.Equal(IntPtr.Zero, dialog.HookProc(control.Handle, msg, wparam, IntPtr.Zero));
            Assert.Equal(expectedApplyCallCount, applyCallCount);
        }
Example #5
0
        public void FontDialog_Reset_Invoke_Success()
        {
            using var font   = new Font("Arial", 8.25f);
            using var dialog = new SubFontDialog
                  {
                      AllowScriptChange  = false,
                      AllowSimulations   = false,
                      AllowVectorFonts   = false,
                      AllowVerticalFonts = false,
                      FixedPitchOnly     = true,
                      Font          = font,
                      FontMustExist = true,
                      MaxSize       = 10,
                      MinSize       = 5,
                      ScriptsOnly   = true,
                      ShowApply     = true,
                      ShowColor     = true,
                      ShowEffects   = false,
                      ShowHelp      = true,
                      Tag           = "Tag",
                  };

            dialog.Reset();
            Assert.True(dialog.AllowScriptChange);
            Assert.True(dialog.AllowSimulations);
            Assert.True(dialog.AllowVectorFonts);
            Assert.True(dialog.AllowVerticalFonts);
            Assert.True(dialog.CanRaiseEvents);
            Assert.Equal(Color.Black, dialog.Color);
            Assert.Null(dialog.Container);
            Assert.False(dialog.DesignMode);
            Assert.NotNull(dialog.Events);
            Assert.Same(dialog.Events, dialog.Events);
            Assert.False(dialog.FixedPitchOnly);
            Assert.Equal(Control.DefaultFont, dialog.Font);
            Assert.False(dialog.FontMustExist);
            Assert.Equal(0, dialog.MaxSize);
            Assert.Equal(0, dialog.MinSize);
            Assert.Equal(0x40101, dialog.Options);
            Assert.False(dialog.ScriptsOnly);
            Assert.False(dialog.ShowApply);
            Assert.False(dialog.ShowColor);
            Assert.True(dialog.ShowEffects);
            Assert.False(dialog.ShowHelp);
            Assert.Null(dialog.Site);
            Assert.Equal("Tag", dialog.Tag);
        }
Example #6
0
        public void FontDialog_AllowScriptChange_Set_GetReturnsExpected(bool value, int expectedOptions, int expectedOptionsAfter)
        {
            using var dialog = new SubFontDialog
                  {
                      AllowScriptChange = value
                  };
            Assert.Equal(value, dialog.AllowScriptChange);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set same.
            dialog.AllowScriptChange = value;
            Assert.Equal(value, dialog.AllowScriptChange);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set different.
            dialog.AllowScriptChange = !value;
            Assert.Equal(!value, dialog.AllowScriptChange);
            Assert.Equal(expectedOptionsAfter, dialog.Options);
        }
Example #7
0
        public void FontDialog_ShowHelp_Set_GetReturnsExpected(bool value, int expectedOptions, int expectedOptionsAfter)
        {
            using var dialog = new SubFontDialog
                  {
                      ShowHelp = value
                  };
            Assert.Equal(value, dialog.ShowHelp);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set same.
            dialog.ShowHelp = value;
            Assert.Equal(value, dialog.ShowHelp);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set different.
            dialog.ShowHelp = !value;
            Assert.Equal(!value, dialog.ShowHelp);
            Assert.Equal(expectedOptionsAfter, dialog.Options);
        }
Example #8
0
        public void FontDialog_FontMustExist_Set_GetReturnsExpected(bool value, int expectedOptions, int expectedOptionsAfter)
        {
            using var dialog = new SubFontDialog
                  {
                      FontMustExist = value
                  };
            Assert.Equal(value, dialog.FontMustExist);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set same.
            dialog.FontMustExist = value;
            Assert.Equal(value, dialog.FontMustExist);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set different.
            dialog.FontMustExist = !value;
            Assert.Equal(!value, dialog.FontMustExist);
            Assert.Equal(expectedOptionsAfter, dialog.Options);
        }
Example #9
0
        public void FontDialog_FixedPitchOnly_Set_GetReturnsExpected(bool value, int expectedOptions, int expectedOptionsAfter)
        {
            using var dialog = new SubFontDialog
                  {
                      FixedPitchOnly = value
                  };
            Assert.Equal(value, dialog.FixedPitchOnly);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set same.
            dialog.FixedPitchOnly = value;
            Assert.Equal(value, dialog.FixedPitchOnly);
            Assert.Equal(expectedOptions, dialog.Options);

            // Set different.
            dialog.FixedPitchOnly = !value;
            Assert.Equal(!value, dialog.FixedPitchOnly);
            Assert.Equal(expectedOptionsAfter, dialog.Options);
        }
Example #10
0
        public void FontDialog_OnApply_Invoke_CallsApply(EventArgs eventArgs)
        {
            using var dialog = new SubFontDialog();
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(dialog, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            dialog.Apply += handler;
            dialog.OnApply(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            dialog.Apply -= handler;
            dialog.OnApply(eventArgs);
            Assert.Equal(1, callCount);
        }
Example #11
0
 public void FontDialog_ToString_Invoke_ReturnsExpected()
 {
     using var dialog = new SubFontDialog();
     Assert.Equal($"System.Windows.Forms.Tests.FontDialogTests+SubFontDialog,  Font: {Control.DefaultFont}", dialog.ToString());
 }