Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Add test cases for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jul 27, 2018
1 parent 36b68f6 commit 629c1a3
Show file tree
Hide file tree
Showing 6 changed files with 873 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@
<Compile Include="Authentication\TfsBasicCredentialsTests.cs" />
<Compile Include="Authentication\TfsNtlmCredentialsTests.cs" />
<Compile Include="Authentication\TfsOAuthCredentialsTests.cs" />
<Compile Include="CommentExtensionsTests.cs" />
<Compile Include="CommentThreadStatusExtensionsTests.cs" />
<Compile Include="ContentProviderTests.cs" />
<Compile Include="GitPullRequestCommentThreadExtensionsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TfsCredentialsExtensionsTests.cs" />
<Compile Include="TfsPullRequestSettingsTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
63 changes: 63 additions & 0 deletions src/Cake.Issues.PullRequests.Tfs.Tests/CommentExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace Cake.Issues.PullRequests.Tfs.Tests
{
using Cake.Issues.Testing;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Shouldly;
using Xunit;

public sealed class CommentExtensionsTests
{
public sealed class TheToPullRequestDiscussionCommentExtension
{
[Fact]
public void Should_Throw_If_Comment_Is_Null()
{
// Given
Comment comment = null;

// When
var result = Record.Exception(() => comment.ToPullRequestDiscussionComment());

// Then
result.IsArgumentNullException("comment");
}

[Fact]
public void Should_Set_Correct_Content()
{
// Given
var content = "foo";
var comment =
new Comment
{
Content = content
};

// When
var result = comment.ToPullRequestDiscussionComment();

// Then
result.Content.ShouldBe(content);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void Should_Set_Correct_IsDeleted(bool isDeleted)
{
// Given
var comment =
new Comment
{
IsDeleted = isDeleted
};

// When
var result = comment.ToPullRequestDiscussionComment();

// Then
result.IsDeleted.ShouldBe(isDeleted);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
namespace Cake.Issues.PullRequests.Tfs.Tests
{
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Shouldly;
using Xunit;

public sealed class CommentThreadStatusExtensionsTests
{
public sealed class TheToPullRequestDiscussionStatusExtension
{
[Theory]
[InlineData(
CommentThreadStatus.Unknown,
PullRequestDiscussionStatus.Unknown)]
[InlineData(
CommentThreadStatus.Active,
PullRequestDiscussionStatus.Active)]
[InlineData(
CommentThreadStatus.Pending,
PullRequestDiscussionStatus.Active)]
[InlineData(
CommentThreadStatus.Fixed,
PullRequestDiscussionStatus.Resolved)]
[InlineData(
CommentThreadStatus.WontFix,
PullRequestDiscussionStatus.Resolved)]
[InlineData(
CommentThreadStatus.Closed,
PullRequestDiscussionStatus.Resolved)]
[InlineData(
CommentThreadStatus.ByDesign,
PullRequestDiscussionStatus.Resolved)]
public void Should_Return_Correct_Value(
CommentThreadStatus status,
PullRequestDiscussionStatus expectedResult)
{
// Given

// When
var result = status.ToPullRequestDiscussionStatus();

// Then
result.ShouldBe(expectedResult);
}
}

public sealed class TheToPullRequestDiscussionResolutionExtension
{
[Theory]
[InlineData(
CommentThreadStatus.Unknown,
PullRequestDiscussionResolution.Unknown)]
[InlineData(
CommentThreadStatus.Active,
PullRequestDiscussionResolution.Unknown)]
[InlineData(
CommentThreadStatus.Pending,
PullRequestDiscussionResolution.Unknown)]
[InlineData(
CommentThreadStatus.Fixed,
PullRequestDiscussionResolution.Resolved)]
[InlineData(
CommentThreadStatus.WontFix,
PullRequestDiscussionResolution.WontFix)]
[InlineData(
CommentThreadStatus.Closed,
PullRequestDiscussionResolution.Resolved)]
[InlineData(
CommentThreadStatus.ByDesign,
PullRequestDiscussionResolution.Resolved)]
public void Should_Return_Correct_Value(
CommentThreadStatus status,
PullRequestDiscussionResolution expectedResult)
{
// Given

// When
var result = status.ToPullRequestDiscussionResolution();

// Then
result.ShouldBe(expectedResult);
}
}
}
}
Loading

0 comments on commit 629c1a3

Please sign in to comment.