public void RegistryDeleteValueFrom64Test() { var helper = new RegistryWrapper(); helper.WriteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit, new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("TestKey", "TestValue") }); helper.DeleteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", "TestKey", RegistryWrapper.RegistryVersion.Only64Bit); Assert.IsFalse(helper.ReadKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit) ._64BitValues. Contains(new KeyValuePair <string, object>("TestKey", "TestValue")), "Given key still contains value after delete attempt."); }
public void RegistryWriteToBothTest() { var helper = new RegistryWrapper(); helper.WriteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Test\TestLayer2", RegistryWrapper.RegistryVersion.Both, new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("Alice", "Allison"), new KeyValuePair <string, object>("Bob", "Boberson") }); var result = helper.ReadKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Test\TestLayer2", RegistryWrapper.RegistryVersion.Both); Assert.IsTrue(result._64BitValues.Contains(new KeyValuePair <string, object>("Alice", "Allison"))); Assert.IsTrue(result._32BitValues.Contains(new KeyValuePair <string, object>("Alice", "Allison"))); helper.DeleteSubKeyTree(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Test", RegistryWrapper.RegistryVersion.Both); }
public void GetSubKeyNamesTest() { var helper = new RegistryWrapper(); var result = helper.ReadKey(@"HKEY_LOCAL_MACHINE\SOFTWARE", RegistryWrapper.RegistryVersion.Both); Assert.IsTrue(result._64BitSubKeyNames.Length > 0); Assert.IsTrue(result._32BitSubKeyNames.Length > 0); foreach (var item in result._64BitSubKeyNames) { Debug.WriteLine(item); } Debug.WriteLine("\n32 bit subkeys:\n"); foreach (var item in result._32BitSubKeyNames) { Debug.WriteLine(item); } }
public void DeleteSubKeyWithSubKeyTreeFrom64Test() { var helper = new RegistryWrapper(); helper.WriteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Test\TestLayer2", RegistryWrapper.RegistryVersion.Only64Bit, new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("Alice", "Allison"), new KeyValuePair <string, object>("Bob", "Boberson") }); try { helper.DeleteSubKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Test", RegistryWrapper.RegistryVersion.Only64Bit); } catch (InvalidOperationException) { Debug.WriteLine("Threw expected exception because given key has subKeys."); helper.DeleteSubKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Test", RegistryWrapper.RegistryVersion.Only64Bit, true); } Assert.IsTrue(helper.ReadKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Test", RegistryWrapper.RegistryVersion.Only64Bit). _64BitValues.Count == 0); }
public void RegistryReadTest() { var helper = new RegistryWrapper(); helper.WriteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit, new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("TestKey1", "TestValue1") }); var result = helper.ReadKey(@"HKEY_LOCAL_MACHINE\SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit); foreach (var item in result._64BitValues) { Debug.WriteLine("Key: " + item.Key + " Value: " + item.Value); } Assert.IsNotNull(result, "The given key has no values"); Assert.IsTrue(result._64BitValues.Count > 0); helper.DeleteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", @"TestKey1", RegistryWrapper.RegistryVersion.Only64Bit); }