diff --git a/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs b/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs index 83d50cf6ff..c3aecb813a 100644 --- a/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs @@ -3,65 +3,44 @@ using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; -using System.Collections.Generic; [TestFixture] public class VsoAgentBuildNumberTests { string key = "BUILD_BUILDNUMBER"; string logPrefix = "##vso[build.updatebuildnumber]"; - List> examples; VsoAgent versionBuilder = new VsoAgent(); - [SetUp] - public void SetUpVsoAgentBuildNumberTest() - { - examples = new List>(); - } - [TearDown] public void TearDownVsoAgentBuildNumberTest() { - examples = null; Environment.SetEnvironmentVariable(key, null, EnvironmentVariableTarget.Process); } - [Test] - public void VsoAgentBuildNumberWithFullSemVer() + [TestCase("$(GitVersion.FullSemVer)", "1.0.0", "1.0.0")] + [TestCase("$(GITVERSION_FULLSEMVER)", "1.0.0", "1.0.0")] + [TestCase("$(GitVersion.FullSemVer)-Build.1234", "1.0.0", "1.0.0-Build.1234")] + [TestCase("$(GITVERSION_FULLSEMVER)-Build.1234", "1.0.0", "1.0.0-Build.1234")] + public void VsoAgentBuildNumberWithFullSemVer(string buildNumberFormat, string myFullSemVer, string expectedBuildNumber) { - examples.Add(new Tuple("$(GitVersion.FullSemVer)", "1.0.0", "1.0.0")); - examples.Add(new Tuple("$(GITVERSION_FULLSEMVER)", "1.0.0", "1.0.0")); - examples.Add(new Tuple("$(GitVersion.FullSemVer)-Build.1234", "1.0.0", "1.0.0-Build.1234")); - examples.Add(new Tuple("$(GITVERSION_FULLSEMVER)-Build.1234", "1.0.0", "1.0.0-Build.1234")); - - foreach (var example in examples) - { - Environment.SetEnvironmentVariable(key, example.Item1, EnvironmentVariableTarget.Process); - var vars = new TestableVersionVariables(fullSemVer: example.Item2); - - var logMessage = versionBuilder.GenerateSetVersionMessage(vars); - logMessage.ShouldBe(logPrefix + example.Item3); - } + Environment.SetEnvironmentVariable(key, buildNumberFormat, EnvironmentVariableTarget.Process); + var vars = new TestableVersionVariables(fullSemVer: myFullSemVer); + var logMessage = versionBuilder.GenerateSetVersionMessage(vars); + logMessage.ShouldBe(logPrefix + expectedBuildNumber); } - [Test] - public void VsoAgentBuildNumberWithSemVer() + [TestCase("$(GitVersion.SemVer)", "1.0.0", "1.0.0")] + [TestCase("$(GITVERSION_SEMVER)", "1.0.0", "1.0.0")] + [TestCase("$(GitVersion.SemVer)-Build.1234", "1.0.0", "1.0.0-Build.1234")] + [TestCase("$(GITVERSION_SEMVER)-Build.1234", "1.0.0", "1.0.0-Build.1234")] + public void VsoAgentBuildNumberWithSemVer(string buildNumberFormat, string mySemVer, string expectedBuildNumber) { - examples.Add(new Tuple("$(GitVersion.SemVer)", "1.0.0", "1.0.0")); - examples.Add(new Tuple("$(GITVERSION_SEMVER)", "1.0.0", "1.0.0")); - examples.Add(new Tuple("$(GitVersion.SemVer)-Build.1234", "1.0.0", "1.0.0-Build.1234")); - examples.Add(new Tuple("$(GITVERSION_SEMVER)-Build.1234", "1.0.0", "1.0.0-Build.1234")); - - foreach (var example in examples) - { - Environment.SetEnvironmentVariable(key, example.Item1, EnvironmentVariableTarget.Process); - var vars = new TestableVersionVariables(semVer: example.Item2); - - var logMessage = versionBuilder.GenerateSetVersionMessage(vars); - logMessage.ShouldBe(logPrefix + example.Item3); - } + Environment.SetEnvironmentVariable(key, buildNumberFormat, EnvironmentVariableTarget.Process); + var vars = new TestableVersionVariables(semVer: mySemVer); + var logMessage = versionBuilder.GenerateSetVersionMessage(vars); + logMessage.ShouldBe(logPrefix + expectedBuildNumber); } } \ No newline at end of file