| 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 RegistryKeyOpenSubKeyTestsBase : RegistryTestsBase |
| 11 |
{ |
| 12 |
protected void Verify_OpenSubKey_KeyExists_OpensWithFixedUpName(string expected, Func<RegistryKey> openSubKey) |
| 13 |
{ |
| 14 |
CreateTestRegistrySubKey(expected); |
| 15 |
|
| 16 |
using (RegistryKey key = openSubKey()) |
| 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_OpenSubKey_KeyDoesNotExist_ReturnsNull(string expected, Func<RegistryKey> openSubKey) |
| 25 |
{ |
| 26 |
Assert.Null(TestRegistryKey.OpenSubKey(expected)); |
| 27 |
Assert.Equal(0, TestRegistryKey.SubKeyCount); |
| 28 |
|
| 29 |
Assert.Null(openSubKey()); |
| 30 |
} |
| 31 |
} |
| 32 |
} |