9
9
using GitVersion . Extensions ;
10
10
using GitVersion . Extensions . VersionAssemblyInfoResources ;
11
11
using GitVersion . Common ;
12
+ using GitVersion . Logging ;
12
13
13
14
namespace GitVersionCore . Tests
14
15
{
15
16
[ TestFixture ]
16
17
[ Parallelizable ( ParallelScope . None ) ]
17
18
public class AssemblyInfoFileUpdaterTests : TestBase
18
19
{
20
+ private IVariableProvider variableProvider ;
21
+ private ILog log ;
22
+
19
23
[ SetUp ]
20
24
public void Setup ( )
21
25
{
22
26
ShouldlyConfiguration . ShouldMatchApprovedDefaults . LocateTestMethodUsingAttribute < TestCaseAttribute > ( ) ;
27
+ log = new NullLog ( ) ;
28
+ variableProvider = new VariableProvider ( log ) ;
23
29
}
24
30
25
31
[ TestCase ( "cs" ) ]
@@ -33,9 +39,9 @@ public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(strin
33
39
var workingDir = Path . GetTempPath ( ) ;
34
40
var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension ;
35
41
var fullPath = Path . Combine ( workingDir , assemblyInfoFile ) ;
36
- var variables = VariableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
42
+ var variables = variableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
37
43
38
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , true ) )
44
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , true ) )
39
45
{
40
46
assemblyInfoFileUpdater . Update ( ) ;
41
47
@@ -54,9 +60,9 @@ public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo
54
60
var workingDir = Path . GetTempPath ( ) ;
55
61
var assemblyInfoFile = Path . Combine ( "src" , "Project" , "Properties" , "VersionAssemblyInfo." + fileExtension ) ;
56
62
var fullPath = Path . Combine ( workingDir , assemblyInfoFile ) ;
57
- var variables = VariableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
63
+ var variables = variableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
58
64
59
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , true ) )
65
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , true ) )
60
66
{
61
67
assemblyInfoFileUpdater . Update ( ) ;
62
68
@@ -78,9 +84,9 @@ public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInf
78
84
"AssemblyInfo." + fileExtension ,
79
85
Path . Combine ( "src" , "Project" , "Properties" , "VersionAssemblyInfo." + fileExtension )
80
86
} ;
81
- var variables = VariableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
87
+ var variables = variableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
82
88
83
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFiles , workingDir , variables , fileSystem , true ) )
89
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFiles , workingDir , variables , fileSystem , log , true ) )
84
90
{
85
91
assemblyInfoFileUpdater . Update ( ) ;
86
92
@@ -101,9 +107,9 @@ public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo
101
107
var workingDir = Path . GetTempPath ( ) ;
102
108
var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension ;
103
109
var fullPath = Path . Combine ( workingDir , assemblyInfoFile ) ;
104
- var variables = VariableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
110
+ var variables = variableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
105
111
106
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
112
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
107
113
{
108
114
assemblyInfoFileUpdater . Update ( ) ;
109
115
@@ -118,9 +124,9 @@ public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssembly
118
124
var workingDir = Path . GetTempPath ( ) ;
119
125
var assemblyInfoFile = "VersionAssemblyInfo.js" ;
120
126
var fullPath = Path . Combine ( workingDir , assemblyInfoFile ) ;
121
- var variables = VariableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
127
+ var variables = variableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
122
128
123
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , true ) )
129
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , true ) )
124
130
{
125
131
assemblyInfoFileUpdater . Update ( ) ;
126
132
@@ -134,9 +140,9 @@ public void ShouldStartSearchFromWorkingDirectory()
134
140
var fileSystem = Substitute . For < IFileSystem > ( ) ;
135
141
var workingDir = Path . GetTempPath ( ) ;
136
142
var assemblyInfoFiles = new HashSet < string > ( ) ;
137
- var variables = VariableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
143
+ var variables = variableProvider . GetVariablesFor ( SemanticVersion . Parse ( "1.0.0" , "v" ) , new TestEffectiveConfiguration ( ) , false ) ;
138
144
139
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFiles , workingDir , variables , fileSystem , false ) )
145
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFiles , workingDir , variables , fileSystem , log , false ) )
140
146
{
141
147
assemblyInfoFileUpdater . Update ( ) ;
142
148
@@ -155,7 +161,7 @@ public void ShouldReplaceAssemblyVersion(string fileExtension, string assemblyFi
155
161
156
162
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
157
163
{
158
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
164
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
159
165
{
160
166
assemblyInfoFileUpdater . Update ( ) ;
161
167
@@ -180,7 +186,7 @@ public void ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone(string fileEx
180
186
181
187
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . None , verify : ( fileSystem , variables ) =>
182
188
{
183
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
189
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
184
190
{
185
191
assemblyInfoFileUpdater . Update ( ) ;
186
192
@@ -201,7 +207,7 @@ public void ShouldReplaceAssemblyVersionInRelativePath(string fileExtension, str
201
207
202
208
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
203
209
{
204
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
210
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
205
211
{
206
212
assemblyInfoFileUpdater . Update ( ) ;
207
213
@@ -224,7 +230,7 @@ public void ShouldReplaceAssemblyVersionInRelativePathWithWhiteSpace(string file
224
230
225
231
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
226
232
{
227
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
233
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
228
234
{
229
235
assemblyInfoFileUpdater . Update ( ) ;
230
236
@@ -247,7 +253,7 @@ public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string as
247
253
248
254
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
249
255
{
250
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
256
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
251
257
{
252
258
assemblyInfoFileUpdater . Update ( ) ;
253
259
@@ -270,7 +276,7 @@ public void ShouldReplaceAssemblyVersionWithAtttributeSuffix(string fileExtensio
270
276
271
277
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , verify : ( fileSystem , variables ) =>
272
278
{
273
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
279
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
274
280
{
275
281
assemblyInfoFileUpdater . Update ( ) ;
276
282
@@ -296,7 +302,7 @@ public void ShouldAddAssemblyVersionIfMissingFromInfoFile(string fileExtension)
296
302
297
303
VerifyAssemblyInfoFile ( "" , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
298
304
{
299
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
305
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
300
306
{
301
307
assemblyInfoFileUpdater . Update ( ) ;
302
308
@@ -319,7 +325,7 @@ public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string a
319
325
320
326
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
321
327
{
322
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
328
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
323
329
{
324
330
assemblyInfoFileUpdater . Update ( ) ;
325
331
@@ -342,7 +348,7 @@ public void ShouldReplaceAssemblyVersionWhenCreatingAssemblyVersionFileAndEnsure
342
348
343
349
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , verify : ( fileSystem , variables ) =>
344
350
{
345
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
351
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
346
352
{
347
353
assemblyInfoFileUpdater . Update ( ) ;
348
354
@@ -365,7 +371,7 @@ public void ShouldReplaceAssemblyVersionInRelativePathWithVariables(string fileE
365
371
366
372
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
367
373
{
368
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
374
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
369
375
{
370
376
assemblyInfoFileUpdater . Update ( ) ;
371
377
@@ -388,7 +394,7 @@ public void ShouldReplaceAssemblyVersionInRelativePathWithVariablesAndWhiteSpace
388
394
389
395
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . MajorMinor , ( fileSystem , variables ) =>
390
396
{
391
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
397
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
392
398
{
393
399
assemblyInfoFileUpdater . Update ( ) ;
394
400
@@ -413,7 +419,7 @@ public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile
413
419
414
420
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , verify : ( fileSystem , variables ) =>
415
421
{
416
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
422
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
417
423
{
418
424
assemblyInfoFileUpdater . Update ( ) ;
419
425
@@ -436,7 +442,7 @@ public void Issue1183_ShouldAddFSharpAssemblyInformationalVersionBesideOtherAttr
436
442
437
443
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , verify : ( fileSystem , variables ) =>
438
444
{
439
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
445
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
440
446
{
441
447
assemblyInfoFileUpdater . Update ( ) ;
442
448
@@ -459,7 +465,7 @@ public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionF
459
465
460
466
VerifyAssemblyInfoFile ( assemblyFileContent , fileName , AssemblyVersioningScheme . None , verify : ( fileSystem , variables ) =>
461
467
{
462
- using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , false ) )
468
+ using ( var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater ( assemblyInfoFile , workingDir , variables , fileSystem , log , false ) )
463
469
{
464
470
assemblyInfoFileUpdater . Update ( ) ;
465
471
@@ -469,7 +475,7 @@ public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionF
469
475
} ) ;
470
476
}
471
477
472
- private static void VerifyAssemblyInfoFile (
478
+ private void VerifyAssemblyInfoFile (
473
479
string assemblyFileContent ,
474
480
string fileName ,
475
481
AssemblyVersioningScheme versioningScheme = AssemblyVersioningScheme . MajorMinorPatch ,
@@ -493,7 +499,7 @@ private static void VerifyAssemblyInfoFile(
493
499
} ) ;
494
500
495
501
var config = new TestEffectiveConfiguration ( assemblyVersioningScheme : versioningScheme ) ;
496
- var variables = VariableProvider . GetVariablesFor ( version , config , false ) ;
502
+ var variables = variableProvider . GetVariablesFor ( version , config , false ) ;
497
503
498
504
verify ? . Invoke ( fileSystem , variables ) ;
499
505
}
0 commit comments