@@ -21,6 +21,12 @@ public class Configuration : IDisposable
21
21
private ConfigurationSafeHandle globalHandle ;
22
22
private ConfigurationSafeHandle localHandle ;
23
23
24
+ /// <summary>
25
+ /// Needed for mocking purposes.
26
+ /// </summary>
27
+ protected Configuration ( )
28
+ { }
29
+
24
30
internal Configuration ( Repository repository , string globalConfigurationFileLocation , string systemConfigurationFileLocation )
25
31
{
26
32
this . repository = repository ;
@@ -90,15 +96,15 @@ private bool HasLocalConfig
90
96
/// <summary>
91
97
/// Determines if a Git configuration file specific to the current interactive user has been found.
92
98
/// </summary>
93
- public bool HasGlobalConfig
99
+ public virtual bool HasGlobalConfig
94
100
{
95
101
get { return globalConfigPath != null ; }
96
102
}
97
103
98
104
/// <summary>
99
105
/// Determines if a system-wide Git configuration file has been found.
100
106
/// </summary>
101
- public bool HasSystemConfig
107
+ public virtual bool HasSystemConfig
102
108
{
103
109
get { return systemConfigPath != null ; }
104
110
}
@@ -143,7 +149,7 @@ public void Dispose()
143
149
/// </summary>
144
150
/// <param name = "key">The key to unset.</param>
145
151
/// <param name = "level">The configuration file which should be considered as the target of this operation</param>
146
- public void Unset ( string key , ConfigurationLevel level = ConfigurationLevel . Local )
152
+ public virtual void Unset ( string key , ConfigurationLevel level = ConfigurationLevel . Local )
147
153
{
148
154
ConfigurationSafeHandle h = RetrieveConfigurationHandle ( level ) ;
149
155
@@ -200,7 +206,7 @@ protected virtual void Dispose(bool disposing)
200
206
/// <param name = "key">The key</param>
201
207
/// <param name = "defaultValue">The default value</param>
202
208
/// <returns>The configuration value, or <c>defaultValue</c> if not set</returns>
203
- public T Get < T > ( string key , T defaultValue )
209
+ public virtual T Get < T > ( string key , T defaultValue )
204
210
{
205
211
Ensure . ArgumentNotNullOrEmptyString ( key , "key" ) ;
206
212
@@ -240,7 +246,7 @@ public T Get<T>(string key, T defaultValue)
240
246
/// <param name = "secondKeyPart">The second key part</param>
241
247
/// <param name = "defaultValue">The default value</param>
242
248
/// <returns>The configuration value, or <c>defaultValue</c> if not set</returns>
243
- public T Get < T > ( string firstKeyPart , string secondKeyPart , T defaultValue )
249
+ public virtual T Get < T > ( string firstKeyPart , string secondKeyPart , T defaultValue )
244
250
{
245
251
Ensure . ArgumentNotNull ( firstKeyPart , "firstKeyPart" ) ;
246
252
Ensure . ArgumentNotNull ( secondKeyPart , "secondKeyPart" ) ;
@@ -271,7 +277,7 @@ public T Get<T>(string firstKeyPart, string secondKeyPart, T defaultValue)
271
277
/// <param name = "thirdKeyPart">The third key part</param>
272
278
/// <param name = "defaultValue">The default value</param>
273
279
/// <returns>The configuration value, or <c>defaultValue</c> if not set</returns>
274
- public T Get < T > ( string firstKeyPart , string secondKeyPart , string thirdKeyPart , T defaultValue )
280
+ public virtual T Get < T > ( string firstKeyPart , string secondKeyPart , string thirdKeyPart , T defaultValue )
275
281
{
276
282
Ensure . ArgumentNotNull ( firstKeyPart , "firstKeyPart" ) ;
277
283
Ensure . ArgumentNotNull ( secondKeyPart , "secondKeyPart" ) ;
@@ -301,7 +307,7 @@ public T Get<T>(string firstKeyPart, string secondKeyPart, string thirdKeyPart,
301
307
/// <param name = "keyParts">The key parts</param>
302
308
/// <param name = "defaultValue">The default value</param>
303
309
/// <returns>The configuration value, or <c>defaultValue</c> if not set</returns>
304
- public T Get < T > ( string [ ] keyParts , T defaultValue )
310
+ public virtual T Get < T > ( string [ ] keyParts , T defaultValue )
305
311
{
306
312
Ensure . ArgumentNotNull ( keyParts , "keyParts" ) ;
307
313
@@ -331,7 +337,7 @@ private void Save()
331
337
/// <param name = "key">The key parts</param>
332
338
/// <param name = "value">The default value</param>
333
339
/// <param name = "level">The configuration file which should be considered as the target of this operation</param>
334
- public void Set < T > ( string key , T value , ConfigurationLevel level = ConfigurationLevel . Local )
340
+ public virtual void Set < T > ( string key , T value , ConfigurationLevel level = ConfigurationLevel . Local )
335
341
{
336
342
Ensure . ArgumentNotNullOrEmptyString ( key , "key" ) ;
337
343
0 commit comments