Skip to content

Commit

Permalink
Allow to pass IssueBuilder to IssueChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Apr 19, 2019
1 parent 25c4ede commit 8da63f6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Cake.Issues.Testing/IssueChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
/// </summary>
public static class IssueChecker
{
/// <summary>
/// Checks values of an issue.
/// </summary>
/// <param name="issueToCheck">Issue which should be checked.</param>
/// <param name="expectedIssue">Description of the expected issue.</param>
public static void Check(
IIssue issueToCheck,
IssueBuilder expectedIssue)
{
issueToCheck.NotNull(nameof(issueToCheck));
expectedIssue.NotNull(nameof(expectedIssue));

Check(
issueToCheck,
expectedIssue.Create());
}

/// <summary>
/// Checks values of an issue.
/// </summary>
Expand Down
61 changes: 61 additions & 0 deletions src/Cake.Issues.Tests/Testing/IssueCheckerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,67 @@

public sealed class IssueCheckerTests
{
public sealed class TheCheckMethodWithIssueBuilder
{
[Fact]
public void Should_Throw_If_IssueToCheck_Is_Null()
{
#pragma warning disable SA1123 // Do not place regions within elements
#region DupFinder Exclusion
#pragma warning restore SA1123 // Do not place regions within elements

// Given
var fixture = new IssueBuilderFixture();
IIssue issueToCheck = null;
var expectedIssue = fixture.IssueBuilder;

// When
var result = Record.Exception(() =>
IssueChecker.Check(issueToCheck, expectedIssue));

// Then
result.IsArgumentNullException("issueToCheck");

#endregion
}

[Fact]
public void Should_Throw_If_ExpectedIssue_Is_Null()
{
#pragma warning disable SA1123 // Do not place regions within elements
#region DupFinder Exclusion
#pragma warning restore SA1123 // Do not place regions within elements

// Given
var fixture = new IssueBuilderFixture();
var issueToCheck = fixture.IssueBuilder.Create();
IssueBuilder expectedIssue = null;

// When
var result = Record.Exception(() =>
IssueChecker.Check(issueToCheck, expectedIssue));

// Then
result.IsArgumentNullException("expectedIssue");

#endregion
}

[Fact]
public void Should_Not_Throw_If_Issues_Are_Identical()
{
// Given
var fixture = new IssueCheckerFixture();
var issueToCheck = fixture.IssueBuilder.Create();
var expectedIssue = fixture.IssueBuilder;

// When
IssueChecker.Check(issueToCheck, expectedIssue);

// Then
}
}

public sealed class TheCheckMethodComparingTwoIssues
{
[Fact]
Expand Down

0 comments on commit 8da63f6

Please sign in to comment.