public void RegistryWriteValueTo64Test() { var helper = new RegistryWrapper(); helper.WriteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit, new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("TestKey1", "TestValue1") }); Assert.IsNotNull(helper.ReadKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit)._64BitValues); helper.DeleteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", "TestKey1", RegistryWrapper.RegistryVersion.Only64Bit); }
public void RegistryDeleteValueTest() { 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 RegistryWriteValueTest() { var helper = new RegistryWrapper(); helper.WriteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit, new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>("Alice", "Allison"), new KeyValuePair <string, object>("Bob", "Boberson") }); Assert.IsNotNull(helper.ReadKey(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", RegistryWrapper.RegistryVersion.Only64Bit)._64BitValues, "Write failed, value does not exist after write attempt"); helper.DeleteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", @"Alice", RegistryWrapper.RegistryVersion.Only64Bit); helper.DeleteValue(RegistryWrapper.RegistryKeyRoot.LocalMachine, @"SOFTWARE", @"Bob", RegistryWrapper.RegistryVersion.Only64Bit); }
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 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); }