| 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 class RegistryKey_Get_Name : RegistryTestsBase |
| 11 |
{ |
| 12 |
private const string CurrentUserKeyName = "HKEY_CURRENT_USER"; |
| 13 |
|
| 14 |
[Fact] |
| 15 |
public void NegativeTests() |
| 16 |
{ |
| 17 |
Assert.Throws<ObjectDisposedException>(() => |
| 18 |
{ |
| 19 |
TestRegistryKey.Dispose(); |
| 20 |
return TestRegistryKey.Name; |
| 21 |
}); |
| 22 |
} |
| 23 |
|
| 24 |
[Fact] |
| 25 |
public static void TestBaseKeyName() |
| 26 |
{ |
| 27 |
Assert.Equal(CurrentUserKeyName, Registry.CurrentUser.Name); |
| 28 |
} |
| 29 |
|
| 30 |
[Fact] |
| 31 |
public void TestSubKeyName() |
| 32 |
{ |
| 33 |
string expectedName = string.Format("HKEY_CURRENT_USER\\{0}", TestRegistryKeyName); |
| 34 |
Assert.Equal(expectedName, TestRegistryKey.Name); |
| 35 |
} |
| 36 |
} |
| 37 |
} |