-
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
19 changed files
with
1,130 additions
and
283 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
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
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,27 @@ | ||
namespace Cake.Tfs.Tests.PullRequest | ||
{ | ||
using Cake.Testing; | ||
using Cake.Tfs.Tests.PullRequest.Fakes; | ||
|
||
internal abstract class BasePullRequestFixture | ||
{ | ||
public const string ValidTfsUrl = "http://MyServer/tfs/MyCollection/MyTeamProject/_git/MyRepoName"; | ||
public const string ValidAzureDevOpsUrl = "https://my-account.visualstudio.com/DefaultCollection/MyProject/_git/MyRepoName"; | ||
public const string InvalidTfsUrl = "http://example.com"; | ||
|
||
public BasePullRequestFixture() | ||
{ | ||
this.InitializeFakes(); | ||
} | ||
|
||
public FakeLog Log { get; set; } | ||
|
||
public IGitClientFactory GitClientFactory { get; set; } | ||
|
||
private void InitializeFakes() | ||
{ | ||
this.Log = new FakeLog(); | ||
this.GitClientFactory = new FakeAllSetGitClientFactory(); | ||
} | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/Cake.Tfs.Tests/PullRequest/CommentThread/TfsCommentTests.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,95 @@ | ||
namespace Cake.Tfs.Tests.PullRequest.CommentThread | ||
{ | ||
using Cake.Tfs.PullRequest.CommentThread; | ||
using Microsoft.TeamFoundation.SourceControl.WebApi; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class TfsCommentTests | ||
{ | ||
public sealed class TheCtor | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Comment_Is_Null() | ||
{ | ||
// Given, When | ||
var result = Record.Exception(() => new TfsComment(null)); | ||
|
||
// Then | ||
result.IsArgumentNullException("comment"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Comment_Content_Is_Null() | ||
{ | ||
// Given, When | ||
var result = Record.Exception(() => new TfsComment(null, false)); | ||
|
||
// Then | ||
result.IsArgumentNullException("content"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Comment_Content_Is_Empty() | ||
{ | ||
// Given, When | ||
var result = Record.Exception(() => new TfsComment(string.Empty, false)); | ||
|
||
// Then | ||
result.IsArgumentOutOfRangeException("content"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Return_Empty_Comment() | ||
{ | ||
// Given, When | ||
var comment = new TfsComment(); | ||
|
||
// Then | ||
comment.ShouldNotBeNull(); | ||
comment.Content.ShouldBe(default(string)); | ||
comment.IsDeleted.ShouldBe(default(bool)); | ||
comment.CommentType.ShouldBe(default(TfsCommentType)); | ||
} | ||
|
||
[Fact] | ||
public void Should_Return_Valid_Comment_With_Default_Comment_Type() | ||
{ | ||
// Given, When | ||
var comment = new TfsComment("Hello", false); | ||
|
||
// Then | ||
comment.ShouldNotBeNull(); | ||
comment.Content.ShouldBe("Hello"); | ||
comment.IsDeleted.ShouldBeFalse(); | ||
comment.CommentType.ShouldBe(default(TfsCommentType)); | ||
} | ||
|
||
[Fact] | ||
public void Should_Return_Valid_Comment_Via_With_Specific_Comment_Type() | ||
{ | ||
// Given, When | ||
var comment = new TfsComment("What's up?", true, CommentType.Text); | ||
|
||
// Then | ||
comment.ShouldNotBeNull(); | ||
comment.Content.ShouldBe("What's up?"); | ||
comment.IsDeleted.ShouldBeTrue(); | ||
comment.CommentType.ShouldBe(TfsCommentType.Text); | ||
} | ||
|
||
[Fact] | ||
public void Should_Return_Valid_Comment_Via_Initializers() | ||
{ | ||
// Given, When | ||
var comment = new TfsComment { Content = "All good", IsDeleted = false, CommentType = TfsCommentType.CodeChange }; | ||
|
||
// Then | ||
comment.ShouldNotBeNull(); | ||
comment.Content.ShouldBe("All good"); | ||
comment.IsDeleted.ShouldBeFalse(); | ||
comment.CommentType.ShouldBe(TfsCommentType.CodeChange); | ||
} | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/Cake.Tfs.Tests/PullRequest/CreatePullRequestFixture.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,25 @@ | ||
namespace Cake.Tfs.Tests.PullRequest | ||
{ | ||
using System; | ||
using Cake.Tfs.Authentication; | ||
using Cake.Tfs.PullRequest; | ||
|
||
internal class CreatePullRequestFixture | ||
: BasePullRequestFixture | ||
{ | ||
public CreatePullRequestFixture(string repoUrl, string sourceRefName, string targetRefName, string title, string description) | ||
: base() | ||
{ | ||
this.Settings = | ||
new TfsCreatePullRequestSettings( | ||
new Uri(repoUrl), | ||
sourceRefName, | ||
targetRefName, | ||
title, | ||
description, | ||
new TfsNtlmCredentials()); | ||
} | ||
|
||
public TfsCreatePullRequestSettings Settings { get; set; } | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,41 +1,24 @@ | ||
namespace Cake.Tfs.Tests.PullRequest | ||
{ | ||
using System; | ||
using Cake.Testing; | ||
using Cake.Tfs.Authentication; | ||
using Cake.Tfs.PullRequest; | ||
using Cake.Tfs.Tests.PullRequest.Fakes; | ||
|
||
internal class PullRequestFixture | ||
: BasePullRequestFixture | ||
{ | ||
public const string ValidTfsUrl = "http://MyServer/tfs/MyCollection/MyTeamProject/_git/MyRepoName"; | ||
public const string ValidAzureDevOpsUrl = "https://my-account.visualstudio.com/DefaultCollection/MyProject/_git/MyRepoName"; | ||
public const string InvalidTfsUrl = "http://example.com"; | ||
|
||
public PullRequestFixture(string repoUrl, int prId) | ||
: base() | ||
{ | ||
this.Settings = new TfsPullRequestSettings(new Uri(repoUrl), prId, new TfsNtlmCredentials()); | ||
|
||
this.InitializeFakes(); | ||
} | ||
|
||
public PullRequestFixture(string repoUrl, string sourceBranch) | ||
public PullRequestFixture(string repoUrl, string sourceRefName) | ||
: base() | ||
{ | ||
this.Settings = new TfsPullRequestSettings(new Uri(repoUrl), sourceBranch, new TfsNtlmCredentials()); | ||
|
||
this.InitializeFakes(); | ||
this.Settings = new TfsPullRequestSettings(new Uri(repoUrl), sourceRefName, new TfsNtlmCredentials()); | ||
} | ||
|
||
public FakeLog Log { get; set; } | ||
|
||
public TfsPullRequestSettings Settings { get; set; } | ||
|
||
public IGitClientFactory GitClientFactory { get; set; } | ||
|
||
private void InitializeFakes() | ||
{ | ||
this.Log = new FakeLog(); | ||
this.GitClientFactory = new FakeAllSetGitClientFactory(); | ||
} | ||
} | ||
} |
Oops, something went wrong.