1
1
namespace GitVersionExe . Tests
2
2
{
3
+ using System ;
3
4
using System . Collections . Generic ;
4
5
using System . IO ;
5
6
using GitVersion ;
@@ -19,5 +20,81 @@ public void ShouldStartSearchFromWorkingDirectory()
19
20
fileSystem . Received ( ) . DirectoryGetFiles ( Arg . Is ( workingDir ) , Arg . Any < string > ( ) , Arg . Any < SearchOption > ( ) ) ;
20
21
}
21
22
}
23
+
24
+ [ Test ]
25
+ public void ShouldReplaceAssemblyVersion ( )
26
+ {
27
+ var fileSystem = Substitute . For < IFileSystem > ( ) ;
28
+ var version = new SemanticVersion ( )
29
+ {
30
+ BuildMetaData = new SemanticVersionBuildMetaData ( 3 , "foo" , "hash" , DateTimeOffset . Now ) ,
31
+ Major = 2 ,
32
+ Minor = 3 ,
33
+ Patch = 1
34
+ } ;
35
+
36
+ const string workingDir = "C:\\ Testing" ;
37
+ const string assemblyInfoFile = @"AssemblyVersion(""1.0.0.0"");
38
+ AssemblyInformationalVersion(""1.0.0.0"");
39
+ AssemblyFileVersion(""1.0.0.0"");" ;
40
+
41
+ fileSystem . Exists ( "C:\\ Testing\\ AssemblyInfo.cs" ) . Returns ( true ) ;
42
+ fileSystem . ReadAllText ( "C:\\ Testing\\ AssemblyInfo.cs" ) . Returns ( assemblyInfoFile ) ;
43
+ var config = new Config ( )
44
+ {
45
+ AssemblyVersioningScheme = AssemblyVersioningScheme . MajorMinorPatch
46
+ } ;
47
+ var variable = VariableProvider . GetVariablesFor ( version , config ) ;
48
+ var args = new Arguments
49
+ {
50
+ UpdateAssemblyInfo = true ,
51
+ UpdateAssemblyInfoFileName = "AssemblyInfo.cs"
52
+ } ;
53
+ using ( new AssemblyInfoFileUpdate ( args , workingDir , variable , fileSystem ) )
54
+ {
55
+ const string expected = @"AssemblyVersion(""2.3.0.0"");
56
+ AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"");
57
+ AssemblyFileVersion(""2.3.1.0"");" ;
58
+ fileSystem . Received ( ) . WriteAllText ( "C:\\ Testing\\ AssemblyInfo.cs" , expected ) ;
59
+ }
60
+ }
61
+
62
+ [ Test ]
63
+ public void ShouldReplaceAssemblyVersionWithStar ( )
64
+ {
65
+ var fileSystem = Substitute . For < IFileSystem > ( ) ;
66
+ var version = new SemanticVersion ( )
67
+ {
68
+ BuildMetaData = new SemanticVersionBuildMetaData ( 3 , "foo" , "hash" , DateTimeOffset . Now ) ,
69
+ Major = 2 ,
70
+ Minor = 3 ,
71
+ Patch = 1
72
+ } ;
73
+
74
+ const string workingDir = "C:\\ Testing" ;
75
+ const string assemblyInfoFile = @"AssemblyVersion(""1.0.0.*"");
76
+ AssemblyInformationalVersion(""1.0.0.*"");
77
+ AssemblyFileVersion(""1.0.0.*"");" ;
78
+
79
+ fileSystem . Exists ( "C:\\ Testing\\ AssemblyInfo.cs" ) . Returns ( true ) ;
80
+ fileSystem . ReadAllText ( "C:\\ Testing\\ AssemblyInfo.cs" ) . Returns ( assemblyInfoFile ) ;
81
+ var config = new Config ( )
82
+ {
83
+ AssemblyVersioningScheme = AssemblyVersioningScheme . MajorMinorPatch
84
+ } ;
85
+ var variable = VariableProvider . GetVariablesFor ( version , config ) ;
86
+ var args = new Arguments
87
+ {
88
+ UpdateAssemblyInfo = true ,
89
+ UpdateAssemblyInfoFileName = "AssemblyInfo.cs"
90
+ } ;
91
+ using ( new AssemblyInfoFileUpdate ( args , workingDir , variable , fileSystem ) )
92
+ {
93
+ const string expected = @"AssemblyVersion(""2.3.0.0"");
94
+ AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"");
95
+ AssemblyFileVersion(""2.3.1.0"");" ;
96
+ fileSystem . Received ( ) . WriteAllText ( "C:\\ Testing\\ AssemblyInfo.cs" , expected ) ;
97
+ }
98
+ }
22
99
}
23
100
}
0 commit comments