@@ -50,14 +50,14 @@ public void CanUnsetAnEntryFromTheLocalConfiguration()
50
50
var path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoPath ) ;
51
51
using ( var repo = new Repository ( path . RepositoryPath ) )
52
52
{
53
- Assert . False ( repo . Config . Get < bool > ( "unittests.boolsetting" , false ) ) ;
53
+ Assert . Null ( repo . Config . Get < bool > ( "unittests.boolsetting" ) ) ;
54
54
55
55
repo . Config . Set ( "unittests.boolsetting" , true ) ;
56
- Assert . True ( repo . Config . Get < bool > ( "unittests.boolsetting" , false ) ) ;
56
+ Assert . True ( repo . Config . Get < bool > ( "unittests.boolsetting" ) . Value ) ;
57
57
58
58
repo . Config . Unset ( "unittests.boolsetting" ) ;
59
59
60
- Assert . False ( repo . Config . Get < bool > ( "unittests.boolsetting" , false ) ) ;
60
+ Assert . Null ( repo . Config . Get < bool > ( "unittests.boolsetting" ) ) ;
61
61
}
62
62
}
63
63
@@ -88,13 +88,13 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration()
88
88
using ( var repo = new Repository ( BareTestRepoPath , options ) )
89
89
{
90
90
Assert . True ( repo . Config . HasGlobalConfig ) ;
91
- Assert . Equal ( 42 , repo . Config . Get ( "Wow.Man-I-am-totally-global" , 1337 ) ) ;
91
+ Assert . Equal ( 42 , repo . Config . Get < int > ( "Wow.Man-I-am-totally-global" ) . Value ) ;
92
92
93
93
repo . Config . Unset ( "Wow.Man-I-am-totally-global" ) ;
94
- Assert . Equal ( 42 , repo . Config . Get ( "Wow.Man-I-am-totally-global" , 1337 ) ) ;
94
+ Assert . Equal ( 42 , repo . Config . Get < int > ( "Wow.Man-I-am-totally-global" ) . Value ) ;
95
95
96
96
repo . Config . Unset ( "Wow.Man-I-am-totally-global" , ConfigurationLevel . Global ) ;
97
- Assert . Equal ( 1337 , repo . Config . Get ( "Wow.Man-I-am-totally-global" , 1337 ) ) ;
97
+ Assert . Null ( repo . Config . Get < int > ( "Wow.Man-I-am-totally-global" ) ) ;
98
98
}
99
99
}
100
100
@@ -105,7 +105,7 @@ public void CanGetGlobalStringValue()
105
105
{
106
106
InconclusiveIf ( ( ) => ! repo . Config . HasGlobalConfig , "No Git global configuration available" ) ;
107
107
108
- Assert . NotNull ( repo . Config . Get < string > ( "user.name" , null ) ) ;
108
+ Assert . NotNull ( repo . Config . Get < string > ( "user.name" ) ) ;
109
109
}
110
110
}
111
111
@@ -115,7 +115,7 @@ public void CanGetGlobalStringValueWithoutRepo()
115
115
using ( var config = new Configuration ( ) )
116
116
{
117
117
InconclusiveIf ( ( ) => ! config . HasGlobalConfig , "No Git global configuration available" ) ;
118
- Assert . NotNull ( config . Get < string > ( "user.name" , null ) ) ;
118
+ Assert . NotNull ( config . Get < string > ( "user.name" ) ) ;
119
119
}
120
120
}
121
121
@@ -124,8 +124,7 @@ public void CanReadBooleanValue()
124
124
{
125
125
using ( var repo = new Repository ( StandardTestRepoPath ) )
126
126
{
127
- Assert . True ( repo . Config . Get < bool > ( "core.ignorecase" , false ) ) ;
128
- Assert . True ( repo . Config . Get < bool > ( "core" , "ignorecase" , false ) ) ;
127
+ Assert . True ( repo . Config . Get < bool > ( "core.ignorecase" ) . Value ) ;
129
128
}
130
129
}
131
130
@@ -134,8 +133,7 @@ public void CanReadIntValue()
134
133
{
135
134
using ( var repo = new Repository ( StandardTestRepoPath ) )
136
135
{
137
- Assert . Equal ( 2 , repo . Config . Get < int > ( "unittests.intsetting" , 42 ) ) ;
138
- Assert . Equal ( 2 , repo . Config . Get < int > ( "unittests" , "intsetting" , 42 ) ) ;
136
+ Assert . Equal ( 2 , repo . Config . Get < int > ( "unittests.intsetting" ) . Value ) ;
139
137
}
140
138
}
141
139
@@ -144,8 +142,7 @@ public void CanReadLongValue()
144
142
{
145
143
using ( var repo = new Repository ( StandardTestRepoPath ) )
146
144
{
147
- Assert . Equal ( 15234 , repo . Config . Get < long > ( "unittests.longsetting" , 42 ) ) ;
148
- Assert . Equal ( 15234 , repo . Config . Get < long > ( "unittests" , "longsetting" , 42 ) ) ;
145
+ Assert . Equal ( 15234 , repo . Config . Get < long > ( "unittests.longsetting" ) . Value ) ;
149
146
}
150
147
}
151
148
@@ -154,8 +151,8 @@ public void CanReadStringValue()
154
151
{
155
152
using ( var repo = new Repository ( StandardTestRepoPath ) )
156
153
{
157
- Assert . Equal ( "+refs/heads/*:refs/remotes/origin/*" , repo . Config . Get < string > ( "remote.origin.fetch" , null ) ) ;
158
- Assert . Equal ( "+refs/heads/*:refs/remotes/origin/*" , repo . Config . Get < string > ( "remote" , "origin" , "fetch" , null ) ) ;
154
+ Assert . Equal ( "+refs/heads/*:refs/remotes/origin/*" , repo . Config . Get < string > ( "remote.origin.fetch" ) . Value ) ;
155
+ Assert . Equal ( "+refs/heads/*:refs/remotes/origin/*" , repo . Config . Get < string > ( "remote" , "origin" , "fetch" ) . Value ) ;
159
156
}
160
157
}
161
158
@@ -165,7 +162,7 @@ public void CanEnumerateGlobalConfig()
165
162
using ( var repo = new Repository ( StandardTestRepoPath ) )
166
163
{
167
164
InconclusiveIf ( ( ) => ! repo . Config . HasGlobalConfig , "No Git global configuration available" ) ;
168
- var entry = repo . Config . FirstOrDefault ( e => e . Key == "user.name" ) ;
165
+ var entry = repo . Config . FirstOrDefault < ConfigurationEntry < string > > ( e => e . Key == "user.name" ) ;
169
166
Assert . NotNull ( entry ) ;
170
167
Assert . NotNull ( entry . Value ) ;
171
168
}
@@ -176,7 +173,7 @@ public void CanEnumerateLocalConfig()
176
173
{
177
174
using ( var repo = new Repository ( StandardTestRepoPath ) )
178
175
{
179
- var entry = repo . Config . FirstOrDefault ( e => e . Key == "core.ignorecase" ) ;
176
+ var entry = repo . Config . FirstOrDefault < ConfigurationEntry < string > > ( e => e . Key == "core.ignorecase" ) ;
180
177
Assert . NotNull ( entry ) ;
181
178
Assert . Equal ( "true" , entry . Value ) ;
182
179
}
@@ -201,7 +198,7 @@ public void CanSetGlobalStringValue()
201
198
{
202
199
InconclusiveIf ( ( ) => ! repo . Config . HasGlobalConfig , "No Git global configuration available" ) ;
203
200
204
- var existing = repo . Config . Get < string > ( "user.name" , null ) ;
201
+ var existing = repo . Config . Get < string > ( "user.name" ) ;
205
202
Assert . NotNull ( existing ) ;
206
203
207
204
try
@@ -212,7 +209,7 @@ public void CanSetGlobalStringValue()
212
209
}
213
210
finally
214
211
{
215
- repo . Config . Set ( "user.name" , existing , ConfigurationLevel . Global ) ;
212
+ repo . Config . Set ( "user.name" , existing . Value , ConfigurationLevel . Global ) ;
216
213
}
217
214
}
218
215
}
@@ -224,7 +221,7 @@ public void CanSetGlobalStringValueWithoutRepo()
224
221
{
225
222
InconclusiveIf ( ( ) => ! config . HasGlobalConfig , "No Git global configuration available" ) ;
226
223
227
- var existing = config . Get < string > ( "user.name" , null ) ;
224
+ var existing = config . Get < string > ( "user.name" ) ;
228
225
Assert . NotNull ( existing ) ;
229
226
230
227
try
@@ -235,7 +232,7 @@ public void CanSetGlobalStringValueWithoutRepo()
235
232
}
236
233
finally
237
234
{
238
- config . Set ( "user.name" , existing , ConfigurationLevel . Global ) ;
235
+ config . Set ( "user.name" , existing . Value , ConfigurationLevel . Global ) ;
239
236
}
240
237
}
241
238
}
@@ -295,14 +292,14 @@ public void CanSetAndReadUnicodeStringValue()
295
292
296
293
AssertValueInLocalConfigFile ( path . RepositoryPath , "stringsetting = Juliën$" ) ;
297
294
298
- string val = repo . Config . Get ( "unittests.stringsetting" , "" ) ;
295
+ string val = repo . Config . Get < string > ( "unittests.stringsetting" ) . Value ;
299
296
Assert . Equal ( "Juliën" , val ) ;
300
297
}
301
298
302
299
// Make sure the change is permanent
303
300
using ( var repo = new Repository ( path . RepositoryPath ) )
304
301
{
305
- string val = repo . Config . Get ( "unittests.stringsetting" , "" ) ;
302
+ string val = repo . Config . Get < string > ( "unittests.stringsetting" ) . Value ;
306
303
Assert . Equal ( "Juliën" , val ) ;
307
304
}
308
305
}
@@ -312,24 +309,20 @@ public void ReadingUnsupportedTypeThrows()
312
309
{
313
310
using ( var repo = new Repository ( StandardTestRepoPath ) )
314
311
{
315
- Assert . Throws < ArgumentException > ( ( ) => repo . Config . Get < short > ( "unittests.setting" , 42 ) ) ;
316
- Assert . Throws < ArgumentException > ( ( ) => repo . Config . Get < Configuration > ( "unittests.setting" , null ) ) ;
312
+ Assert . Throws < ArgumentException > ( ( ) => repo . Config . Get < short > ( "unittests.setting" ) ) ;
313
+ Assert . Throws < ArgumentException > ( ( ) => repo . Config . Get < Configuration > ( "unittests.setting" ) ) ;
317
314
}
318
315
}
319
316
320
317
[ Fact ]
321
- public void ReadingValueThatDoesntExistReturnsDefault ( )
318
+ public void ReadingValueThatDoesntExistReturnsNull ( )
322
319
{
323
320
using ( var repo = new Repository ( StandardTestRepoPath ) )
324
321
{
325
- Assert . Null ( repo . Config . Get < string > ( "unittests.ghostsetting" , null ) ) ;
326
- Assert . Equal ( 0 , repo . Config . Get < int > ( "unittests.ghostsetting" , 0 ) ) ;
327
- Assert . Equal ( 0L , repo . Config . Get < long > ( "unittests.ghostsetting" , 0L ) ) ;
328
- Assert . False ( repo . Config . Get < bool > ( "unittests.ghostsetting" , false ) ) ;
329
- Assert . Equal ( "42" , repo . Config . Get ( "unittests.ghostsetting" , "42" ) ) ;
330
- Assert . Equal ( 42 , repo . Config . Get ( "unittests.ghostsetting" , 42 ) ) ;
331
- Assert . Equal ( 42L , repo . Config . Get ( "unittests.ghostsetting" , 42L ) ) ;
332
- Assert . True ( repo . Config . Get ( "unittests.ghostsetting" , true ) ) ;
322
+ Assert . Null ( repo . Config . Get < string > ( "unittests.ghostsetting" ) ) ;
323
+ Assert . Null ( repo . Config . Get < int > ( "unittests.ghostsetting" ) ) ;
324
+ Assert . Null ( repo . Config . Get < long > ( "unittests.ghostsetting" ) ) ;
325
+ Assert . Null ( repo . Config . Get < bool > ( "unittests.ghostsetting" ) ) ;
333
326
}
334
327
}
335
328
0 commit comments