Debian Codegraph @

external/corefx/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyCreateSubKeyTestsBase.cs

raw
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 using System;
6 using Xunit;
7
8 namespace Microsoft.Win32.RegistryTests
9 {
10 public abstract class RegistryKeyCreateSubKeyTestsBase : RegistryTestsBase
11 {
12 protected void Verify_CreateSubKey_KeyExists_OpensKeyWithFixedUpName(string expected, Func<RegistryKey> createSubKey)
13 {
14 CreateTestRegistrySubKey(expected);
15
16 using (RegistryKey key = createSubKey())
17 {
18 Assert.NotNull(key);
19 Assert.Equal(1, TestRegistryKey.SubKeyCount);
20 Assert.Equal(TestRegistryKey.Name + @"\" + expected, key.Name);
21 }
22 }
23
24 protected void Verify_CreateSubKey_KeyDoesNotExist_CreatesKeyWithFixedUpName(string expected, Func<RegistryKey> createSubKey)
25 {
26 Assert.Null(TestRegistryKey.OpenSubKey(expected));
27 Assert.Equal(0, TestRegistryKey.SubKeyCount);
28
29 using (RegistryKey key = createSubKey())
30 {
31 Assert.NotNull(key);
32 Assert.Equal(1, TestRegistryKey.SubKeyCount);
33 Assert.Equal(TestRegistryKey.Name + @"\" + expected, key.Name);
34 }
35 }
36 }
37 }