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

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Microsoft.Win32.Registry/tests/RegistryTestsBase.cs')
-rw-r--r--src/Microsoft.Win32.Registry/tests/RegistryTestsBase.cs114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/Microsoft.Win32.Registry/tests/RegistryTestsBase.cs b/src/Microsoft.Win32.Registry/tests/RegistryTestsBase.cs
index 4d185d691c..acf8d54856 100644
--- a/src/Microsoft.Win32.Registry/tests/RegistryTestsBase.cs
+++ b/src/Microsoft.Win32.Registry/tests/RegistryTestsBase.cs
@@ -54,5 +54,119 @@ namespace Microsoft.Win32.RegistryTests
// classes running concurrently
return "corefxtest_" + GetType().Name;
}
+
+ public static readonly object[][] TestRegistrySubKeyNames =
+ {
+ new object[] { @"Foo", @"Foo" },
+ new object[] { @"Foo\Bar", @"Foo\Bar" },
+
+ // Multiple/trailing slashes should be removed.
+ new object[] { @"Foo", @"Foo\" },
+ new object[] { @"Foo", @"Foo\\" },
+ new object[] { @"Foo", @"Foo\\\" },
+ new object[] { @"Foo", @"Foo\\\\" },
+ new object[] { @"Foo\Bar", @"Foo\\Bar" },
+ new object[] { @"Foo\Bar", @"Foo\\\Bar" },
+ new object[] { @"Foo\Bar", @"Foo\\\\Bar" },
+ new object[] { @"Foo\Bar", @"Foo\Bar\" },
+ new object[] { @"Foo\Bar", @"Foo\Bar\\" },
+ new object[] { @"Foo\Bar", @"Foo\Bar\\\" },
+ new object[] { @"Foo\Bar", @"Foo\\Bar\" },
+ new object[] { @"Foo\Bar", @"Foo\\Bar\\" },
+ new object[] { @"Foo\Bar", @"Foo\\Bar\\\" },
+ new object[] { @"Foo\Bar", @"Foo\\\Bar\\\" },
+ new object[] { @"Foo\Bar", @"Foo\\\\Bar\\\\" },
+
+ // The name fix-up implementation uses a mark-and-sweep approach.
+ // If there are multiple slashes, any extra slash chars will be
+ // replaced with a marker char ('\uffff'), and then all '\uffff'
+ // chars will be removed, including any pre-existing '\uffff' chars.
+ InsertMarkerChar(@"Foo", @"{0}Foo\\"),
+ InsertMarkerChar(@"Foo", @"Foo{0}\\"),
+ InsertMarkerChar(@"Foo", @"Foo\\{0}"),
+ InsertMarkerChar(@"Foo", @"Fo{0}o\\"),
+ InsertMarkerChar(@"Foo", @"{0}Fo{0}o{0}\\{0}"),
+ InsertMarkerChar(@"Foo", @"{0}Foo\\\"),
+ InsertMarkerChar(@"Foo", @"Foo{0}\\\"),
+ InsertMarkerChar(@"Foo", @"Foo\\\{0}"),
+ InsertMarkerChar(@"Foo", @"Fo{0}o\\\"),
+ InsertMarkerChar(@"Foo", @"{0}Fo{0}o{0}\\\{0}"),
+ InsertMarkerChar(@"Foo\Bar", @"{0}Foo\\Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo{0}\\Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\\{0}Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\\Bar{0}"),
+ InsertMarkerChar(@"Foo\Bar", @"Fo{0}o\\Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\\B{0}ar"),
+ InsertMarkerChar(@"Foo\Bar", @"Fo{0}o\\B{0}ar"),
+ InsertMarkerChar(@"Foo\Bar", @"{0}Fo{0}o{0}\\{0}B{0}ar{0}"),
+ InsertMarkerChar(@"Foo\Bar", @"{0}Foo\\\Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo{0}\\\Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\\\{0}Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\\\Bar{0}"),
+ InsertMarkerChar(@"Foo\Bar", @"Fo{0}o\\\Bar"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\\\B{0}ar"),
+ InsertMarkerChar(@"Foo\Bar", @"Fo{0}o\\\B{0}ar"),
+ InsertMarkerChar(@"Foo\Bar", @"{0}Fo{0}o{0}\\\{0}B{0}ar{0}"),
+ InsertMarkerChar(@"Foo\Bar", @"{0}Foo\Bar\\"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo{0}\Bar\\"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\{0}Bar\\"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\Bar{0}\\"),
+ InsertMarkerChar(@"Foo\Bar", @"Foo\Bar\\{0}"),
+ InsertMarkerChar(@"Foo\Bar", @"Fo{0}o\B{0}ar\\"),
+ InsertMarkerChar(@"Foo\Bar", @"{0}Fo{0}o{0}\{0}B{0}ar{0}\\{0}"),
+
+ // If there aren't multiple slashes, any '\uffff' chars should remain.
+ InsertMarkerChar(@"{0}Foo"),
+ InsertMarkerChar(@"Foo{0}"),
+ InsertMarkerChar(@"Fo{0}o"),
+ InsertMarkerChar(@"{0}Fo{0}o{0}"),
+ InsertMarkerChar(@"{0}Foo\"),
+ InsertMarkerChar(@"Foo{0}\"),
+ InsertMarkerChar(@"Fo{0}o\"),
+ InsertMarkerChar(@"{0}Fo{0}o{0}\"),
+ InsertMarkerChar(@"{0}Foo\Bar"),
+ InsertMarkerChar(@"Foo{0}\Bar"),
+ InsertMarkerChar(@"Foo\{0}Bar"),
+ InsertMarkerChar(@"Foo\Bar{0}"),
+ InsertMarkerChar(@"Fo{0}o\Bar"),
+ InsertMarkerChar(@"Foo\B{0}ar"),
+ InsertMarkerChar(@"Fo{0}o\B{0}ar"),
+ InsertMarkerChar(@"{0}Fo{0}o{0}\{0}B{0}ar{0}"),
+ InsertMarkerChar(@"{0}Foo\Bar\"),
+ InsertMarkerChar(@"Foo{0}\Bar\"),
+ InsertMarkerChar(@"Foo\{0}Bar\"),
+ InsertMarkerChar(@"Foo\Bar{0}\"),
+ InsertMarkerChar(@"Fo{0}o\Bar\"),
+ InsertMarkerChar(@"Foo\B{0}ar\"),
+ InsertMarkerChar(@"Fo{0}o\B{0}ar\"),
+ InsertMarkerChar(@"{0}Fo{0}o{0}\{0}B{0}ar{0}\"),
+ };
+
+ private const char MarkerChar = '\uffff';
+
+ private static object[] InsertMarkerChar(string expected, string format)
+ {
+ string result = string.Format(format, MarkerChar);
+ return new object[] { expected, result };
+ }
+
+ private static object[] InsertMarkerChar(string format)
+ {
+ string result = string.Format(format, MarkerChar);
+ string expected = result.TrimEnd('\\');
+ return new object[] { expected, result };
+ }
+
+ protected void CreateTestRegistrySubKey(string expected)
+ {
+ Assert.Equal(0, TestRegistryKey.SubKeyCount);
+
+ using (RegistryKey key = TestRegistryKey.CreateSubKey(expected))
+ {
+ Assert.NotNull(key);
+ Assert.Equal(1, TestRegistryKey.SubKeyCount);
+ Assert.Equal(TestRegistryKey.Name + @"\" + expected, key.Name);
+ }
+ }
}
}