public void RegistryDeleteSubKeyTest() { var helper = new RegistryWrapper(); helper.WriteSubKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Charlie", RegistryWrapper.RegistryVersion.Only64Bit); helper.DeleteSubKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Charlie", RegistryWrapper.RegistryVersion.Only64Bit); Assert.IsTrue(helper.ReadKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE\Charlie", RegistryWrapper.RegistryVersion.Only64Bit)._64BitValues.Count == 0); }
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); }