Debian Codegraph @

external/corefx/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKey_ToString.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 class RegistryKey_ToString : 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.ToString();
21 });
22 }
23
24 [Fact]
25 public static void TestBaseKeyToString()
26 {
27 Assert.Equal(CurrentUserKeyName, Registry.CurrentUser.ToString());
28 }
29
30 [Fact]
31 public void TestToString()
32 {
33 string expectedName = string.Format("HKEY_CURRENT_USER\\{0}", TestRegistryKeyName);
34 Assert.Equal(expectedName, TestRegistryKey.ToString());
35 }
36 }
37 }