11namespace GitVersionExe . Tests
22{
3+ using System ;
34 using System . Collections . Generic ;
45 using System . IO ;
56 using GitVersion ;
@@ -19,5 +20,81 @@ public void ShouldStartSearchFromWorkingDirectory()
1920 fileSystem . Received ( ) . DirectoryGetFiles ( Arg . Is ( workingDir ) , Arg . Any < string > ( ) , Arg . Any < SearchOption > ( ) ) ;
2021 }
2122 }
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+ }
2299 }
23100}
0 commit comments