private void VerifyBoxes(TabBase tab, RegistryHelper reg, bool inverse, OpenTarget target, Tabs.GlobalState consoleVersion) { // get the key for the current target RegistryKey consoleKey = reg.GetMatchingKey(target); // hold the parent console key in case we need to look things up for specifics. RegistryKey parentConsoleKey = reg.GetMatchingKey(OpenTarget.Defaults); // include the global checkbox in the set for verification purposes IEnumerable <CheckBoxMeta> boxes = tab.GetCheckboxesForVerification(); AutoHelpers.LogInvariant("Testing target: {0} in inverse {1} mode", target.ToString(), inverse.ToString()); // If we're opened as specifics, remove all global only boxes from the test set if (target == OpenTarget.Specifics) { AutoHelpers.LogInvariant("Reducing"); boxes = boxes.Where(box => !box.IsGlobalOnly); } foreach (CheckBoxMeta meta in boxes) { int?storedValue = consoleKey.GetValue(meta.ValueName) as int?; string boxName = AutoHelpers.FormatInvariant("Box: {0}", meta.ValueName); // if we're in specifics mode, we might have a null and if so, we check the parent value if (target == OpenTarget.Specifics) { if (storedValue == null) { AutoHelpers.LogInvariant("Specific setting missing. Checking defaults."); storedValue = parentConsoleKey.GetValue(meta.ValueName) as int?; } } else { Verify.IsNotNull(storedValue, boxName); } if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property) { AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName); } else { // A box can be inverse if checking it means false in the registry. // This method can be inverse if we're turning off the boxes and expecting it to be on. // Therefore, a box will be false if it's checked and supposed to be off. Or if it's unchecked and supposed to be on. if ((meta.IsInverse && !inverse) || (!meta.IsInverse && inverse)) { Verify.IsFalse(storedValue.Value.DwordToBool(), boxName); } else { Verify.IsTrue(storedValue.Value.DwordToBool(), boxName); } } } }
private void VerifyBoxes(TabBase tab, ShortcutHelper shortcut, bool inverse, Tabs.GlobalState consoleVersion) { IEnumerable <CheckBoxMeta> boxes = tab.GetCheckboxesForVerification(); // collect up properties that we need to retrieve keys for IEnumerable <CheckBoxMeta> propBoxes = boxes.Where(box => box.PropKey != null); IEnumerable <Wtypes.PROPERTYKEY> keys = propBoxes.Select(box => box.PropKey).Cast <Wtypes.PROPERTYKEY>(); // fetch data for keys IDictionary <Wtypes.PROPERTYKEY, object> propertyData = shortcut.GetFromPropertyStore(keys); // enumerate each box and validate the data foreach (CheckBoxMeta meta in propBoxes) { string boxName = AutoHelpers.FormatInvariant("Box: {0}", meta.ValueName); Wtypes.PROPERTYKEY key = (Wtypes.PROPERTYKEY)meta.PropKey; bool?value = (bool?)propertyData[key]; Verify.IsNotNull(value, boxName); if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property) { AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName); } else { // A box can be inverse if checking it means false in the registry. // This method can be inverse if we're turning off the boxes and expecting it to be on. // Therefore, a box will be false if it's checked and supposed to be off. Or if it's unchecked and supposed to be on. if ((meta.IsInverse && !inverse) || (!meta.IsInverse && inverse)) { Verify.IsFalse(value.Value, boxName); } else { Verify.IsTrue(value.Value, boxName); } } } }