示例#1
0
        // Uses reflection to test each LogFont and Boolean style (italic, underline, etc) combinaton. Each style is toggled to true then false.
        public void TestBooleanLogFontStyles()
        {
            foreach (var logFontProperty in typeof(NonClientMetrics).GetProperties())
            {
                if (logFontProperty.PropertyType.Name != "LogFont")
                {
                    continue;
                }

                foreach (var booleanStyleProperty in typeof(LogFont).GetProperties())
                {
                    if (booleanStyleProperty.PropertyType.Name != "Boolean")
                    {
                        continue;
                    }

                    Logger.Debug("Testing NonClientMetrics." + logFontProperty.Name + "." + booleanStyleProperty.Name);
                    var ncm = new NonClientMetrics();
                    booleanStyleProperty.SetValue(((LogFont)logFontProperty.GetValue(ncm)), true);
                    ncm.Apply();
                    Assert((bool)booleanStyleProperty.GetValue(((LogFont)logFontProperty.GetValue(new NonClientMetrics()))) == true);
                    booleanStyleProperty.SetValue(((LogFont)logFontProperty.GetValue(ncm)), false);
                    ncm.Apply();
                    Assert((bool)booleanStyleProperty.GetValue(((LogFont)logFontProperty.GetValue(new NonClientMetrics()))) == false);
                }
            }
        }
示例#2
0
        public async Task <object> SetNonClientMetrics(dynamic input)
        {
            var ncm = new NonClientMetrics();

            ncm.UseSettings(input);
            ncm.Apply();
            return(new NonClientMetrics());
        }
示例#3
0
        public async Task <object> SetScrollWidth(dynamic input)
        {
            int scrollWidth      = (int)input.scrollWidth;
            NonClientMetrics ncm = new NonClientMetrics();

            ncm.ScrollWidth = scrollWidth;
            ncm.Apply();
            return(new NonClientMetrics().ScrollWidth);
        }
示例#4
0
        /// <summary>
        /// Sets a Int32 property of a NonClientMetrics instance to a value, verifies, and restores original value
        /// </summary>
        /// <param name="p">PropertyInfo instance to test (must be a Int32 type)</param>
        /// <param name="newValue">Value the property will be set to</param>
        private void TestInt32Property(PropertyInfo p, int newValue)
        {
            // Obtain a NCM instance and record the original value
            var ncm           = new NonClientMetrics();
            var originalValue = (int)p.GetValue(ncm);

            // Set the new value
            p.SetValue(ncm, newValue);
            ncm.Apply();

            // Assert the new value was set
            Assert((int)p.GetValue(new NonClientMetrics()) == newValue);

            // Restore the original
            p.SetValue(ncm, originalValue);
            ncm.Apply();

            // Assert the original setting was restored
            Assert((int)p.GetValue(new NonClientMetrics()) == originalValue);
        }
示例#5
0
        // Tests a profile matching the GPII unit test for NonClientMetrics
        public void TestProfile()
        {
            Logger.Debug("Testing a sample profile");
            // Save original settings
            var ncmOriginal = new NonClientMetrics();

            // Change settings
            var ncm = new NonClientMetrics();

            ncm.ScrollWidth                  = 30;
            ncm.ScrollHeight                 = 30;
            ncm.CaptionFont.IsItalic         = true;
            ncm.SmallCaptionFont.IsUnderline = true;
            ncm.MenuFont.IsItalic            = true;
            ncm.MenuFont.IsUnderline         = true;
            ncm.Apply();

            // Test settings were saved in system. We use the ncmAssert instance for assertions
            var ncmAssert = new NonClientMetrics();

            Assert(ncmAssert.ScrollWidth == 30, "ScrollWidth should have been set");
            Assert(ncmAssert.ScrollHeight == 30, "ScrollHeight should have been set");
            Assert(ncmAssert.CaptionFont.IsItalic == true, "CaptionFont should be Italic");
            Assert(ncmAssert.SmallCaptionFont.IsUnderline == true, "SmallCaptionFont should be Underlined");
            Assert(ncmAssert.MenuFont.IsItalic == true, "MenuFont should be Italic");
            Assert(ncmAssert.MenuFont.IsUnderline == true, "MenuFont should be underlined");

            // Restore settings and verify
            ncmOriginal.Apply();
            ncmAssert = new NonClientMetrics();
            Assert(ncmAssert.ScrollHeight == ncmOriginal.ScrollHeight, "ScrollHeight should have been restored");
            Assert(ncmAssert.ScrollWidth == ncmOriginal.ScrollWidth, "ScrollWidth should have been restored");
            Assert(ncmAssert.CaptionFont.IsItalic == ncmOriginal.CaptionFont.IsItalic, "CaptionFont should have been restored");
            Assert(ncmAssert.SmallCaptionFont.IsUnderline == ncmOriginal.SmallCaptionFont.IsUnderline, "SmallCaptionFont should have been restored");
            Assert(ncmAssert.MenuFont.IsItalic == ncmOriginal.MenuFont.IsItalic, "MenuFont should have been restored (italics)");
            Assert(ncmAssert.MenuFont.IsUnderline == ncmOriginal.MenuFont.IsUnderline, "MenuFont should have been restored (underline)");
            // TODO: Should the equality logic be implemented in NonClientMetrics class so we can write (ncm1 == ncm2) in test code?
        }
示例#6
0
        public void TestUseOfDynamic()
        {
            dynamic settings = new ExpandoObject();

            settings.BorderWidth = 10;
            settings.ScrollWidth = 20;

            NonClientMetrics ncmOriginal = new NonClientMetrics();

            NonClientMetrics ncmModifier = new NonClientMetrics();

            ncmModifier.UseSettings(settings);
            ncmModifier.Apply();

            var ncmAssert = new NonClientMetrics();

            Assert(ncmAssert.BorderWidth == settings.BorderWidth);
            Assert(ncmAssert.ScrollWidth == settings.ScrollWidth);

            ncmOriginal.Apply();
            ncmAssert = new NonClientMetrics();
            Assert(ncmAssert.BorderWidth == ncmOriginal.BorderWidth);
            Assert(ncmAssert.ScrollWidth == ncmOriginal.ScrollWidth);
        }