Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>2010-07-30 18:26:51 +0400
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>2010-07-30 18:26:51 +0400
commitcc871f21d86765c372ffd71615de2a5252ce2832 (patch)
tree796f2d1f3accb8ab91149580848129d472044cf1
parent940155882171d68ee6678247eb2bf51a01ee0e63 (diff)
Add tests for GetSubKeyNames and DeleteSubKey rotines with volatile keys.last-commit-with-compulsory-changelog-entry
* RegistryKeyTest.cs: New tests for volatile keys children handling.
-rw-r--r--mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs b/mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs
index f357a22333b..7e1c7a5c84c 100644
--- a/mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs
+++ b/mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs
@@ -757,6 +757,65 @@ namespace MonoTests.Microsoft.Win32
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]