-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
1,166 additions
and
263 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/Cake.AzureDevOps.Tests/BaseAzureDevOpsCollectionSettingsImpl.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,23 @@ | ||
namespace Cake.AzureDevOps | ||
{ | ||
using System; | ||
using Cake.AzureDevOps.Authentication; | ||
|
||
public class BaseAzureDevOpsCollectionSettingsImpl : BaseAzureDevOpsCollectionSettings | ||
{ | ||
public BaseAzureDevOpsCollectionSettingsImpl(Uri collectionUrl, IAzureDevOpsCredentials credentials) | ||
: base(collectionUrl, credentials) | ||
{ | ||
} | ||
|
||
public BaseAzureDevOpsCollectionSettingsImpl(BaseAzureDevOpsCollectionSettings settings) | ||
: base(settings) | ||
{ | ||
} | ||
|
||
public BaseAzureDevOpsCollectionSettingsImpl(IAzureDevOpsCredentials credentials) | ||
: base(credentials) | ||
{ | ||
} | ||
} | ||
} |
216 changes: 216 additions & 0 deletions
216
src/Cake.AzureDevOps.Tests/BaseAzureDevOpsCollectionSettingsTests.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,216 @@ | ||
namespace Cake.AzureDevOps.Tests | ||
{ | ||
using System; | ||
using Cake.AzureDevOps.Authentication; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class BaseAzureDevOpsCollectionSettingsTests | ||
{ | ||
public sealed class TheCtor | ||
{ | ||
public sealed class WithCollectionUrlAndCredentialsParameter | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_CollectionUrl_Is_Null() | ||
{ | ||
// Given | ||
Uri collectionUrl = null; | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(collectionUrl, credentials)); | ||
|
||
// Then | ||
result.IsArgumentNullException("collectionUrl"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Credentials_Are_Null() | ||
{ | ||
// Given | ||
var collectionUrl = new Uri("http://example.com/collection"); | ||
IAzureDevOpsCredentials credentials = null; | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(collectionUrl, credentials)); | ||
|
||
// Then | ||
result.IsArgumentNullException("credentials"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Credentials() | ||
{ | ||
// Given | ||
var collectionUrl = new Uri("http://example.com/collection"); | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
|
||
// When | ||
var result = new BaseAzureDevOpsCollectionSettingsImpl(collectionUrl, credentials); | ||
|
||
// Then | ||
result.Credentials.ShouldBe(credentials); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Collection_Url() | ||
{ | ||
// Given | ||
var collectionUrl = new Uri("http://example.com/collection"); | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
|
||
// When | ||
var result = new BaseAzureDevOpsCollectionSettingsImpl(collectionUrl, credentials); | ||
|
||
// Then | ||
result.CollectionUrl.ShouldBe(collectionUrl); | ||
} | ||
} | ||
|
||
public sealed class WithSettingsParameter | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
BaseAzureDevOpsCollectionSettingsImpl settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(settings)); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Credentials() | ||
{ | ||
// Given | ||
var collectionUrl = new Uri("http://example.com/collection"); | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
var settings = new BaseAzureDevOpsCollectionSettingsImpl(collectionUrl, credentials); | ||
|
||
// When | ||
var result = new BaseAzureDevOpsCollectionSettingsImpl(settings); | ||
|
||
// Then | ||
result.Credentials.ShouldBe(credentials); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_CollectionUrl() | ||
{ | ||
// Given | ||
var collectionUrl = new Uri("http://example.com/collection"); | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
var settings = new BaseAzureDevOpsCollectionSettingsImpl(collectionUrl, credentials); | ||
|
||
// When | ||
var result = new BaseAzureDevOpsCollectionSettingsImpl(settings); | ||
|
||
// Then | ||
result.CollectionUrl.ShouldBe(collectionUrl); | ||
} | ||
} | ||
|
||
public sealed class WithCredentialsParameter : IDisposable | ||
{ | ||
private readonly string originalCollectionUrl; | ||
|
||
public WithCredentialsParameter() | ||
{ | ||
this.originalCollectionUrl = Environment.GetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Credentials_Are_Null() | ||
{ | ||
// Given | ||
IAzureDevOpsCredentials credentials = null; | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(credentials)); | ||
|
||
// Then | ||
result.IsArgumentNullException("credentials"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Collection_Url_Env_Var_Is_Not_Set() | ||
{ | ||
// Given | ||
var credentials = new AzureDevOpsNtlmCredentials(); | ||
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", null); | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(credentials)); | ||
|
||
// Then | ||
result.IsInvalidOperationException(); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Collection_Url_Env_Var_Is_Empty() | ||
{ | ||
// Given | ||
var credentials = new AzureDevOpsNtlmCredentials(); | ||
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", string.Empty); | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(credentials)); | ||
|
||
// Then | ||
result.IsInvalidOperationException(); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Collection_Url_Env_Var_Is_WhiteSpace() | ||
{ | ||
// Given | ||
var credentials = new AzureDevOpsNtlmCredentials(); | ||
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", " "); | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCollectionSettingsImpl(credentials)); | ||
|
||
// Then | ||
result.IsInvalidOperationException(); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Credentials() | ||
{ | ||
// Given | ||
var credentials = new AzureDevOpsNtlmCredentials(); | ||
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); | ||
|
||
// When | ||
var settings = new BaseAzureDevOpsCollectionSettingsImpl(credentials); | ||
|
||
// Then | ||
settings.Credentials.ShouldBe(credentials); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Collection_Url() | ||
{ | ||
// Given | ||
var credentials = new AzureDevOpsNtlmCredentials(); | ||
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection"); | ||
|
||
// When | ||
var settings = new BaseAzureDevOpsCollectionSettingsImpl(credentials); | ||
|
||
// Then | ||
settings.CollectionUrl.ToString().ShouldBe(new Uri("https://example.com/collection").ToString()); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", this.originalCollectionUrl); | ||
} | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Cake.AzureDevOps.Tests/BaseAzureDevOpsCredentialsSettingsImpl.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,17 @@ | ||
namespace Cake.AzureDevOps.Tests | ||
{ | ||
using Cake.AzureDevOps.Authentication; | ||
|
||
public class BaseAzureDevOpsCredentialsSettingsImpl : BaseAzureDevOpsCredentialsSettings | ||
{ | ||
public BaseAzureDevOpsCredentialsSettingsImpl(IAzureDevOpsCredentials credentials) | ||
: base(credentials) | ||
{ | ||
} | ||
|
||
public BaseAzureDevOpsCredentialsSettingsImpl(BaseAzureDevOpsCredentialsSettingsImpl settings) | ||
: base(settings) | ||
{ | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/Cake.AzureDevOps.Tests/BaseAzureDevOpsCredentialsSettingsTests.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,71 @@ | ||
namespace Cake.AzureDevOps.Tests | ||
{ | ||
using Cake.AzureDevOps.Authentication; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class BaseAzureDevOpsCredentialsSettingsTests | ||
{ | ||
public sealed class TheCtor | ||
{ | ||
public sealed class WithCredentialsParameter | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Credentials_Are_Null() | ||
{ | ||
// Given | ||
IAzureDevOpsCredentials credentials = null; | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCredentialsSettingsImpl(credentials)); | ||
|
||
// Then | ||
result.IsArgumentNullException("credentials"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Credentials() | ||
{ | ||
// Given | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
|
||
// When | ||
var result = new BaseAzureDevOpsCredentialsSettingsImpl(credentials); | ||
|
||
// Then | ||
result.Credentials.ShouldBe(credentials); | ||
} | ||
} | ||
|
||
public sealed class WithSettingsParameter | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
BaseAzureDevOpsCredentialsSettingsImpl settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => new BaseAzureDevOpsCredentialsSettingsImpl(settings)); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Credentials() | ||
{ | ||
// Given | ||
var credentials = AuthenticationProvider.AuthenticationNtlm(); | ||
var settings = new BaseAzureDevOpsCredentialsSettingsImpl(credentials); | ||
|
||
// When | ||
var result = new BaseAzureDevOpsCredentialsSettingsImpl(settings); | ||
|
||
// Then | ||
result.Credentials.ShouldBe(credentials); | ||
} | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Cake.AzureDevOps.Tests/BaseAzureDevOpsProjectSettingsImpl.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,28 @@ | ||
namespace Cake.AzureDevOps | ||
{ | ||
using System; | ||
using Cake.AzureDevOps.Authentication; | ||
|
||
public class BaseAzureDevOpsProjectSettingsImpl : BaseAzureDevOpsProjectSettings | ||
{ | ||
public BaseAzureDevOpsProjectSettingsImpl(Uri collectionUrl, Guid projectGuid, IAzureDevOpsCredentials credentials) | ||
: base(collectionUrl, projectGuid, credentials) | ||
{ | ||
} | ||
|
||
public BaseAzureDevOpsProjectSettingsImpl(Uri collectionUrl, string projectName, IAzureDevOpsCredentials credentials) | ||
: base(collectionUrl, projectName, credentials) | ||
{ | ||
} | ||
|
||
public BaseAzureDevOpsProjectSettingsImpl(BaseAzureDevOpsProjectSettings settings) | ||
: base(settings) | ||
{ | ||
} | ||
|
||
public BaseAzureDevOpsProjectSettingsImpl(IAzureDevOpsCredentials credentials) | ||
: base(credentials) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.