Skip to content

Commit

Permalink
Merge branch 'release/0.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Sep 2, 2018
2 parents 26c2226 + 3dfe7d3 commit beb42f5
Show file tree
Hide file tree
Showing 4 changed files with 495 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nuspec/nuget/Cake.Issues.Testing.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Common helpers for testing add-ins based on Cake.Issues
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues"/>
<copyright>Copyright © BBT Software AG and contributors</copyright>
<tags>Cake Script Cake-Issues Issues Testing</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues/releases/tag/0.6.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues/releases/tag/0.6.1</releaseNotes>
</metadata>
<files>
<file src="netstandard2.0\Cake.Issues.Testing.dll" target="lib\netstandard2.0" />
Expand Down
2 changes: 1 addition & 1 deletion nuspec/nuget/Cake.Issues.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues"/>
<copyright>Copyright © BBT Software AG and contributors</copyright>
<tags>Cake Script Cake-Issues CodeAnalysis Linting Issues</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues/releases/tag/0.6.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues/releases/tag/0.6.1</releaseNotes>
</metadata>
<files>
<file src="netstandard2.0\Cake.Issues.dll" target="lib\netstandard2.0" />
Expand Down
332 changes: 332 additions & 0 deletions src/Cake.Issues.Tests/IIssueExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,332 @@
namespace Cake.Issues.Tests
{
using System;
using Cake.Issues.Testing;
using Shouldly;
using Xunit;

public sealed class IIssueExtensionsTests
{
public sealed class TheProjectPathExtension
{
[Fact]
public void Should_Throw_If_Issue_Is_Null()
{
// Given
IIssue issue = null;

// When
var result = Record.Exception(() => issue.ProjectPath());

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

[Fact]
public void Should_Return_Full_Path()
{
// Given
var projectPath = @"src\Cake.Issues\Cake.Issues.csproj";
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.InProjectFile(projectPath)
.Create();

// When
var result = issue.ProjectPath();

// Then
result.ShouldBe(@"src/Cake.Issues/Cake.Issues.csproj");
}

[Fact]
public void Should_Return_Null_If_Project_Is_Not_Set()
{
// Given
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.Create();

// When
var result = issue.ProjectPath();

// Then
result.ShouldBeNull();
}
}

public sealed class TheProjectDirectoryExtension
{
[Fact]
public void Should_Throw_If_Issue_Is_Null()
{
// Given
IIssue issue = null;

// When
var result = Record.Exception(() => issue.ProjectDirectory());

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

[Fact]
public void Should_Return_Full_Path()
{
// Given
var filePath = @"src\Cake.Issues\Foo.cs";
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.InProjectFile(filePath)
.Create();

// When
var result = issue.ProjectDirectory();

// Then
result.ShouldBe(@"src/Cake.Issues");
}

[Fact]
public void Should_Return_Null_If_File_Is_Not_Set()
{
// Given
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.Create();

// When
var result = issue.ProjectDirectory();

// Then
result.ShouldBeNull();
}
}

public sealed class TheFilePathExtension
{
[Fact]
public void Should_Throw_If_Issue_Is_Null()
{
// Given
IIssue issue = null;

// When
var result = Record.Exception(() => issue.FilePath());

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

[Fact]
public void Should_Return_Full_Path()
{
// Given
var filePath = @"src\Cake.Issues\Foo.cs";
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.InFile(filePath)
.Create();

// When
var result = issue.FilePath();

// Then
result.ShouldBe(@"src/Cake.Issues/Foo.cs");
}

[Fact]
public void Should_Return_Null_If_File_Is_Not_Set()
{
// Given
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.Create();

// When
var result = issue.FilePath();

// Then
result.ShouldBeNull();
}
}

public sealed class TheFileDirectoryExtension
{
[Fact]
public void Should_Throw_If_Issue_Is_Null()
{
// Given
IIssue issue = null;

// When
var result = Record.Exception(() => issue.FileDirectory());

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

[Fact]
public void Should_Return_Full_Path()
{
// Given
var filePath = @"src\Cake.Issues\Foo.cs";
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.InFile(filePath)
.Create();

// When
var result = issue.FileDirectory();

// Then
result.ShouldBe(@"src/Cake.Issues");
}

[Fact]
public void Should_Return_Null_If_File_Is_Not_Set()
{
// Given
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.Create();

// When
var result = issue.FileDirectory();

// Then
result.ShouldBeNull();
}
}

public sealed class TheFileNameExtension
{
[Fact]
public void Should_Throw_If_Issue_Is_Null()
{
// Given
IIssue issue = null;

// When
var result = Record.Exception(() => issue.FileName());

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

[Fact]
public void Should_Return_Full_Path()
{
// Given
var filePath = @"src\Cake.Issues\Foo.cs";
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.InFile(filePath)
.Create();

// When
var result = issue.FileName();

// Then
result.ShouldBe("Foo.cs");
}

[Fact]
public void Should_Return_Null_If_File_Is_Not_Set()
{
// Given
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.Create();

// When
var result = issue.FileName();

// Then
result.ShouldBeNull();
}
}

public sealed class TheReplaceIssuePatternExtension
{
[Fact]
public void Should_Throw_If_Pattern_Is_Null()
{
// Given
string pattern = null;
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.Create();

// When
var result = Record.Exception(() => pattern.ReplaceIssuePattern(issue));

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

[Fact]
public void Should_Throw_If_Issue_Is_Null()
{
// Given
var pattern = "foo";
IIssue issue = null;

// When
var result = Record.Exception(() => pattern.ReplaceIssuePattern(issue));

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

[Theory]
[InlineData("", "")]
[InlineData(" ", " ")]
[InlineData("foo", "foo")]
[InlineData("{foo}", "{foo}")]
[InlineData("foo {ProviderType} bar", "foo ProviderType Foo bar")]
[InlineData("foo {ProviderName} bar", "foo ProviderName Foo bar")]
[InlineData("foo {Priority} bar", "foo 400 bar")]
[InlineData("foo {PriorityName} bar", "foo Error bar")]
[InlineData("foo {ProjectPath} bar", "foo src/Cake.Issues/Cake.Issues.csproj bar")]
[InlineData("foo {ProjectDirectory} bar", "foo src/Cake.Issues bar")]
[InlineData("foo {ProjectName} bar", "foo Cake.Issues bar")]
[InlineData("foo {FilePath} bar", "foo src/Cake.Issues/foo.cs bar")]
[InlineData("foo {FileDirectory} bar", "foo src/Cake.Issues bar")]
[InlineData("foo {FileName} bar", "foo foo.cs bar")]
[InlineData("foo {Line} bar", "foo 42 bar")]
[InlineData("foo {Rule} bar", "foo Rule Foo bar")]
[InlineData("foo {RuleUrl} bar", "foo https://google.com/ bar")]
[InlineData("foo {Message} bar", "foo Message Foo bar")]
public void Should_Replace_Tokens(string pattern, string expectedResult)
{
// Given
var issue =
IssueBuilder
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
.InFile(@"src/Cake.Issues/foo.cs", 42)
.InProject(@"src/Cake.Issues/Cake.Issues.csproj", "Cake.Issues")
.OfRule("Rule Foo", new Uri("https://google.com"))
.WithPriority(IssuePriority.Error)
.Create();

// When
var result = pattern.ReplaceIssuePattern(issue);

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

0 comments on commit beb42f5

Please sign in to comment.