@@ -23,6 +23,7 @@ public class ConfigProviderTests : TestBase
23
23
private string repoPath ;
24
24
private IFileSystem fileSystem ;
25
25
private IConfigFileLocator configFileLocator ;
26
+ private IConfigurationProvider configurationProvider ;
26
27
27
28
[ SetUp ]
28
29
public void Setup ( )
@@ -32,6 +33,9 @@ public void Setup()
32
33
configFileLocator = new DefaultConfigFileLocator ( fileSystem , log ) ;
33
34
repoPath = DefaultRepoPath ;
34
35
36
+ var gitPreparer = new GitPreparer ( log , new Arguments { TargetPath = repoPath } ) ;
37
+ configurationProvider = new ConfigurationProvider ( fileSystem , log , configFileLocator , gitPreparer ) ;
38
+
35
39
ShouldlyConfiguration . ShouldMatchApprovedDefaults . LocateTestMethodUsingAttribute < TestAttribute > ( ) ;
36
40
}
37
41
@@ -53,7 +57,7 @@ public void CanReadOldDocument()
53
57
tag: rc
54
58
" ;
55
59
SetupConfigFileContent ( text ) ;
56
- var error = Should . Throw < OldConfigurationException > ( ( ) => ConfigurationProvider . Provide ( repoPath , configFileLocator ) ) ;
60
+ var error = Should . Throw < OldConfigurationException > ( ( ) => configurationProvider . Provide ( repoPath ) ) ;
57
61
error . Message . ShouldContainWithoutWhitespace ( @"GitVersion configuration file contains old configuration, please fix the following errors:
58
62
GitVersion branch configs no longer are keyed by regexes, update:
59
63
dev(elop)?(ment)?$ -> develop
@@ -66,15 +70,15 @@ assemblyVersioningScheme has been replaced by assembly-versioning-scheme
66
70
[ Test ]
67
71
public void OverwritesDefaultsWithProvidedConfig ( )
68
72
{
69
- var defaultConfig = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
73
+ var defaultConfig = configurationProvider . Provide ( repoPath ) ;
70
74
const string text = @"
71
75
next-version: 2.0.0
72
76
branches:
73
77
develop:
74
78
mode: ContinuousDeployment
75
79
tag: dev" ;
76
80
SetupConfigFileContent ( text ) ;
77
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
81
+ var config = configurationProvider . Provide ( repoPath ) ;
78
82
79
83
config . NextVersion . ShouldBe ( "2.0.0" ) ;
80
84
config . Branches [ "develop" ] . Increment . ShouldBe ( defaultConfig . Branches [ "develop" ] . Increment ) ;
@@ -87,7 +91,7 @@ public void AllBranchesModeWhenUsingMainline()
87
91
{
88
92
const string text = @"mode: Mainline" ;
89
93
SetupConfigFileContent ( text ) ;
90
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
94
+ var config = configurationProvider . Provide ( repoPath ) ;
91
95
var branches = config . Branches . Select ( x => x . Value ) ;
92
96
branches . All ( branch => branch . VersioningMode == VersioningMode . Mainline ) . ShouldBe ( true ) ;
93
97
}
@@ -101,7 +105,7 @@ public void CanRemoveTag()
101
105
release:
102
106
tag: """"" ;
103
107
SetupConfigFileContent ( text ) ;
104
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
108
+ var config = configurationProvider . Provide ( repoPath ) ;
105
109
106
110
config . NextVersion . ShouldBe ( "2.0.0" ) ;
107
111
config . Branches [ "release" ] . Tag . ShouldBe ( string . Empty ) ;
@@ -116,7 +120,7 @@ public void RegexIsRequired()
116
120
bug:
117
121
tag: bugfix" ;
118
122
SetupConfigFileContent ( text ) ;
119
- var ex = Should . Throw < GitVersionConfigurationException > ( ( ) => ConfigurationProvider . Provide ( repoPath , configFileLocator ) ) ;
123
+ var ex = Should . Throw < GitVersionConfigurationException > ( ( ) => configurationProvider . Provide ( repoPath ) ) ;
120
124
ex . Message . ShouldBe ( "Branch configuration 'bug' is missing required configuration 'regex'\n \n " +
121
125
"See http://gitversion.readthedocs.io/en/latest/configuration/ for more info" ) ;
122
126
}
@@ -131,7 +135,7 @@ public void SourceBranchIsRequired()
131
135
regex: 'bug[/-]'
132
136
tag: bugfix" ;
133
137
SetupConfigFileContent ( text ) ;
134
- var ex = Should . Throw < GitVersionConfigurationException > ( ( ) => ConfigurationProvider . Provide ( repoPath , configFileLocator ) ) ;
138
+ var ex = Should . Throw < GitVersionConfigurationException > ( ( ) => configurationProvider . Provide ( repoPath ) ) ;
135
139
ex . Message . ShouldBe ( "Branch configuration 'bug' is missing required configuration 'source-branches'\n \n " +
136
140
"See http://gitversion.readthedocs.io/en/latest/configuration/ for more info" ) ;
137
141
}
@@ -147,7 +151,7 @@ public void CanProvideConfigForNewBranch()
147
151
tag: bugfix
148
152
source-branches: []" ;
149
153
SetupConfigFileContent ( text ) ;
150
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
154
+ var config = configurationProvider . Provide ( repoPath ) ;
151
155
152
156
config . Branches [ "bug" ] . Regex . ShouldBe ( "bug[/-]" ) ;
153
157
config . Branches [ "bug" ] . Tag . ShouldBe ( "bugfix" ) ;
@@ -158,7 +162,7 @@ public void NextVersionCanBeInteger()
158
162
{
159
163
const string text = "next-version: 2" ;
160
164
SetupConfigFileContent ( text ) ;
161
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
165
+ var config = configurationProvider . Provide ( repoPath ) ;
162
166
163
167
config . NextVersion . ShouldBe ( "2.0" ) ;
164
168
}
@@ -168,7 +172,7 @@ public void NextVersionCanHaveEnormousMinorVersion()
168
172
{
169
173
const string text = "next-version: 2.118998723" ;
170
174
SetupConfigFileContent ( text ) ;
171
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
175
+ var config = configurationProvider . Provide ( repoPath ) ;
172
176
173
177
config . NextVersion . ShouldBe ( "2.118998723" ) ;
174
178
}
@@ -178,7 +182,7 @@ public void NextVersionCanHavePatch()
178
182
{
179
183
const string text = "next-version: 2.12.654651698" ;
180
184
SetupConfigFileContent ( text ) ;
181
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
185
+ var config = configurationProvider . Provide ( repoPath ) ;
182
186
183
187
config . NextVersion . ShouldBe ( "2.12.654651698" ) ;
184
188
}
@@ -189,7 +193,7 @@ public void NextVersionCanHavePatch()
189
193
[ Description ( "Won't run on Mono due to source information not being available for ShouldMatchApproved." ) ]
190
194
public void CanWriteOutEffectiveConfiguration ( )
191
195
{
192
- var config = ConfigurationProvider . GetEffectiveConfigAsString ( repoPath , configFileLocator ) ;
196
+ var config = configurationProvider . GetEffectiveConfigAsString ( repoPath ) ;
193
197
194
198
config . ShouldMatchApproved ( ) ;
195
199
}
@@ -204,7 +208,7 @@ public void CanUpdateAssemblyInformationalVersioningScheme()
204
208
205
209
SetupConfigFileContent ( text ) ;
206
210
207
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
211
+ var config = configurationProvider . Provide ( repoPath ) ;
208
212
config . AssemblyVersioningScheme . ShouldBe ( AssemblyVersioningScheme . MajorMinor ) ;
209
213
config . AssemblyFileVersioningScheme . ShouldBe ( AssemblyFileVersioningScheme . MajorMinorPatch ) ;
210
214
config . AssemblyInformationalFormat . ShouldBe ( "{NugetVersion}" ) ;
@@ -220,7 +224,7 @@ public void CanUpdateAssemblyInformationalVersioningSchemeWithMultipleVariables(
220
224
221
225
SetupConfigFileContent ( text ) ;
222
226
223
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
227
+ var config = configurationProvider . Provide ( repoPath ) ;
224
228
config . AssemblyVersioningScheme . ShouldBe ( AssemblyVersioningScheme . MajorMinor ) ;
225
229
config . AssemblyFileVersioningScheme . ShouldBe ( AssemblyFileVersioningScheme . MajorMinorPatch ) ;
226
230
config . AssemblyInformationalFormat . ShouldBe ( "{Major}.{Minor}.{Patch}" ) ;
@@ -239,7 +243,7 @@ public void CanUpdateAssemblyInformationalVersioningSchemeWithFullSemVer()
239
243
240
244
SetupConfigFileContent ( text ) ;
241
245
242
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
246
+ var config = configurationProvider . Provide ( repoPath ) ;
243
247
config . AssemblyVersioningScheme . ShouldBe ( AssemblyVersioningScheme . MajorMinorPatch ) ;
244
248
config . AssemblyFileVersioningScheme . ShouldBe ( AssemblyFileVersioningScheme . MajorMinorPatch ) ;
245
249
config . AssemblyInformationalFormat . ShouldBe ( "{FullSemVer}" ) ;
@@ -250,7 +254,7 @@ public void CanReadDefaultDocument()
250
254
{
251
255
const string text = "" ;
252
256
SetupConfigFileContent ( text ) ;
253
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
257
+ var config = configurationProvider . Provide ( repoPath ) ;
254
258
config . AssemblyVersioningScheme . ShouldBe ( AssemblyVersioningScheme . MajorMinorPatch ) ;
255
259
config . AssemblyFileVersioningScheme . ShouldBe ( AssemblyFileVersioningScheme . MajorMinorPatch ) ;
256
260
config . AssemblyInformationalFormat . ShouldBe ( null ) ;
@@ -284,8 +288,11 @@ public void NoWarnOnGitVersionYmlFile()
284
288
var log = new Log ( logAppender ) ;
285
289
286
290
var defaultConfigFileLocator = new DefaultConfigFileLocator ( fileSystem , log ) ;
291
+ var gitPreparer = new GitPreparer ( log , new Arguments { TargetPath = repoPath } ) ;
292
+
293
+ configurationProvider = new ConfigurationProvider ( fileSystem , log , defaultConfigFileLocator , gitPreparer ) ;
287
294
288
- ConfigurationProvider . Provide ( repoPath , defaultConfigFileLocator ) ;
295
+ configurationProvider . Provide ( repoPath ) ;
289
296
290
297
stringLogger . Length . ShouldBe ( 0 ) ;
291
298
}
@@ -314,7 +321,7 @@ public void ShouldUseSpecifiedSourceBranchesForDevelop()
314
321
source-branches: ['develop']
315
322
tag: dev" ;
316
323
SetupConfigFileContent ( text ) ;
317
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
324
+ var config = configurationProvider . Provide ( repoPath ) ;
318
325
319
326
config . Branches [ "develop" ] . SourceBranches . ShouldBe ( new List < string > { "develop" } ) ;
320
327
}
@@ -329,7 +336,7 @@ public void ShouldUseDefaultSourceBranchesWhenNotSpecifiedForDevelop()
329
336
mode: ContinuousDeployment
330
337
tag: dev" ;
331
338
SetupConfigFileContent ( text ) ;
332
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
339
+ var config = configurationProvider . Provide ( repoPath ) ;
333
340
334
341
config . Branches [ "develop" ] . SourceBranches . ShouldBe ( new List < string > ( ) ) ;
335
342
}
@@ -345,7 +352,7 @@ public void ShouldUseSpecifiedSourceBranchesForFeature()
345
352
source-branches: ['develop', 'release']
346
353
tag: dev" ;
347
354
SetupConfigFileContent ( text ) ;
348
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
355
+ var config = configurationProvider . Provide ( repoPath ) ;
349
356
350
357
config . Branches [ "feature" ] . SourceBranches . ShouldBe ( new List < string > { "develop" , "release" } ) ;
351
358
}
@@ -360,7 +367,7 @@ public void ShouldUseDefaultSourceBranchesWhenNotSpecifiedForFeature()
360
367
mode: ContinuousDeployment
361
368
tag: dev" ;
362
369
SetupConfigFileContent ( text ) ;
363
- var config = ConfigurationProvider . Provide ( repoPath , configFileLocator ) ;
370
+ var config = configurationProvider . Provide ( repoPath ) ;
364
371
365
372
config . Branches [ "feature" ] . SourceBranches . ShouldBe (
366
373
new List < string > { "develop" , "master" , "release" , "feature" , "support" , "hotfix" } ) ;
0 commit comments