Skip to content

Commit 85518e2

Browse files
committed
Add test which verifies #257 is fixed
1 parent ee30817 commit 85518e2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/GitVersionExe.Tests/AssemblyInfoFileUpdateTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,41 @@ public void ShouldReplaceAssemblyVersionWithStar()
9191
{
9292
const string expected = @"AssemblyVersion(""2.3.0.0"");
9393
AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"");
94+
AssemblyFileVersion(""2.3.1.0"");";
95+
fileSystem.Received().WriteAllText("C:\\Testing\\AssemblyInfo.cs", expected);
96+
}
97+
}
98+
99+
[Test] public void ShouldReplaceAlreadySubstitutedValues()
100+
{
101+
var fileSystem = Substitute.For<IFileSystem>();
102+
var version = new SemanticVersion
103+
{
104+
BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now),
105+
Major = 2,
106+
Minor = 3,
107+
Patch = 1
108+
};
109+
110+
const string workingDir = "C:\\Testing";
111+
const string assemblyInfoFile = @"AssemblyVersion(""2.2.0.0"");
112+
AssemblyInformationalVersion(""2.2.0+5.Branch.foo.Sha.hash"");
113+
AssemblyFileVersion(""2.2.0.0"");";
114+
115+
fileSystem.Exists("C:\\Testing\\AssemblyInfo.cs").Returns(true);
116+
fileSystem.ReadAllText("C:\\Testing\\AssemblyInfo.cs").Returns(assemblyInfoFile);
117+
118+
var config = new TestEffectiveConfiguration(assemblyVersioningScheme: AssemblyVersioningScheme.MajorMinor);
119+
var variable = VariableProvider.GetVariablesFor(version, config, false);
120+
var args = new Arguments
121+
{
122+
UpdateAssemblyInfo = true,
123+
UpdateAssemblyInfoFileName = "AssemblyInfo.cs"
124+
};
125+
using (new AssemblyInfoFileUpdate(args, workingDir, variable, fileSystem))
126+
{
127+
const string expected = @"AssemblyVersion(""2.3.0.0"");
128+
AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"");
94129
AssemblyFileVersion(""2.3.1.0"");";
95130
fileSystem.Received().WriteAllText("C:\\Testing\\AssemblyInfo.cs", expected);
96131
}

0 commit comments

Comments
 (0)