Skip to content

Commit fc4ebb0

Browse files
committed
Enable tests to control what build server to "use"
1 parent 811d65e commit fc4ebb0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

GitFlowVersion/BuildServers/BuildServerList.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace GitFlowVersion
22
{
3+
using System;
34
using System.Collections.Generic;
45

56
public static class BuildServerList
@@ -10,7 +11,19 @@ public static class BuildServerList
1011
new TeamCity()
1112
};
1213

14+
public static Func<IEnumerable<IBuildServer>> Selector = () => DefaultSelector();
15+
16+
public static void ResetSelector()
17+
{
18+
Selector = DefaultSelector;
19+
}
20+
1321
public static IEnumerable<IBuildServer> GetApplicableBuildServers()
22+
{
23+
return Selector();
24+
}
25+
26+
static IEnumerable<IBuildServer> DefaultSelector()
1427
{
1528
foreach (var buildServer in BuildServers)
1629
{

Tests/UpdateAssemblyInfoTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using System.IO;
23
using System.Linq;
34
using GitFlowVersion;
@@ -101,6 +102,19 @@ public void StandardExecutionMode_CannotDetermineTheVersionFromADetachedHead()
101102
Assert.AreEqual("It looks like the branch being examined is a detached Head pointing to commit '469f851'. Without a proper branch name GitFlowVersion cannot determine the build version.", exception.Message);
102103
}
103104

105+
[SetUp]
106+
public void SetUp()
107+
{
108+
//avoid buildserver detection to make the tests pass on the buildserver
109+
BuildServerList.Selector = () => new List<IBuildServer>();
110+
}
111+
112+
113+
[TearDown]
114+
public void TearDown()
115+
{
116+
BuildServerList.ResetSelector();
117+
}
104118
string CheckoutLocal(string repositoryPath, string monitoredReference)
105119
{
106120
var repoPath = Clone(repositoryPath);

0 commit comments

Comments
 (0)