-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
RegistryKey_GetValue_str_obj.cs
53 lines (46 loc) · 1.85 KB
/
RegistryKey_GetValue_str_obj.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using Xunit;
namespace Microsoft.Win32.RegistryTests
{
public class RegistryKey_GetValue_str_obj : RegistryTestsBase
{
[Fact]
public void NegativeTests()
{
Assert.Throws<ObjectDisposedException>(() =>
{
TestRegistryKey.Dispose();
TestRegistryKey.GetValue(null, TestData.DefaultValue);
});
}
[Fact]
public void GetDefaultValueTest()
{
if (!TestRegistryKey.IsDefaultValueSet())
{
Assert.Equal(TestData.DefaultValue, TestRegistryKey.GetValue(null, TestData.DefaultValue));
Assert.Equal(TestData.DefaultValue, TestRegistryKey.GetValue(string.Empty, TestData.DefaultValue));
}
Assert.True(TestRegistryKey.SetDefaultValue(TestData.DefaultValue));
Assert.Equal(TestData.DefaultValue, TestRegistryKey.GetValue(null, null));
Assert.Equal(TestData.DefaultValue, TestRegistryKey.GetValue(string.Empty, null));
}
[Fact]
public void ShouldAcceptNullAsDefaultValue()
{
Assert.Null(TestRegistryKey.GetValue("tt", defaultValue: null));
}
public static IEnumerable<object[]> TestValueTypes { get { return TestData.TestValueTypes; } }
[Theory]
[MemberData(nameof(TestValueTypes))]
public void TestGetValueWithValueTypes(string valueName, object testValue)
{
TestRegistryKey.SetValue(valueName, testValue);
Assert.Equal(testValue.ToString(), TestRegistryKey.GetValue(valueName, null).ToString());
TestRegistryKey.DeleteValue(valueName);
}
}
}