@@ -50,14 +50,14 @@ public void CanUnsetAnEntryFromTheLocalConfiguration()
5050 var path = BuildTemporaryCloneOfTestRepo ( StandardTestRepoPath ) ;
5151 using ( var repo = new Repository ( path . RepositoryPath ) )
5252 {
53- Assert . False ( repo . Config . Get < bool > ( "unittests.boolsetting" , false ) ) ;
53+ Assert . Null ( repo . Config . Get < bool > ( "unittests.boolsetting" ) ) ;
5454
5555 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 ) ;
5757
5858 repo . Config . Unset ( "unittests.boolsetting" ) ;
5959
60- Assert . False ( repo . Config . Get < bool > ( "unittests.boolsetting" , false ) ) ;
60+ Assert . Null ( repo . Config . Get < bool > ( "unittests.boolsetting" ) ) ;
6161 }
6262 }
6363
@@ -88,13 +88,13 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration()
8888 using ( var repo = new Repository ( BareTestRepoPath , options ) )
8989 {
9090 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 ) ;
9292
9393 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 ) ;
9595
9696 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" ) ) ;
9898 }
9999 }
100100
@@ -105,7 +105,7 @@ public void CanGetGlobalStringValue()
105105 {
106106 InconclusiveIf ( ( ) => ! repo . Config . HasGlobalConfig , "No Git global configuration available" ) ;
107107
108- Assert . NotNull ( repo . Config . Get < string > ( "user.name" , null ) ) ;
108+ Assert . NotNull ( repo . Config . Get < string > ( "user.name" ) ) ;
109109 }
110110 }
111111
@@ -115,7 +115,7 @@ public void CanGetGlobalStringValueWithoutRepo()
115115 using ( var config = new Configuration ( ) )
116116 {
117117 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" ) ) ;
119119 }
120120 }
121121
@@ -124,8 +124,7 @@ public void CanReadBooleanValue()
124124 {
125125 using ( var repo = new Repository ( StandardTestRepoPath ) )
126126 {
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 ) ;
129128 }
130129 }
131130
@@ -134,8 +133,7 @@ public void CanReadIntValue()
134133 {
135134 using ( var repo = new Repository ( StandardTestRepoPath ) )
136135 {
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 ) ;
139137 }
140138 }
141139
@@ -144,8 +142,7 @@ public void CanReadLongValue()
144142 {
145143 using ( var repo = new Repository ( StandardTestRepoPath ) )
146144 {
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 ) ;
149146 }
150147 }
151148
@@ -154,8 +151,8 @@ public void CanReadStringValue()
154151 {
155152 using ( var repo = new Repository ( StandardTestRepoPath ) )
156153 {
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 ) ;
159156 }
160157 }
161158
@@ -165,7 +162,7 @@ public void CanEnumerateGlobalConfig()
165162 using ( var repo = new Repository ( StandardTestRepoPath ) )
166163 {
167164 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" ) ;
169166 Assert . NotNull ( entry ) ;
170167 Assert . NotNull ( entry . Value ) ;
171168 }
@@ -176,7 +173,7 @@ public void CanEnumerateLocalConfig()
176173 {
177174 using ( var repo = new Repository ( StandardTestRepoPath ) )
178175 {
179- var entry = repo . Config . FirstOrDefault ( e => e . Key == "core.ignorecase" ) ;
176+ var entry = repo . Config . FirstOrDefault < ConfigurationEntry < string > > ( e => e . Key == "core.ignorecase" ) ;
180177 Assert . NotNull ( entry ) ;
181178 Assert . Equal ( "true" , entry . Value ) ;
182179 }
@@ -201,7 +198,7 @@ public void CanSetGlobalStringValue()
201198 {
202199 InconclusiveIf ( ( ) => ! repo . Config . HasGlobalConfig , "No Git global configuration available" ) ;
203200
204- var existing = repo . Config . Get < string > ( "user.name" , null ) ;
201+ var existing = repo . Config . Get < string > ( "user.name" ) ;
205202 Assert . NotNull ( existing ) ;
206203
207204 try
@@ -212,7 +209,7 @@ public void CanSetGlobalStringValue()
212209 }
213210 finally
214211 {
215- repo . Config . Set ( "user.name" , existing , ConfigurationLevel . Global ) ;
212+ repo . Config . Set ( "user.name" , existing . Value , ConfigurationLevel . Global ) ;
216213 }
217214 }
218215 }
@@ -224,7 +221,7 @@ public void CanSetGlobalStringValueWithoutRepo()
224221 {
225222 InconclusiveIf ( ( ) => ! config . HasGlobalConfig , "No Git global configuration available" ) ;
226223
227- var existing = config . Get < string > ( "user.name" , null ) ;
224+ var existing = config . Get < string > ( "user.name" ) ;
228225 Assert . NotNull ( existing ) ;
229226
230227 try
@@ -235,7 +232,7 @@ public void CanSetGlobalStringValueWithoutRepo()
235232 }
236233 finally
237234 {
238- config . Set ( "user.name" , existing , ConfigurationLevel . Global ) ;
235+ config . Set ( "user.name" , existing . Value , ConfigurationLevel . Global ) ;
239236 }
240237 }
241238 }
@@ -295,14 +292,14 @@ public void CanSetAndReadUnicodeStringValue()
295292
296293 AssertValueInLocalConfigFile ( path . RepositoryPath , "stringsetting = Juliën$" ) ;
297294
298- string val = repo . Config . Get ( "unittests.stringsetting" , "" ) ;
295+ string val = repo . Config . Get < string > ( "unittests.stringsetting" ) . Value ;
299296 Assert . Equal ( "Juliën" , val ) ;
300297 }
301298
302299 // Make sure the change is permanent
303300 using ( var repo = new Repository ( path . RepositoryPath ) )
304301 {
305- string val = repo . Config . Get ( "unittests.stringsetting" , "" ) ;
302+ string val = repo . Config . Get < string > ( "unittests.stringsetting" ) . Value ;
306303 Assert . Equal ( "Juliën" , val ) ;
307304 }
308305 }
@@ -312,24 +309,20 @@ public void ReadingUnsupportedTypeThrows()
312309 {
313310 using ( var repo = new Repository ( StandardTestRepoPath ) )
314311 {
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" ) ) ;
317314 }
318315 }
319316
320317 [ Fact ]
321- public void ReadingValueThatDoesntExistReturnsDefault ( )
318+ public void ReadingValueThatDoesntExistReturnsNull ( )
322319 {
323320 using ( var repo = new Repository ( StandardTestRepoPath ) )
324321 {
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" ) ) ;
333326 }
334327 }
335328
0 commit comments