Skip to content
Browse files

Add tests for GetSubKeyNames and DeleteSubKey rotines with volatile k…

…eys.

	* RegistryKeyTest.cs: New tests for volatile keys children
	handling.
  • Loading branch information...
1 parent 9401558 commit cc871f21d86765c372ffd71615de2a5252ce2832 @carlosalberto carlosalberto committed Jul 30, 2010
Showing with 59 additions and 0 deletions.
  1. +59 −0 mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs
View
59 mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs
@@ -757,6 +757,65 @@ public void CreateSubKey_Volatile_Conflict ()
key2.Close ();
}
}
+
+ [Test]
+ public void DeleteSubKey_Volatile ()
+ {
+ RegistryKey key = null;
+ RegistryKey subkey = null;
+ string subKeyName = "VolatileKey";
+
+ try {
+ key = Registry.CurrentUser.CreateSubKey (subKeyName, RegistryKeyPermissionCheck.Default, RegistryOptions.Volatile);
+ key.CreateSubKey ("VolatileKeyChild", RegistryKeyPermissionCheck.Default, RegistryOptions.Volatile);
+ key.SetValue ("Name", "Mono");
+ key.Close ();
+
+ Registry.CurrentUser.DeleteSubKeyTree (subKeyName);
+
+ key = Registry.CurrentUser.OpenSubKey (subKeyName);
+ Assert.AreEqual (null, key, "#A0");
+ } finally {
+ if (subkey != null)
+ subkey.Close ();
+ if (key != null)
+ key.Close ();
+ }
+ }
+
+ // Define a normal key, and create a normal and a volatile key under it, and retrieve their names.
+ [Test]
+ public void GetSubKeyNames_Volatile ()
+ {
+ RegistryKey key = null;
+ RegistryKey subkey = null;
+ string subKeyName = Guid.NewGuid ().ToString ();
+ string volChildKeyName = "volatilechildkey";
+ string childKeyName = "childkey";
+
+ try {
+ key = Registry.CurrentUser.CreateSubKey (subKeyName);
+ key.CreateSubKey (volChildKeyName, RegistryKeyPermissionCheck.Default, RegistryOptions.Volatile);
+ key.CreateSubKey (childKeyName, RegistryKeyPermissionCheck.Default, RegistryOptions.None);
+ key.Close ();
+
+ key = Registry.CurrentUser.OpenSubKey (subKeyName);
+ string [] keyNames = key.GetSubKeyNames ();
+
+ // we can guarantee the order of the child keys, so we sort the two of them
+ Array.Sort (keyNames);
+
+ Assert.AreEqual (2, keyNames.Length, "#A0");
+ Assert.AreEqual (childKeyName, keyNames [0], "#A1");
+ Assert.AreEqual (volChildKeyName, keyNames [1], "#A2");
+ } finally {
+ if (subkey != null)
+ subkey.Close ();
+ if (key != null)
+ key.Close ();
+ }
+
+ }
#endif
[Test]

0 comments on commit cc871f2

Please sign in to comment.
Something went wrong with that request. Please try again.