public void SetValueData_WithoutValueNameInPath() { var TestValueData = "Test Value Data"; AdvRegistry.SetValueData(ExistentKeyPath, TestValueData); Assert.AreEqual(TestValueData, AdvRegistry.GetValueData(ExistentKeyPath)); }
public void SetValueData_ExistentKeyNonexitentVal() { var TestValueData = "Test Value Data"; AdvRegistry.SetValueData(ExistentKey_NonexistentVal_Path, TestValueData); Assert.AreEqual(TestValueData, AdvRegistry.GetValueData(ExistentKey_NonexistentVal_Path)); }
private void treeRegistry_AfterExpand(object sender, TreeViewEventArgs e) { TreeNode CurrentTreeNode = e.Node; try { // Remove dummy node. CurrentTreeNode.Nodes["\\dummy"].Remove(); // Open key associated with current node. RegistryKey CurrentKey = AdvRegistry.OpenSubKey(CurrentTreeNode.FullPath); // Populate keys. foreach (String CurrentSubKeyName in CurrentKey.GetSubKeyNames()) { AddKey(CurrentTreeNode, CurrentSubKeyName); } // Populate values. foreach (String CurrentValueName in CurrentKey.GetValueNames()) { AddValue(CurrentTreeNode, CurrentValueName); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DeleteKey_ForExistentKeyWithSubkeys() { AdvRegistry.CreateKey(ExistentKeyPath + "\\Subkey1"); AdvRegistry.CreateKey(ExistentKeyPath + "\\Subkey2"); AdvRegistry.DeleteKey(ExistentKeyPath); Assert.IsFalse(AdvRegistry.IsKeyExists(ExistentKeyPath)); }
private static string[] ExpandFSPaths(Ruleset.PathsRow path) { var Result = new List <string>(); if (!AdvRegistry.IsRegistryPath(path.Path)) { Result.Add(AdvEnvironment.ExpandEnvironmentVariables(path.Path)); } return(Result.ToArray()); }
public void TestOpenSubKey() { // Is OpenSubKey able to open existent path? var key = AdvRegistry.OpenSubKey(ExistentKeyPath); Assert.AreEqual(key.Name, "HKEY_CURRENT_USER\\existent"); // Is OpenSubKey able to open path which contains only root element? key = AdvRegistry.OpenSubKey("HKLM"); Assert.AreEqual(Registry.LocalMachine, key); // When opening nonexistent path OpenSubKye must return null key = AdvRegistry.OpenSubKey(NonexistentKeyPath); Assert.IsNull(key); }
private static int Benchmark(Ruleset ruleset, int benchmarkTime) { int accessCounter = 0; var time = DateTime.Now.AddMinutes(benchmarkTime); while (DateTime.Now < time) { foreach (Ruleset.PathsRow path in ruleset.Paths) { // Try to open every file in list. foreach (var fsPath in ExpandFSPaths(path)) { FileStream file = null; try { if (File.Exists(fsPath)) { file = File.Open(fsPath, FileMode.Open, FileAccess.Read); } } catch { } finally { if (file != null) { file.Close(); } } } if (AdvRegistry.IsRegistryPath(path.Path) && AdvRegistry.IsKeyExists(path.Path)) { AdvRegistry.GetValueData(path.Path); } } accessCounter++; Console.Write("."); } Console.WriteLine(); return(accessCounter); }
public void IsRegistryPathOnIcorrectData() { string[] TestRegistryPaths = new[] { @"C:\Documents and Settings", @"C:\Documents and Settings\All Users\Favorites", @"D:\Documents\Pictures", @"HKY_CURRENT_USER\Printers\\DeviceOld", @"HKEY_LOCAL_MACHIN\SOFTWARE\FGUpdate\Config\\Time1" }; foreach (var RegistryPath in TestRegistryPaths) { if (AdvRegistry.IsRegistryPath(RegistryPath)) { Assert.Fail("AdvRegistry.IsRegistryPath returned true on:\r\n" + RegistryPath); } } }
public void CreateKey() { if (Registry.CurrentUser.OpenSubKey("TestKey") != null) { Assert.Fail(@"HKCU\TestKey already exists."); } AdvRegistry.CreateKey(@"HKCU\TestKey"); if (Registry.CurrentUser.OpenSubKey("TestKey") == null) { Assert.Fail(@"HKCU\TestKey failed to create."); } else { Registry.CurrentUser.DeleteSubKey("TestKey"); } }
public void IsRegistryPath() { string[] TestRegistryPaths = new[] { @"HKEY_LOCAL_MACHINE\SOFTWARE\FGUpdate\Config", @"HKEY_LOCAL_MACHINE\SOFTWARE\Windows 3.1 Migration Status\REG.DAT", @"HKEY_USERS\S-1-5-21-515967899-606747145-682003330-500\Identities\{30EA52FF-4D40-469E-B12F-CE5262A1495F}\Software\Microsoft\Outlook Express\5.0\Rules\Filter\FFA\Actions\000", @"HKEY_CURRENT_USER\Printers\\DeviceOld", @"HKEY_LOCAL_MACHINE\SOFTWARE" }; foreach (var RegistryPath in TestRegistryPaths) { if (!AdvRegistry.IsRegistryPath(RegistryPath)) { Assert.Fail("AdvRegistry.IsRegistryPath returned false on:\r\n" + RegistryPath); } } }
public void Initialize() { var Key = Registry.CurrentUser.CreateSubKey("existent"); if (Key == null) { throw new ApplicationException("Can't create existent key in HKCU."); } Key.SetValue("existent", "TEST"); if (Registry.CurrentUser.OpenSubKey("nonexistent") != null) { throw new ApplicationException("nonexistent key exists in HKCU."); } if (AdvRegistry.GetValueData(ExistentKey_NonexistentVal_Path) != null) { throw new ApplicationException("nonexistent val exists in HKCU\\existent."); } }
public void SetValueData_NullKey() { AdvRegistry.SetValueData(null, "Test value data."); }
public void DeleteKey_ForNonexistentKey() { AdvRegistry.DeleteKey(NonexistentKeyPath); }
public void SetValueData_EmptyKey() { AdvRegistry.SetValueData("", "Test value data."); }
public void GetValueData() { Assert.AreEqual("TEST", AdvRegistry.GetValueData(ExistentValPath)); }
public void SetValueData_NullData() { AdvRegistry.SetValueData(ExistentValPath, null); }
public void SetValueData_EmptyData() { AdvRegistry.SetValueData(ExistentValPath, ""); Assert.AreEqual(string.Empty, AdvRegistry.GetValueData(ExistentValPath)); }
public void SetValueData_NonexistentKey() { AdvRegistry.SetValueData(NonexistentKeyPath, string.Empty); }
public void DeleteKey_ForExistentKey() { AdvRegistry.DeleteKey(ExistentKeyPath); Assert.IsFalse(AdvRegistry.IsKeyExists(ExistentKeyPath)); }
public void IsKeyExists() { Assert.AreEqual(AdvRegistry.IsKeyExists(ExistentKeyPath), true); Assert.AreEqual(AdvRegistry.IsKeyExists(NonexistentKeyPath), false); }