Skip to content

Commit f509c86

Browse files
author
Ruh Ullah Shah
committed
Added approval test
1 parent bcbf146 commit f509c86

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<?define AssemblySemFileVer="1.2.3.0"?>
4+
<?define AssemblySemVer="1.2.3.0"?>
5+
<?define BranchName="develop"?>
6+
<?define BuildMetaData="5"?>
7+
<?define BuildMetaDataPadded="05"?>
8+
<?define CommitDate="2019-02-20"?>
9+
<?define CommitsSinceVersionSource="5"?>
10+
<?define CommitsSinceVersionSourcePadded="0005"?>
11+
<?define FullBuildMetaData="5.Branch.develop.Sha.commitSha"?>
12+
<?define FullSemVer="1.2.3+5"?>
13+
<?define InformationalVersion="1.2.3+5.Branch.develop.Sha.commitSha"?>
14+
<?define LegacySemVer="1.2.3"?>
15+
<?define LegacySemVerPadded="1.2.3"?>
16+
<?define Major="1"?>
17+
<?define MajorMinorPatch="1.2.3"?>
18+
<?define Minor="2"?>
19+
<?define NuGetPreReleaseTag=""?>
20+
<?define NuGetPreReleaseTagV2=""?>
21+
<?define NuGetVersion="1.2.3"?>
22+
<?define NuGetVersionV2="1.2.3"?>
23+
<?define Patch="3"?>
24+
<?define PreReleaseLabel=""?>
25+
<?define PreReleaseNumber=""?>
26+
<?define PreReleaseTag=""?>
27+
<?define PreReleaseTagWithDash=""?>
28+
<?define SemVer="1.2.3"?>
29+
<?define Sha="commitSha"?>
30+
<?define ShortSha="commitShortSha"?>
31+
</Include>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
namespace GitVersionCore.Tests
2+
{
3+
using System;
4+
using System.IO;
5+
using System.Text;
6+
using GitVersion;
7+
using NUnit.Framework;
8+
using Shouldly;
9+
10+
[TestFixture]
11+
[Parallelizable(ParallelScope.None)]
12+
class WixFileTests
13+
{
14+
[SetUp]
15+
public void Setup()
16+
{
17+
ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute<TestAttribute>();
18+
}
19+
20+
[Test]
21+
[Category("NoMono")]
22+
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
23+
public void UpdateWixVersionFile()
24+
{
25+
var fileSystem = new TestFileSystem();
26+
var workingDir = Path.GetTempPath();
27+
var semVer = new SemanticVersion
28+
{
29+
Major = 1,
30+
Minor = 2,
31+
Patch = 3,
32+
BuildMetaData = "5.Branch.develop"
33+
};
34+
35+
semVer.BuildMetaData.Sha = "commitSha";
36+
semVer.BuildMetaData.ShortSha = "commitShortSha";
37+
semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2019-02-20 23:59:59Z");
38+
39+
var config = new TestEffectiveConfiguration(buildMetaDataPadding: 2, legacySemVerPadding: 5);
40+
var vars = VariableProvider.GetVariablesFor(semVer, config, false);
41+
42+
StringBuilder log = new StringBuilder();
43+
Action<string> action = s => log.AppendLine(s);
44+
Logger.SetLoggers(action, action, action, action);
45+
using (var wixVersionFileUpdater = new WixVersionFileUpdater(workingDir, vars, fileSystem))
46+
{
47+
wixVersionFileUpdater.Update();
48+
}
49+
50+
fileSystem.ReadAllText(WixVersionFileUpdater.GetWixVersionFileName()).
51+
ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved")));
52+
}
53+
}
54+
}

src/GitVersionExe.Tests/UpdateWixVersionFileTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GitVersionExe.Tests
1+
namespace GitVersionExe.Tests
22
{
33
using System.IO;
44
using System.Linq;
@@ -10,6 +10,7 @@
1010
using System.Xml;
1111

1212
[TestFixture]
13+
[Parallelizable(ParallelScope.None)]
1314
class UpdateWixVersionFileTests
1415
{
1516
private string WixVersionFileName;
@@ -99,4 +100,4 @@ private Dictionary<string, string> GetGitVersionVarsInWixFile(string file)
99100
return gitVersionVarsInWix;
100101
}
101102
}
102-
}
103+
}

0 commit comments

Comments
 (0)