Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Commit 0cd58c8

Browse files
Merge pull request #57 from 304NotModified/refactor-tests-assert
Refactor tests 2
2 parents f9c48a6 + ffa6539 commit 0cd58c8

3 files changed

Lines changed: 47 additions & 17 deletions

File tree

Tests/PatchAssemblyTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@ public PatchAssemblyTests() : base("AssemblyToProcess")
1010
{
1111
}
1212

13-
protected override void AssertVersion(string version)
13+
protected override void AssertProductionVersion(string version)
14+
{
15+
AssertVersionWithHeadAndSha(version);
16+
}
17+
18+
protected override void AssertFileVersion(string version)
19+
{
20+
Assert.AreEqual("1.0.0.0", version);
21+
}
22+
23+
protected override void AssertInformationalVersion(string version)
24+
{
25+
AssertVersionWithHeadAndSha(version);
26+
}
27+
28+
private static void AssertVersionWithHeadAndSha(string version)
1429
{
1530
Assert.IsNotNull(version);
1631
Assert.IsNotEmpty(version);

Tests/PatchAssemblyTestsBase.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,40 @@ protected PatchAssemblyTestsBase(string assemblyName)
4848
_patchedAssembly = Assembly.LoadFile(_patchedAssemblyPath);
4949
}
5050

51+
protected abstract void AssertProductionVersion(string version);
52+
53+
protected abstract void AssertFileVersion(string version);
54+
55+
protected abstract void AssertInformationalVersion(string version);
56+
5157
[Test]
5258
public void InformationalVersionSetCorrectly()
5359
{
5460
var customAttributes = GetAssemblyInformationalVersionAttribute(_patchedAssembly);
5561

5662
// Assert
57-
AssertVersion(customAttributes.InformationalVersion);
63+
var version = customAttributes.InformationalVersion;
64+
AssertInformationalVersion(version);
5865
}
59-
66+
6067
[Test]
6168
public void FileVersionSetCorrectly()
6269
{
6370
var versionInfo = FileVersionInfo.GetVersionInfo(_patchedAssemblyPath);
64-
65-
Assert.IsNotNull(versionInfo.FileVersion);
66-
Assert.IsNotEmpty(versionInfo.FileVersion);
67-
Assert.AreEqual("1.0.0.0", versionInfo.FileVersion);
71+
var version = versionInfo.FileVersion;
72+
AssertFileVersion(version);
6873
}
69-
74+
7075
[Test]
7176
public void ProductionVersionSetCorrectly()
7277
{
7378
var versionInfo = FileVersionInfo.GetVersionInfo(_patchedAssemblyPath);
7479

7580
// Assert
76-
AssertVersion(versionInfo.ProductVersion);
81+
var version = versionInfo.ProductVersion;
82+
AssertProductionVersion(version);
7783
}
78-
79-
80-
84+
8185
#if(DEBUG)
8286
[Test]
8387
public void PeVerify()
@@ -86,10 +90,6 @@ public void PeVerify()
8690
}
8791
#endif
8892

89-
90-
protected abstract void AssertVersion(string version);
91-
92-
9393
private static string GetAssemblyToPatchPath(string assemblyName)
9494
{
9595

Tests/PatchExistingAssemblyTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ public PatchExistingAssemblyTests() : base("AssemblyToProcessExistingAttribute")
99
{
1010
}
1111

12-
protected override void AssertVersion(string version)
12+
protected override void AssertProductionVersion(string version)
13+
{
14+
AssertVersionWithBranch(version);
15+
}
16+
17+
protected override void AssertFileVersion(string version)
18+
{
19+
Assert.AreEqual("1.0.0.0", version);
20+
}
21+
22+
protected override void AssertInformationalVersion(string version)
23+
{
24+
AssertVersionWithBranch(version);
25+
}
26+
27+
private static void AssertVersionWithBranch(string version)
1328
{
1429
using (var repo = new Repository(Repository.Discover(TestContext.CurrentContext.TestDirectory)))
1530
{

0 commit comments

Comments
 (0)