@@ -15,15 +15,15 @@ public void Test01()
15
15
// [] Passing in null should throw ArgumentNullException
16
16
//UPDATE: This sets the default value. We should move this test to a newly defined reg key so as not to screw up the system
17
17
const string expected = "This is a test" ;
18
- Registry . SetValue ( _testRegistryKey . Name , null , expected ) ;
19
- Assert . Equal ( expected , _testRegistryKey . GetValue ( null ) ) ;
18
+ Registry . SetValue ( TestRegistryKey . Name , null , expected ) ;
19
+ Assert . Equal ( expected , TestRegistryKey . GetValue ( null ) ) ;
20
20
}
21
21
22
22
[ Fact ]
23
23
public void NegativeTests ( )
24
24
{
25
25
// Should throw if passed value is null
26
- Assert . Throws < ArgumentNullException > ( ( ) => Registry . SetValue ( _testRegistryKey . Name , "test" , value : null ) ) ;
26
+ Assert . Throws < ArgumentNullException > ( ( ) => Registry . SetValue ( TestRegistryKey . Name , "test" , value : null ) ) ;
27
27
28
28
// Should throw if passed keyName is null
29
29
Assert . Throws < ArgumentNullException > ( ( ) => Registry . SetValue ( keyName : null , valueName : "test" , value : "test" ) ) ;
@@ -36,14 +36,14 @@ public void NegativeTests()
36
36
37
37
// Should throw if key length above 255 characters but prior to V4, the limit is 16383
38
38
const int maxValueNameLength = 16383 ;
39
- Assert . Throws < ArgumentException > ( ( ) => Registry . SetValue ( _testRegistryKey . Name , new string ( 'a' , maxValueNameLength + 1 ) , 5 ) ) ;
39
+ Assert . Throws < ArgumentException > ( ( ) => Registry . SetValue ( TestRegistryKey . Name , new string ( 'a' , maxValueNameLength + 1 ) , 5 ) ) ;
40
40
41
41
// Should throw if passed value is array with uninitialized elements
42
- Assert . Throws < ArgumentException > ( ( ) => Registry . SetValue ( _testRegistryKey . Name , "StringArr" , value : new string [ 1 ] ) ) ;
42
+ Assert . Throws < ArgumentException > ( ( ) => Registry . SetValue ( TestRegistryKey . Name , "StringArr" , value : new string [ 1 ] ) ) ;
43
43
44
44
// Should throw because only String[] (REG_MULTI_SZ) and byte[] (REG_BINARY) are supported.
45
45
// RegistryKey.SetValue does not support arrays of type UInt32[].
46
- Assert . Throws < ArgumentException > ( ( ) => Registry . SetValue ( _testRegistryKey . Name , "IntArray" , new [ ] { 1 , 2 , 3 } ) ) ;
46
+ Assert . Throws < ArgumentException > ( ( ) => Registry . SetValue ( TestRegistryKey . Name , "IntArray" , new [ ] { 1 , 2 , 3 } ) ) ;
47
47
}
48
48
49
49
public static IEnumerable < object [ ] > TestValueTypes { get { return TestData . TestValueTypes ; } }
@@ -52,9 +52,9 @@ public void NegativeTests()
52
52
[ MemberData ( "TestValueTypes" ) ]
53
53
public void SetValueWithValueTypes ( string valueName , object testValue )
54
54
{
55
- Registry . SetValue ( _testRegistryKey . Name , valueName , testValue ) ;
56
- Assert . Equal ( testValue . ToString ( ) , _testRegistryKey . GetValue ( valueName ) . ToString ( ) ) ;
57
- _testRegistryKey . DeleteValue ( valueName ) ;
55
+ Registry . SetValue ( TestRegistryKey . Name , valueName , testValue ) ;
56
+ Assert . Equal ( testValue . ToString ( ) , TestRegistryKey . GetValue ( valueName ) . ToString ( ) ) ;
57
+ TestRegistryKey . DeleteValue ( valueName ) ;
58
58
}
59
59
60
60
[ Fact ]
@@ -63,9 +63,9 @@ public void SetValueWithInt32()
63
63
const string testValueName = "Int32" ;
64
64
const int expected = - 5 ;
65
65
66
- Registry . SetValue ( _testRegistryKey . Name , testValueName , expected ) ;
67
- Assert . Equal ( expected , ( int ) _testRegistryKey . GetValue ( testValueName ) ) ;
68
- _testRegistryKey . DeleteValue ( testValueName ) ;
66
+ Registry . SetValue ( TestRegistryKey . Name , testValueName , expected ) ;
67
+ Assert . Equal ( expected , ( int ) TestRegistryKey . GetValue ( testValueName ) ) ;
68
+ TestRegistryKey . DeleteValue ( testValueName ) ;
69
69
}
70
70
71
71
[ Fact ]
@@ -75,9 +75,9 @@ public void SetValueWithUInt64()
75
75
const string testValueName = "UInt64" ;
76
76
const ulong expected = ulong . MaxValue ;
77
77
78
- Registry . SetValue ( _testRegistryKey . Name , testValueName , expected ) ;
79
- Assert . Equal ( expected , Convert . ToUInt64 ( _testRegistryKey . GetValue ( testValueName ) ) ) ;
80
- _testRegistryKey . DeleteValue ( testValueName ) ;
78
+ Registry . SetValue ( TestRegistryKey . Name , testValueName , expected ) ;
79
+ Assert . Equal ( expected , Convert . ToUInt64 ( TestRegistryKey . GetValue ( testValueName ) ) ) ;
80
+ TestRegistryKey . DeleteValue ( testValueName ) ;
81
81
}
82
82
83
83
[ Fact ]
@@ -87,9 +87,9 @@ public void SetValueWithByteArray()
87
87
const string testValueName = "UBArr" ;
88
88
byte [ ] expected = { 1 , 2 , 3 } ;
89
89
90
- Registry . SetValue ( _testRegistryKey . Name , testValueName , expected ) ;
91
- Assert . Equal ( expected , ( byte [ ] ) _testRegistryKey . GetValue ( testValueName ) ) ;
92
- _testRegistryKey . DeleteValue ( testValueName ) ;
90
+ Registry . SetValue ( TestRegistryKey . Name , testValueName , expected ) ;
91
+ Assert . Equal ( expected , ( byte [ ] ) TestRegistryKey . GetValue ( testValueName ) ) ;
92
+ TestRegistryKey . DeleteValue ( testValueName ) ;
93
93
}
94
94
95
95
[ Fact ]
@@ -104,9 +104,9 @@ public void SetValueWithMultiString()
104
104
"lot of things. one of which"
105
105
} ;
106
106
107
- Registry . SetValue ( _testRegistryKey . Name , testValueName , expected ) ;
108
- Assert . Equal ( expected , ( string [ ] ) _testRegistryKey . GetValue ( testValueName ) ) ;
109
- _testRegistryKey . DeleteValue ( testValueName ) ;
107
+ Registry . SetValue ( TestRegistryKey . Name , testValueName , expected ) ;
108
+ Assert . Equal ( expected , ( string [ ] ) TestRegistryKey . GetValue ( testValueName ) ) ;
109
+ TestRegistryKey . DeleteValue ( testValueName ) ;
110
110
}
111
111
112
112
public static IEnumerable < object [ ] > TestEnvironment { get { return TestData . TestEnvironment ; } }
@@ -116,12 +116,12 @@ public void SetValueWithMultiString()
116
116
public void SetValueWithEnvironmentVariable ( string valueName , string envVariableName , string expectedVariableValue )
117
117
{
118
118
string value = "%" + envVariableName + "%" ;
119
- Registry . SetValue ( _testRegistryKey . Name , valueName , value ) ;
119
+ Registry . SetValue ( TestRegistryKey . Name , valueName , value ) ;
120
120
121
- string result = ( string ) _testRegistryKey . GetValue ( valueName ) ;
121
+ string result = ( string ) TestRegistryKey . GetValue ( valueName ) ;
122
122
//we don't expand for the user, REG_SZ_EXPAND not supported
123
123
Assert . Equal ( expectedVariableValue , Environment . ExpandEnvironmentVariables ( result ) ) ;
124
- _testRegistryKey . DeleteValue ( valueName ) ;
124
+ TestRegistryKey . DeleteValue ( valueName ) ;
125
125
}
126
126
127
127
[ Fact ]
@@ -131,9 +131,9 @@ public void SetValueWithEmptyString()
131
131
const string testValueName = "test_122018" ;
132
132
string expected = string . Empty ;
133
133
134
- Registry . SetValue ( _testRegistryKey . Name , testValueName , expected ) ;
135
- Assert . Equal ( expected , ( string ) _testRegistryKey . GetValue ( testValueName ) ) ;
136
- _testRegistryKey . DeleteValue ( testValueName ) ;
134
+ Registry . SetValue ( TestRegistryKey . Name , testValueName , expected ) ;
135
+ Assert . Equal ( expected , ( string ) TestRegistryKey . GetValue ( testValueName ) ) ;
136
+ TestRegistryKey . DeleteValue ( testValueName ) ;
137
137
}
138
138
}
139
139
}
0 commit comments