Debian Codegraph @

external/corefx/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKey_GetValueCount.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_GetValueCount : RegistryTestsBase
11 {
12 [Fact]
13 public void NegativeTests()
14 {
15 Assert.Throws<ObjectDisposedException>(() =>
16 {
17 TestRegistryKey.Dispose();
18 return TestRegistryKey.ValueCount;
19 });
20 }
21
22 [Fact]
23 public void TestValueCount()
24 {
25 Assert.Equal(expected: 0, actual: TestRegistryKey.ValueCount);
26
27 TestRegistryKey.SetValue(TestRegistryKeyName, 5);
28 Assert.Equal(expected: 1, actual: TestRegistryKey.ValueCount);
29
30 TestRegistryKey.DeleteValue(TestRegistryKeyName);
31 Assert.Equal(expected: 0, actual: TestRegistryKey.ValueCount);
32 }
33
34 [Fact]
35 public void TestValueCount2()
36 {
37 int expectedCount = 0;
38 foreach (var testCase in TestData.TestValueTypes)
39 {
40 TestRegistryKey.SetValue(testCase[0].ToString(), testCase[1]);
41 ++expectedCount;
42 }
43
44 Assert.Equal(expectedCount, TestRegistryKey.ValueCount);
45 }
46 }
47 }