-
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
9 changed files
with
139 additions
and
5 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
43 changes: 43 additions & 0 deletions
43
src/Cake.Tfs.Tests/PullRequest/PullRequestStatusExtensionsTests.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,43 @@ | ||
namespace Cake.Tfs.Tests.PullRequest | ||
{ | ||
using Cake.Tfs.PullRequest; | ||
using Microsoft.TeamFoundation.SourceControl.WebApi; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class PullRequestStatusExtensionsTests | ||
{ | ||
public sealed class TheToTfsPullRequestState | ||
{ | ||
[Theory] | ||
[InlineData(PullRequestStatus.NotSet, TfsPullRequestState.NotSet)] | ||
[InlineData(PullRequestStatus.Active, TfsPullRequestState.Active)] | ||
[InlineData(PullRequestStatus.Completed, TfsPullRequestState.Completed)] | ||
[InlineData(PullRequestStatus.Abandoned, TfsPullRequestState.Abandoned)] | ||
public void Should_Return_Correct_Value(PullRequestStatus state, TfsPullRequestState expectedResult) | ||
{ | ||
// Given | ||
|
||
// When | ||
var result = state.ToTfsPullRequestState(); | ||
|
||
// Then | ||
result.ShouldBe(expectedResult); | ||
} | ||
|
||
[Theory] | ||
[InlineData(PullRequestStatus.All)] | ||
public void Should_Throw_If_Invalid_Value_Is_Passed(PullRequestStatus state) | ||
{ | ||
// Given | ||
|
||
// When | ||
var result = | ||
Record.Exception(() => state.ToTfsPullRequestState()); | ||
|
||
// Then | ||
result.IsArgumentOutOfRangeException("state"); | ||
} | ||
} | ||
} | ||
} |
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,33 @@ | ||
namespace Cake.Tfs.PullRequest | ||
{ | ||
using System; | ||
using Microsoft.TeamFoundation.SourceControl.WebApi; | ||
|
||
/// <summary> | ||
/// Extensions for the <see cref="PullRequestStatus"/> class. | ||
/// </summary> | ||
internal static class PullRequestStatusExtensions | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="PullRequestStatus"/> to a <see cref="TfsPullRequestState"/>. | ||
/// </summary> | ||
/// <param name="state">State to convert.</param> | ||
/// <returns>Converted state.</returns> | ||
public static TfsPullRequestState ToTfsPullRequestState(this PullRequestStatus state) | ||
{ | ||
switch (state) | ||
{ | ||
case PullRequestStatus.NotSet: | ||
return TfsPullRequestState.NotSet; | ||
case PullRequestStatus.Active: | ||
return TfsPullRequestState.Active; | ||
case PullRequestStatus.Abandoned: | ||
return TfsPullRequestState.Abandoned; | ||
case PullRequestStatus.Completed: | ||
return TfsPullRequestState.Completed; | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(state)); | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
namespace Cake.Tfs.PullRequest | ||
{ | ||
/// <summary> | ||
/// Possible states of a pull request. | ||
/// </summary> | ||
public enum TfsPullRequestState : byte | ||
{ | ||
/// <summary> | ||
/// Status is not set. | ||
/// </summary> | ||
NotSet, | ||
|
||
/// <summary> | ||
/// Pull request is active. | ||
/// </summary> | ||
Active, | ||
|
||
/// <summary> | ||
/// Pull request is abandoned. | ||
/// </summary> | ||
Abandoned, | ||
|
||
/// <summary> | ||
/// Pull request is completed. | ||
/// </summary> | ||
Completed | ||
} | ||
} |