public void ValidateRegistryValue(RegistryHive hive, string subKeyName, string name, string expectedValue)
        {
            var actualValue = _mockRegManager.GetValue(hive, subKeyName, name);

            var validationPassed = string.Equals(expectedValue, actualValue, StringComparison.OrdinalIgnoreCase);

            Assert.True(validationPassed, $"Validation failed for '{subKeyName}\\{name}'. Expected - {expectedValue} Actual - {actualValue}");
        }
Example #2
0
        public void VerifyRegistryChanges(string securityId)
        {
            ValidateRegistryValue(RegistryHive.LocalMachine,
                                  RegistryConstants.MachineSettings.SubKeys.AutoLogon,
                                  RegistryConstants.MachineSettings.ValueNames.AutoLogon,
                                  "1");

            ValidateRegistryValue(RegistryHive.LocalMachine,
                                  RegistryConstants.MachineSettings.SubKeys.AutoLogon,
                                  RegistryConstants.MachineSettings.ValueNames.AutoLogonUserName,
                                  _userName);

            ValidateRegistryValue(RegistryHive.LocalMachine,
                                  RegistryConstants.MachineSettings.SubKeys.AutoLogon,
                                  RegistryConstants.MachineSettings.ValueNames.AutoLogonDomainName,
                                  _domainName);

            ValidateRegistryValue(RegistryHive.LocalMachine,
                                  RegistryConstants.MachineSettings.SubKeys.AutoLogon,
                                  RegistryConstants.MachineSettings.ValueNames.AutoLogonPassword,
                                  null);

            ValidateRegistryValue(RegistryHive.Users,
                                  $"{securityId}\\{RegistryConstants.UserSettings.SubKeys.ScreenSaver}",
                                  RegistryConstants.UserSettings.ValueNames.ScreenSaver,
                                  "0");

            // verify the startup process key is defined and contains --once if appropriate
            var startup = _mockRegManager.GetValue(
                RegistryHive.Users,
                $"{securityId}\\{RegistryConstants.UserSettings.SubKeys.StartupProcess}",
                RegistryConstants.UserSettings.ValueNames.StartupProcess);

            Assert.False(String.IsNullOrEmpty(startup), "Startup key should not be empty");

            Assert.True(startup.Contains(_runOnce), "Startup key should match the runOnce setting");
        }