[corlib] Fix RegistryKeyTest cleanup
authorMarek Safar <marek.safar@gmail.com>
Fri, 17 Mar 2017 09:08:37 +0000 (10:08 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 27 Mar 2017 21:36:35 +0000 (23:36 +0200)
mcs/class/corlib/Test/Microsoft.Win32/RegistryKeyTest.cs

index 7054084409dab3c72f7be13a1ddc4df6b7c49d9f..048091d2d7cb9dbb624836c4833bfa52d79b89cc 100755 (executable)
@@ -3436,15 +3436,20 @@ namespace MonoTests.Microsoft.Win32
                [Test]
                public void bugnew2 () // values cannot be written on registry root (hive)
                {
-                       string [] names = Registry.CurrentUser.GetValueNames ();
-                       Assert.IsNotNull (names, "#1");
-                       Registry.CurrentUser.SetValue ("name1", "value1");
-                       Assert.IsNotNull (Registry.CurrentUser.GetValue ("name1"), "#2");
-                       Assert.AreEqual ("value1", Registry.CurrentUser.GetValue ("name1"), "#3");
-                       string [] newNames = Registry.CurrentUser.GetValueNames ();
-                       Assert.IsNotNull (newNames, "#4");
-                       Assert.AreEqual (names.Length + 1, newNames.Length, "#5");
-                       Registry.CurrentUser.DeleteValue ("name1");
+                       try {
+                               string [] names = Registry.CurrentUser.GetValueNames ();
+                               Assert.IsNotNull (names, "#1");
+                               Registry.CurrentUser.SetValue ("name1", "value1");
+                               Assert.IsNotNull (Registry.CurrentUser.GetValue ("name1"), "#2");
+                               Assert.AreEqual ("value1", Registry.CurrentUser.GetValue ("name1"), "#3");
+                               string [] newNames = Registry.CurrentUser.GetValueNames ();
+                               Assert.IsNotNull (newNames, "#4");
+                               Assert.AreEqual (names.Length + 1, newNames.Length, "#5");
+                               Registry.CurrentUser.DeleteValue ("name1");
+                       } finally {
+                               Registry.CurrentUser.DeleteValue ("name1", false);
+                               Registry.CurrentUser.Flush ();
+                       }                               
                }
 
                [Test]