-
-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'agc93-feature/GH-1250' into develop
- Loading branch information
Showing
23 changed files
with
1,705 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Cake.Common.Build.TFBuild; | ||
using Cake.Core; | ||
using NSubstitute; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Build | ||
{ | ||
internal sealed class TFBuildFixture | ||
{ | ||
public ICakeEnvironment Environment { get; set; } | ||
|
||
public TFBuildFixture() | ||
{ | ||
Environment = Substitute.For<ICakeEnvironment>(); | ||
Environment.WorkingDirectory.Returns("C:\\build\\CAKE-CAKE-JOB1"); | ||
Environment.GetEnvironmentVariable("TF_BUILD").Returns((string)null); | ||
} | ||
|
||
public void IsRunningOnVSTS() | ||
{ | ||
Environment.GetEnvironmentVariable("TF_BUILD").Returns("True"); | ||
Environment.GetEnvironmentVariable("AGENT_NAME").Returns("Hosted Agent"); | ||
} | ||
|
||
public void IsRunningOnTFS() | ||
{ | ||
Environment.GetEnvironmentVariable("TF_BUILD").Returns("True"); | ||
Environment.GetEnvironmentVariable("AGENT_NAME").Returns("On Premises"); | ||
} | ||
|
||
public TFBuildProvider CreateTFBuildService() | ||
{ | ||
return new TFBuildProvider(Environment); | ||
} | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/Cake.Common.Tests/Fixtures/Build/TFBuildInfoFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Cake.Common.Build.TFBuild.Data; | ||
using Cake.Core; | ||
using NSubstitute; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Build | ||
{ | ||
public sealed class TFBuildInfoFixture | ||
{ | ||
public ICakeEnvironment Environment { get; set; } | ||
|
||
public TFBuildInfoFixture() | ||
{ | ||
Environment = Substitute.For<ICakeEnvironment>(); | ||
|
||
// VSTS RepositoryInfo | ||
Environment.GetEnvironmentVariable("BUILD_SOURCEVERSION").Returns("4efbc1ffb993dfbcf024e6a9202865cc0b6d9c50"); | ||
Environment.GetEnvironmentVariable("BUILD_SOURCETFVCSHELVESET").Returns("Shelveset1"); | ||
Environment.GetEnvironmentVariable("BUILD_REPOSITORY_NAME").Returns("cake"); | ||
Environment.GetEnvironmentVariable("BUILD_REPOSITORY_PROVIDER").Returns("GitHub"); | ||
Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCHNAME").Returns("develop"); | ||
|
||
// VSTS AgentInfo | ||
Environment.GetEnvironmentVariable("AGENT_BUILDDIRECTORY").Returns(@"c:\agent\_work\1"); | ||
Environment.GetEnvironmentVariable("AGENT_HOMEDIRECTORY").Returns(@"c:\agent"); | ||
Environment.GetEnvironmentVariable("AGENT_WORKFOLDER").Returns(@"c:\agent\_work"); | ||
Environment.GetEnvironmentVariable("AGENT_ID").Returns("71"); | ||
Environment.GetEnvironmentVariable("AGENT_NAME").Returns("Agent-1"); | ||
Environment.GetEnvironmentVariable("AGENT_MACHINE_NAME").Returns("BuildServer"); | ||
|
||
// VSTS BuildInfo | ||
Environment.GetEnvironmentVariable("BUILD_BUILDID").Returns("100234"); | ||
Environment.GetEnvironmentVariable("BUILD_BUILDNUMBER").Returns("Build-20160927.1"); | ||
Environment.GetEnvironmentVariable("BUILD_BUILDURI").Returns("vstfs:///Build/Build/1430"); | ||
Environment.GetEnvironmentVariable("BUILD_QUEUEDBY") | ||
.Returns(@"[DefaultCollection]\Project Collection Service Accounts"); | ||
Environment.GetEnvironmentVariable("BUILD_REQUESTEDFOR").Returns("Alistair Chapman"); | ||
Environment.GetEnvironmentVariable("BUILD_REQUESTEDFOREMAIL").Returns("author@mail.com"); | ||
|
||
// VSTS DefinitionInfo | ||
Environment.GetEnvironmentVariable("SYSTEM_DEFINITIONID").Returns("1855"); | ||
Environment.GetEnvironmentVariable("BUILD_DEFINITIONNAME").Returns("Cake-CI"); | ||
Environment.GetEnvironmentVariable("BUILD_DEFINITIONVERSION").Returns("47"); | ||
|
||
// VSTS TeamProjectInfo | ||
Environment.GetEnvironmentVariable("SYSTEM_TEAMPROJECT").Returns("TeamProject"); | ||
Environment.GetEnvironmentVariable("SYSTEM_TEAMPROJECTID").Returns("D0A3B6B8-499B-4D4B-BD46-DB70C19E6D33"); | ||
Environment.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI") | ||
.Returns("https://fabrikamfiber.visualstudio.com/"); | ||
} | ||
|
||
public TFBuildEnvironmentInfo CreateEnvironmentInfo() | ||
{ | ||
return new TFBuildEnvironmentInfo(Environment); | ||
} | ||
|
||
public TFBuildRepositoryInfo CreateRepositoryInfo() | ||
{ | ||
return new TFBuildRepositoryInfo(Environment); | ||
} | ||
|
||
public TFBuildRepositoryInfo CreateRepositoryInfo(string repoType) | ||
{ | ||
Environment.GetEnvironmentVariable("BUILD_REPOSITORY_PROVIDER").Returns(repoType); | ||
return CreateRepositoryInfo(); | ||
} | ||
|
||
public TFBuildAgentInfo CreateAgentInfo() | ||
{ | ||
return new TFBuildAgentInfo(Environment); | ||
} | ||
|
||
public TFBuildAgentInfo CreateHostedAgentInfo() | ||
{ | ||
Environment.GetEnvironmentVariable("AGENT_NAME").Returns("Hosted Agent"); | ||
return new TFBuildAgentInfo(Environment); | ||
} | ||
|
||
public TFBuildInfo CreateBuildInfo() | ||
{ | ||
return new TFBuildInfo(Environment); | ||
} | ||
|
||
public TFBuildDefinitionInfo CreateDefinitionInfo() | ||
{ | ||
return new TFBuildDefinitionInfo(Environment); | ||
} | ||
|
||
public TFBuildTeamProjectInfo CreateTeamProjectInfo() | ||
{ | ||
return new TFBuildTeamProjectInfo(Environment); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.