diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 727dfd76..4903ba5f 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
- "version": "0.38.5",
+ "version": "1.3.0",
"commands": [
"dotnet-cake"
]
diff --git a/README.md b/README.md
index b6bf5872..7918b140 100644
--- a/README.md
+++ b/README.md
@@ -11,14 +11,32 @@ This addin for Cake allows you to work with Azure DevOps.
|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.AzureDevOps.svg)](https://github.com/cake-contrib/Cake.AzureDevOps/releases/latest)|
|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.AzureDevOps.svg)](https://www.nuget.org/packages/Cake.AzureDevOps)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.AzureDevOps.svg)](https://www.nuget.org/packages/Cake.AzureDevOps)|
-## Build Status
-
-| | Develop | Master |
-|:--:|:--:|:--:|
-|AppVeyor Windows|[![Build status](https://ci.appveyor.com/api/projects/status/45blf3csh70opuos/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-azuredevops/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/45blf3csh70opuos/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-azuredevops/branch/master)|
-|Azure DevOps Windows|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
-|Azure DevOps macOS|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=macOS)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=macOS)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
-|Azure DevOps Ubuntu|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Ubuntu)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Ubuntu)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+## Build & Test Status
+
+| Type | CI Server | Runner | Operating System | Develop | Master |
+|:------------------:|:------------:|:-------------------------------:|:-------------------:|:-------:|:------:|
+| Build & Unit Tests | AppVeyor | N/A | Windows Server 2019 |[![Build status](https://ci.appveyor.com/api/projects/status/45blf3csh70opuos/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-azuredevops/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/45blf3csh70opuos/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-azuredevops/branch/master)|
+| Build & Unit Tests | Azure DevOps | N/A | Windows Server 2022 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Build%20%26%20Test%20Windows)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Build%20%26%20Test%20Windows)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Build & Unit Tests | Azure DevOps | N/A | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Build%20%26%20Test%20macOS)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Build%20%26%20Test%20macOS)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Build & Unit Tests | Azure DevOps | N/A | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Build%20%26%20Test%20Ubuntu)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Build%20%26%20Test%20Ubuntu)](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET Core 3.1 | Windows Server 2019 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20Windows%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20Windows%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET 5.0 | Windows Server 2019 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20Windows%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20Windows%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET 6.0 | Windows Server 2022 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20Windows%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20Windows%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET Core 3.1 | Windows Server 2019 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20Windows%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20Windows%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET 5.0 | Windows Server 2019 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20Windows%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20Windows%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET 6.0 | Windows Server 2022 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20Windows%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20Windows%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET Core 3.1 | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20macOS%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20macOS%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET 5.0 | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20macOS%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20macOS%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET 6.0 | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20macOS%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20macOS%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET Core 3.1 | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20macOS%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20macOS%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET 5.0 | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20macOS%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20macOS%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET 6.0 | macOS 11 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20macOS%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20macOS%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET Core 3.1 | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20Ubuntu%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20Ubuntu%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET 5.0 | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20Ubuntu%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20Ubuntu%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Frosting on .NET 6.0 | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Frosting%20Ubuntu%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Frosting%20Ubuntu%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET Core 3.1 | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20Ubuntu%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20Ubuntu%20(.NET%20Core%203.1))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET 5.0 | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20Ubuntu%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20Ubuntu%20(.NET%205))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
+| Integration Tests | Azure DevOps | Cake Scripting on .NET 6.0 | Ubuntu 20.04 |[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=develop&jobName=Integration%20Tests%20Script%20Runner%20Ubuntu%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_apis/build/status/cake-contrib.Cake.AzureDevOps?branchName=master&jobName=Integration%20Tests%20Script%20Runner%20Ubuntu%20(.NET%206))](https://dev.azure.com/cake-contrib/Cake.AzureDevOps/_build/latest?definitionId=24&branchName=master)|
## Demos
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 390e5c0c..b6097c25 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -10,7 +10,9 @@ pr:
- hotfix/*
jobs:
-- job: Windows
+# Build & Test Windows
+- job: Build_Windows
+ displayName: Build & Test Windows
pool:
vmImage: 'windows-2022'
steps:
@@ -19,10 +21,15 @@ jobs:
.\build.ps1
exit $LASTEXITCODE
displayName: 'Cake Build'
+ - publish: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ artifact: NuGet Package Windows
+ displayName: 'Publish NuGet package as build artifact'
-- job: macOS
+# Build & Test macOS
+- job: Build_macOS
+ displayName: Build & Test macOS
pool:
- vmImage: 'macOS-10.15'
+ vmImage: 'macOS-11'
steps:
- task: UseDotNet@2
inputs:
@@ -36,10 +43,15 @@ jobs:
- bash: |
./build.sh
displayName: 'Cake Build'
+ - publish: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ artifact: NuGet Package macOS
+ displayName: 'Publish NuGet package as build artifact'
-- job: Ubuntu
+# Build & Test Ubuntu
+- job: Build_Ubuntu
+ displayName: Build & Test Ubuntu
pool:
- vmImage: 'ubuntu-18.04'
+ vmImage: 'ubuntu-20.04'
steps:
- task: UseDotNet@2
inputs:
@@ -52,4 +64,421 @@ jobs:
version: '3.x'
- bash: |
./build.sh --verbosity=diagnostic
- displayName: 'Cake Build'
\ No newline at end of file
+ displayName: 'Cake Build'
+ - publish: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ artifact: NuGet Package Ubuntu
+ displayName: 'Publish NuGet package as build artifact'
+
+# Integration Tests Frosting Windows (.NET Core 3.1)
+- job: Test_Frosting_Windows_NetCoreApp31
+ displayName: Integration Tests Frosting Windows (.NET Core 3.1)
+ dependsOn: Build_Windows
+ pool:
+ vmImage: 'windows-2019'
+ steps:
+ - download: current
+ artifact: NuGet Package Windows
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Windows
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - powershell: ./build.ps1 --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/netcoreapp3.1
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting Windows (.NET 5)
+- job: Test_Frosting_Windows_Net5
+ displayName: Integration Tests Frosting Windows (.NET 5)
+ dependsOn: Build_Windows
+ pool:
+ vmImage: 'windows-2019'
+ steps:
+ - download: current
+ artifact: NuGet Package Windows
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Windows
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - powershell: ./build.ps1 --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/net5.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting Windows (.NET 6)
+- job: Test_Frosting_Windows_Net6
+ displayName: Integration Tests Frosting Windows (.NET 6)
+ dependsOn: Build_Windows
+ pool:
+ vmImage: 'windows-2022'
+ steps:
+ - download: current
+ artifact: NuGet Package Windows
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Windows
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - powershell: ./build.ps1 --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/net6.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner Windows (.NET Core 3.1)
+- job: Test_Script_Runner_Windows_NetCoreApp31
+ displayName: Integration Tests Script Runner Windows (.NET Core 3.1)
+ dependsOn: Build_Windows
+ pool:
+ vmImage: 'windows-2019'
+ steps:
+ - download: current
+ artifact: NuGet Package Windows
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Windows
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - powershell: ./build.ps1 --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/netcoreapp3.1
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner Windows (.NET 5)
+- job: Test_Script_Runner_Windows_Net5
+ displayName: Integration Tests Script Runner Windows (.NET 5)
+ dependsOn: Build_Windows
+ pool:
+ vmImage: 'windows-2019'
+ steps:
+ - download: current
+ artifact: NuGet Package Windows
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Windows
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - powershell: ./build.ps1 --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/net5.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner Windows (.NET 6)
+- job: Test_Script_Runner_Windows_Net6
+ displayName: Integration Tests Script Runner Windows (.NET 6)
+ dependsOn: Build_Windows
+ pool:
+ vmImage: 'windows-2022'
+ steps:
+ - download: current
+ artifact: NuGet Package Windows
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Windows
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - powershell: ./build.ps1 --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/net6.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting macOS (.NET Core 3.1)
+- job: Test_Frosting_macOS_NetCoreApp31
+ displayName: Integration Tests Frosting macOS (.NET Core 3.1)
+ dependsOn: Build_macOS
+ pool:
+ vmImage: 'macOS-11'
+ steps:
+ - download: current
+ artifact: NuGet Package macOS
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package macOS
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '3.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/netcoreapp3.1
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting macOS (.NET 5)
+- job: Test_Frosting_macOS_Net5
+ displayName: Integration Tests Frosting macOS (.NET 5)
+ dependsOn: Build_macOS
+ pool:
+ vmImage: 'macOS-11'
+ steps:
+ - download: current
+ artifact: NuGet Package macOS
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package macOS
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '5.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/net5.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting macOS (.NET 6)
+- job: Test_Frosting_macOS_Net6
+ displayName: Integration Tests Frosting macOS (.NET 6)
+ dependsOn: Build_macOS
+ pool:
+ vmImage: 'macOS-11'
+ steps:
+ - download: current
+ artifact: NuGet Package macOS
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package macOS
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '6.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/net6.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner macOS (.NET Core 3.1)
+- job: Test_Script_Runner_macOS_NetCoreApp31
+ displayName: Integration Tests Script Runner macOS (.NET Core 3.1)
+ dependsOn: Build_macOS
+ pool:
+ vmImage: 'macOS-11'
+ steps:
+ - download: current
+ artifact: NuGet Package macOS
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package macOS
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '3.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/netcoreapp3.1
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner macOS (.NET 5)
+- job: Test_Script_Runner_macOS_Net5
+ displayName: Integration Tests Script Runner macOS (.NET 5)
+ dependsOn: Build_macOS
+ pool:
+ vmImage: 'macOS-11'
+ steps:
+ - download: current
+ artifact: NuGet Package macOS
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package macOS
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '5.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/net5.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner macOS (.NET 6)
+- job: Test_Script_Runner_macOS_Net6
+ displayName: Integration Tests Script Runner macOS (.NET 6)
+ dependsOn: Build_macOS
+ pool:
+ vmImage: 'macOS-11'
+ steps:
+ - download: current
+ artifact: NuGet Package macOS
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package macOS
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '6.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/net6.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting Ubuntu (.NET Core 3.1)
+- job: Test_Frosting_Ubuntu_NetCoreApp31
+ displayName: Integration Tests Frosting Ubuntu (.NET Core 3.1)
+ dependsOn: Build_Ubuntu
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - download: current
+ artifact: NuGet Package Ubuntu
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Ubuntu
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '3.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/netcoreapp3.1
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting Ubuntu (.NET 5)
+- job: Test_Frosting_Ubuntu_Net5
+ displayName: Integration Tests Frosting Ubuntu (.NET 5)
+ dependsOn: Build_Ubuntu
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - download: current
+ artifact: NuGet Package Ubuntu
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Ubuntu
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '5.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/net5.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Frosting Ubuntu (.NET 6)
+- job: Test_Frosting_Ubuntu_Net6
+ displayName: Integration Tests Frosting Ubuntu (.NET 6)
+ dependsOn: Build_Ubuntu
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - download: current
+ artifact: NuGet Package Ubuntu
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Ubuntu
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '6.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/frosting/net6.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner Ubuntu (.NET Core 3.1)
+- job: Test_Script_Runner_Ubuntu_NetCoreApp31
+ displayName: Integration Tests Script Runner Ubuntu (.NET Core 3.1)
+ dependsOn: Build_Ubuntu
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - download: current
+ artifact: NuGet Package Ubuntu
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Ubuntu
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '3.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/netcoreapp3.1
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner Ubuntu (.NET 5)
+- job: Test_Script_Runner_Ubuntu_Net5
+ displayName: Integration Tests Script Runner Ubuntu (.NET 5)
+ dependsOn: Build_Ubuntu
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - download: current
+ artifact: NuGet Package Ubuntu
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Ubuntu
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '5.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/net5.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+
+# Integration Tests Script Runner Ubuntu (.NET 6)
+- job: Test_Script_Runner_Ubuntu_Net6
+ displayName: Integration Tests Script Runner Ubuntu (.NET 6)
+ dependsOn: Build_Ubuntu
+ pool:
+ vmImage: 'ubuntu-20.04'
+ steps:
+ - download: current
+ artifact: NuGet Package Ubuntu
+ displayName: 'Download build artifact'
+ - task: CopyFiles@2
+ inputs:
+ sourceFolder: $(Pipeline.Workspace)/NuGet Package Ubuntu
+ targetFolder: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet
+ displayName: 'Copy build artifact for test run'
+ - task: UseDotNet@2
+ inputs:
+ version: '6.x'
+ - bash: ./build.sh --verbosity=diagnostic
+ workingDirectory: ./tests/script-runner/net6.0
+ displayName: 'Run integration tests'
+ env:
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
diff --git a/recipe.cake b/recipe.cake
index 32a2ad86..f9917f57 100644
--- a/recipe.cake
+++ b/recipe.cake
@@ -1,4 +1,4 @@
-#load nuget:?package=Cake.Recipe&version=2.2.1
+#load nuget:?package=Cake.Recipe&version=3.0.1
Environment.SetVariableNames();
@@ -11,7 +11,6 @@ BuildParameters.SetParameters(
repositoryName: "Cake.AzureDevOps",
appVeyorAccountName: "cakecontrib",
shouldCalculateVersion: true,
- shouldRunDupFinder: false, // dupFinder is missing in 2021.3.0-eap
shouldRunDotNetCorePack: true,
shouldGenerateDocumentation: false, // Fails to restore tool on AppVeyor
shouldRunCoveralls: false, // Fails to restore tool on AppVeyor
@@ -21,17 +20,10 @@ BuildParameters.PrintParameters(Context);
ToolSettings.SetToolSettings(
context: Context,
- dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.AzureDevOps.Tests/**/*.cs" },
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Common]* -[*.Tests]* -[Cake.Testing]* -[Moq]* -[Shouldly]* -[DiffEngine]* -[EmptyFiles]*",
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");
-// Workaround until https://github.com/cake-contrib/Cake.Recipe/issues/862 has been fixed in Cake.Recipe
-ToolSettings.SetToolPreprocessorDirectives(
- reSharperTools: "#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2021.3.1",
- coverallsGlobalTool: "#tool dotnet:?package=coveralls.net&version=3.0.0",
- gitVersionGlobalTool: "#tool dotnet:?package=GitVersion.Tool&version=5.8.1");
-
// Disable Upload-Coveralls-Report task since it fails to install the tool on AppVeyor
BuildParameters.Tasks.UploadCoverallsReportTask.WithCriteria(() => false);
diff --git a/src/Cake.AzureDevOps.Tests/Boards/WorkItemTracking/AzureDevOpsWorkItemSettingsTests.cs b/src/Cake.AzureDevOps.Tests/Boards/WorkItemTracking/AzureDevOpsWorkItemSettingsTests.cs
new file mode 100644
index 00000000..07f39499
--- /dev/null
+++ b/src/Cake.AzureDevOps.Tests/Boards/WorkItemTracking/AzureDevOpsWorkItemSettingsTests.cs
@@ -0,0 +1,891 @@
+namespace Cake.AzureDevOps.Tests.Boards.WorkItemTracking
+{
+ using System;
+ using Cake.AzureDevOps.Authentication;
+ using Cake.AzureDevOps.Boards.WorkItemTracking;
+ using Shouldly;
+ using Xunit;
+
+ public sealed class AzureDevOpsWorkItemSettingsTests
+ {
+ public sealed class TheCtorForProjectGuid
+ {
+ [Fact]
+ public void Should_Throw_If_CollectionUrl_Is_Null()
+ {
+ // Given
+ Uri collectionUrl = null;
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials));
+
+ // Then
+ result.IsArgumentNullException("collectionUrl");
+ }
+
+ [Fact]
+ public void Should_Throw_If_ProjectGuid_Is_Empty()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.Empty;
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("projectGuid");
+ }
+
+ [Fact]
+ public void Should_Throw_If_WorkItemId_Is_Zero()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 0;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("workItemId");
+ }
+
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(int.MinValue)]
+ public void Should_Throw_If_WorkItemId_Is_Negative(int workItemId)
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("workItemId");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Credentials_Are_Null()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ IAzureDevOpsCredentials credentials = null;
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials));
+
+ // Then
+ result.IsArgumentNullException("credentials");
+ }
+
+ [Fact]
+ public void Should_Set_Collection_Url()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // Then
+ result.CollectionUrl.ShouldBe(collectionUrl);
+ }
+
+ [Fact]
+ public void Should_Set_ProjectGuid()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // Then
+ result.ProjectGuid.ShouldBe(projectGuid);
+ }
+
+ [Theory]
+ [InlineData(1)]
+ [InlineData(int.MaxValue)]
+ public void Should_Set_WorkItemId(int workItemId)
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // Then
+ result.WorkItemId.ShouldBe(workItemId);
+ }
+
+ [Fact]
+ public void Should_Set_Credentials()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // Then
+ result.Credentials.ShouldBe(credentials);
+ }
+ }
+
+ public sealed class TheCtorForProjectName
+ {
+ [Fact]
+ public void Should_Throw_If_CollectionUrl_Is_Null()
+ {
+ // Given
+ Uri collectionUrl = null;
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentNullException("collectionUrl");
+ }
+
+ [Fact]
+ public void Should_Throw_If_ProjectName_Is_Null()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ string projectName = null;
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentNullException("projectName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_ProjectName_Is_Empty()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = string.Empty;
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("projectName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_ProjectName_Is_WhiteSpace()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = " ";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("projectName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_WorkItemId_Is_Zero()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 0;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("workItemId");
+ }
+
+ [Theory]
+ [InlineData(-1)]
+ [InlineData(int.MinValue)]
+ public void Should_Throw_If_WorkItemId_Is_Negative(int workItemId)
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentOutOfRangeException("workItemId");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Credentials_Are_Null()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ IAzureDevOpsCredentials credentials = null;
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials));
+
+ // Then
+ result.IsArgumentNullException("credentials");
+ }
+
+ [Fact]
+ public void Should_Set_Collection_Url()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials);
+
+ // Then
+ result.CollectionUrl.ShouldBe(collectionUrl);
+ }
+
+ [Fact]
+ public void Should_Set_ProjectName()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials);
+
+ // Then
+ result.ProjectName.ShouldBe(projectName);
+ }
+
+ [Theory]
+ [InlineData(1)]
+ [InlineData(int.MaxValue)]
+ public void Should_Set_WorkItemId(int workItemId)
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials);
+
+ // Then
+ result.WorkItemId.ShouldBe(workItemId);
+ }
+
+ [Fact]
+ public void Should_Set_Credentials()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials);
+
+ // Then
+ result.Credentials.ShouldBe(credentials);
+ }
+ }
+
+ public sealed class TheCtorForSettings
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ AzureDevOpsWorkItemSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(settings));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Set_Collection_Url()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+ var settings = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(settings);
+
+ // Then
+ result.CollectionUrl.ShouldBe(collectionUrl);
+ }
+
+ [Fact]
+ public void Should_Set_ProjectGuid()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+ var settings = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(settings);
+
+ // Then
+ result.ProjectGuid.ShouldBe(projectGuid);
+ }
+
+ [Fact]
+ public void Should_Set_ProjectName()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+ var settings = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials);
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(settings);
+
+ // Then
+ result.ProjectName.ShouldBe(projectName);
+ }
+
+ [Theory]
+ [InlineData(1)]
+ [InlineData(int.MaxValue)]
+ public void Should_Set_WorkItemId(int workItemId)
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectGuid = Guid.NewGuid();
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+ var settings = new AzureDevOpsWorkItemSettings(collectionUrl, projectGuid, workItemId, credentials);
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(settings);
+
+ // Then
+ result.WorkItemId.ShouldBe(workItemId);
+ }
+
+ [Fact]
+ public void Should_Set_Credentials()
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+ var settings = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials);
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(settings);
+
+ // Then
+ result.Credentials.ShouldBe(credentials);
+ }
+
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public void Should_Set_ThrowExceptionIfWorkItemCouldNotBeFound(bool value)
+ {
+ // Given
+ var collectionUrl = new Uri("http://example.com/collection");
+ var projectName = "MyProject";
+ var workItemId = 42;
+ var credentials = AuthenticationProvider.AuthenticationNtlm();
+ var settings = new AzureDevOpsWorkItemSettings(collectionUrl, projectName, workItemId, credentials)
+ {
+ ThrowExceptionIfWorkItemCouldNotBeFound = value,
+ };
+
+ // When
+ var result = new AzureDevOpsWorkItemSettings(settings);
+
+ // Then
+ result.ThrowExceptionIfWorkItemCouldNotBeFound.ShouldBe(value);
+ }
+ }
+
+ public sealed class TheCtorForEnvironmentVariables : IDisposable
+ {
+ private readonly string originalCollectionUrl;
+ private readonly string originalProjectName;
+
+ public TheCtorForEnvironmentVariables()
+ {
+ this.originalCollectionUrl = Environment.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI");
+ this.originalProjectName = Environment.GetEnvironmentVariable("SYSTEM_TEAMPROJECT");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Credentials_Are_Null()
+ {
+ // Given
+ IAzureDevOpsCredentials creds = null;
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsArgumentNullException("credentials");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Collection_Url_Env_Var_Is_Not_Set()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", null);
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Collection_Url_Env_Var_Is_Empty()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", string.Empty);
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Collection_Url_Env_Var_Is_WhiteSpace()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", " ");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Project_Name_Env_Var_Is_Not_Set()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", null);
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Project_Name_Env_Var_Is_Empty()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", string.Empty);
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Project_Name_Env_Var_Is_WhiteSpace()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", " ");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Set_Collection_Url()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(42, creds);
+
+ // Then
+ settings.CollectionUrl.ToString().ShouldBe(new Uri("https://example.com/collection").ToString());
+ }
+
+ [Fact]
+ public void Should_Set_Project_Name()
+ {
+ // Given
+ var projectName = "MyProject";
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", projectName);
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(42, creds);
+
+ // Then
+ settings.ProjectName.ShouldBe(projectName);
+ }
+
+ [Fact]
+ public void Should_Set_Credentials()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(42, creds);
+
+ // Then
+ settings.Credentials.ShouldBe(creds);
+ }
+
+ public void Dispose()
+ {
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", this.originalCollectionUrl);
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", this.originalProjectName);
+ }
+ }
+
+ public sealed class TheUsingAzurePipelinesOAuthTokenMethod : IDisposable
+ {
+ private readonly string originalCollectionUrl;
+ private readonly string originalProjectName;
+ private readonly string originalAccessToken;
+
+ public TheUsingAzurePipelinesOAuthTokenMethod()
+ {
+ this.originalCollectionUrl = Environment.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI");
+ this.originalProjectName = Environment.GetEnvironmentVariable("SYSTEM_TEAMPROJECT");
+ this.originalAccessToken = Environment.GetEnvironmentVariable("SYSTEM_ACCESSTOKEN");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Collection_Url_Env_Var_Is_Not_Set()
+ {
+ // Given
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", null);
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => AzureDevOpsWorkItemSettings.UsingAzurePipelinesOAuthToken(42));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Collection_Url_Env_Var_Is_Empty()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", string.Empty);
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Collection_Url_Env_Var_Is_WhiteSpace()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", " ");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Project_Name_Env_Var_Is_Not_Set()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", null);
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Project_Name_Env_Var_Is_Empty()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", string.Empty);
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_Project_Name_Env_Var_Is_WhiteSpace()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", " ");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(42, creds));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_WorkItem_Id_Value_Zero()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(0, creds));
+
+ // Then
+ result.IsArgumentOutOfRangeException("workItemId");
+ }
+
+ [Fact]
+ public void Should_Throw_If_WorkItem_Id_Value_Negative()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var result = Record.Exception(() => new AzureDevOpsWorkItemSettings(-1, creds));
+
+ // Then
+ result.IsArgumentOutOfRangeException("workItemId");
+ }
+
+ [Fact]
+ public void Should_Throw_If_System_Access_Token_Env_Var_Is_Not_Set_With_OAuthToken()
+ {
+ // Given
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", null);
+
+ // When
+ var result = Record.Exception(() => AzureDevOpsWorkItemSettings.UsingAzurePipelinesOAuthToken(42));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_System_Access_Token_Env_Var_Is_Empty_With_OAuthToken()
+ {
+ // Given
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", string.Empty);
+
+ // When
+ var result = Record.Exception(() => AzureDevOpsWorkItemSettings.UsingAzurePipelinesOAuthToken(42));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Throw_If_System_Access_Token_Env_Var_Is_WhiteSpace_With_OAuthToken()
+ {
+ // Given
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", " ");
+
+ // When
+ var result = Record.Exception(() => AzureDevOpsWorkItemSettings.UsingAzurePipelinesOAuthToken(42));
+
+ // Then
+ result.IsInvalidOperationException();
+ }
+
+ [Fact]
+ public void Should_Set_Collection_Url()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(42, creds);
+
+ // Then
+ settings.CollectionUrl.ToString().ShouldBe(new Uri("https://example.com/collection").ToString());
+ }
+
+ [Fact]
+ public void Should_Set_Project_Name()
+ {
+ // Given
+ var projectName = "MyProject";
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", projectName);
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(42, creds);
+
+ // Then
+ settings.ProjectName.ShouldBe(projectName);
+ }
+
+ [Fact]
+ public void Should_Set_WorkItem_Id()
+ {
+ // Given
+ var workItemId = 42;
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(workItemId, creds);
+
+ // Then
+ settings.WorkItemId.ShouldBe(workItemId);
+ }
+
+ [Fact]
+ public void Should_Set_Credentials()
+ {
+ // Given
+ var creds = new AzureDevOpsNtlmCredentials();
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");
+
+ // When
+ var settings = new AzureDevOpsWorkItemSettings(42, creds);
+
+ // Then
+ settings.Credentials.ShouldBe(creds);
+ }
+
+ public void Dispose()
+ {
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", this.originalCollectionUrl);
+ Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", this.originalProjectName);
+ Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", this.originalAccessToken);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Cake.AzureDevOps.Tests/Cake.AzureDevOps.Tests.csproj b/src/Cake.AzureDevOps.Tests/Cake.AzureDevOps.Tests.csproj
index 7dc28d5b..0fdbd7ba 100644
--- a/src/Cake.AzureDevOps.Tests/Cake.AzureDevOps.Tests.csproj
+++ b/src/Cake.AzureDevOps.Tests/Cake.AzureDevOps.Tests.csproj
@@ -14,15 +14,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/src/Cake.AzureDevOps.Tests/ExceptionAssertExtensions.cs b/src/Cake.AzureDevOps.Tests/ExceptionAssertExtensions.cs
index 12c9e813..7dd44750 100644
--- a/src/Cake.AzureDevOps.Tests/ExceptionAssertExtensions.cs
+++ b/src/Cake.AzureDevOps.Tests/ExceptionAssertExtensions.cs
@@ -23,6 +23,17 @@ public static void IsArgumentException(this T exception, Type expectedExcepti
Assert.Equal(parameterName, exception.ParamName);
}
+ ///
+ /// Checks if an exception is of type .
+ ///
+ /// Exception to check.
+ /// Expected name of the parameter which has caused the exception.
+ public static void IsArgumentException(this Exception exception, string parameterName)
+ {
+ Assert.IsType(exception);
+ Assert.Equal(parameterName, ((ArgumentException)exception).ParamName);
+ }
+
///
/// Checks if an exception is of type .
///
@@ -45,17 +56,6 @@ public static void IsArgumentOutOfRangeException(this Exception exception, strin
Assert.Equal(parameterName, ((ArgumentOutOfRangeException)exception).ParamName);
}
- ///
- /// Checks if an exception is of type .
- ///
- /// Exception to check.
- /// Expected name of the parameter which has caused the exception.
- public static void IsArgumentException(this Exception exception, string parameterName)
- {
- Assert.IsType(exception);
- Assert.Equal(parameterName, ((ArgumentException)exception).ParamName);
- }
-
///
/// Checks if an exception is of type .
///
diff --git a/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetBuildClientFactory.cs b/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetBuildClientFactory.cs
index 237b7490..9c745eb6 100644
--- a/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetBuildClientFactory.cs
+++ b/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetBuildClientFactory.cs
@@ -1,10 +1,12 @@
namespace Cake.AzureDevOps.Tests.Fakes
{
using System;
+ using System.Collections.Generic;
using System.Threading;
using Cake.AzureDevOps.Authentication;
using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
+ using Microsoft.VisualStudio.Services.WebApi;
using Moq;
public class FakeAllSetBuildClientFactory : FakeBuildClientFactory
@@ -13,7 +15,7 @@ public override BuildHttpClient CreateBuildClient(Uri collectionUrl, IAzureDevOp
{
var mock = new Mock(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials());
- mock.Setup(arg => arg.GetBuildAsync(It.IsAny(), It.IsAny(), null, null, default(CancellationToken)))
+ mock.Setup(arg => arg.GetBuildAsync(It.IsAny(), It.IsAny(), null, null, default))
.ReturnsAsync((Guid projectId, int buildId, string propertyFilters, object userState, CancellationToken token) => new Build
{
Id = buildId,
@@ -21,7 +23,7 @@ public override BuildHttpClient CreateBuildClient(Uri collectionUrl, IAzureDevOp
Project = new TeamProjectReference { Id = projectId },
});
- mock.Setup(arg => arg.GetBuildAsync(It.IsAny(), It.IsAny(), null, null, default(CancellationToken)))
+ mock.Setup(arg => arg.GetBuildAsync(It.IsAny(), It.IsAny(), null, null, default))
.ReturnsAsync((string projectName, int buildId, string propertyFilters, object userState, CancellationToken token) => new Build
{
Id = buildId,
@@ -29,6 +31,12 @@ public override BuildHttpClient CreateBuildClient(Uri collectionUrl, IAzureDevOp
Project = new TeamProjectReference { Name = projectName },
});
+ mock.Setup(arg => arg.GetBuildWorkItemsRefsAsync(It.IsAny(), It.IsAny(), It.IsAny(), null, default))
+ .ReturnsAsync((string projectName, int buildId, int? top, object userState, CancellationToken token) => new List
+ {
+ new ResourceRef { Id = "42" },
+ });
+
mock = this.Setup(mock);
return mock.Object;
diff --git a/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetGitClientFactory.cs b/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetGitClientFactory.cs
index 8bd386bd..e3a1ad0e 100644
--- a/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetGitClientFactory.cs
+++ b/src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetGitClientFactory.cs
@@ -14,7 +14,7 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
{
var mock = new Mock(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials());
- mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny(), It.IsAny(), It.IsAny(), null, null, null, null, null, null, default(CancellationToken)))
+ mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny(), It.IsAny(), It.IsAny(), null, null, null, null, null, null, default))
.ReturnsAsync((string project1, string repoId1, int prId, int i1, int i2, int i3, bool b1, bool b2, object o1, CancellationToken c1) => new GitPullRequest
{
PullRequestId = prId,
@@ -39,7 +39,7 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
null,
1,
null,
- default(CancellationToken)))
+ default))
.ReturnsAsync((string project2, string repoId2, GitPullRequestSearchCriteria sc, int j1, int j2, int top, object o2, CancellationToken c2)
=> new List(new[]
{
@@ -73,7 +73,7 @@ protected override Mock Setup(Mock m)
It.IsAny(),
It.IsAny(),
It.IsAny