Skip to content
This repository has been archived by the owner on Dec 28, 2017. It is now read-only.

Commit

Permalink
Merge branch 'release/0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jun 23, 2017
2 parents 2439550 + cf77672 commit d9985cf
Show file tree
Hide file tree
Showing 26 changed files with 1,147 additions and 461 deletions.
4 changes: 2 additions & 2 deletions nuspec/nuget/Cake.Prca.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<description>The Pull Request Code Analysis Addin for Cake allows you to write issue found using any code analyzer or linter as comments to pull requests.</description>
<licenseUrl>https://github.com/cake-contrib/Cake.Prca/blob/develop/LICENSE</licenseUrl>
<projectUrl>http://cake-contrib.github.io/Cake.Prca.Website/</projectUrl>
<iconUrl>https://raw.githubusercontent.com/cake-build/graphics/aba74fb4cb5fe9454381af2cc70c870088229d5c/png/cake-medium.png</iconUrl>
<iconUrl>https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright © 2017 BBT Software AG, Root/Zermatt, Switzerland</copyright>
<tags>Cake Script PullRequest CodeAnalysis Linting</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Prca/releases/tag/0.4.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Prca/releases/tag/0.5.0</releaseNotes>
</metadata>
<files>
<file src="Cake.Prca.dll" target="lib\net45" />
Expand Down
4 changes: 4 additions & 0 deletions src/Cake.Prca.Tests/Cake.Prca.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<ItemGroup>
<Compile Include="FakeRuleUrlResolver.cs" />
<Compile Include="FakeRuleDescription.cs" />
<Compile Include="IssueReaderTests.cs" />
<Compile Include="Issues\CodeAnalysisIssueOfTTests.cs" />
<Compile Include="Issues\CodeAnalysisProviderTests.cs" />
<Compile Include="ExceptionAssertExtensions.cs" />
Expand All @@ -87,10 +88,13 @@
<Compile Include="PrcaArgumentChecksTests.cs" />
<Compile Include="PrcaFixture.cs" />
<Compile Include="PrcaResultTests.cs" />
<Compile Include="PrcaSettingsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Issues\StringPathExtensionsTests.cs" />
<Compile Include="PullRequests\PrcaDiscussionThreadTests.cs" />
<Compile Include="PullRequests\PullRequestSystemTests.cs" />
<Compile Include="ReadIssuesSettingsTests.cs" />
<Compile Include="ReportIssuesToPullRequestSettingsTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cake.Prca\Cake.Prca.csproj">
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Prca.Tests/FakeCodeAnalysisProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public FakeCodeAnalysisProvider(ICakeLog log, IEnumerable<ICodeAnalysisIssue> is

public new ICakeLog Log => base.Log;

public new ReportCodeAnalysisIssuesToPullRequestSettings PrcaSettings => base.PrcaSettings;
public new PrcaSettings PrcaSettings => base.PrcaSettings;

public PrcaCommentFormat Format { get; private set; }

Expand Down
11 changes: 10 additions & 1 deletion src/Cake.Prca.Tests/FakePullRequestSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,28 @@ public FakePullRequestSystem(

public new ICakeLog Log => base.Log;

public new ReportCodeAnalysisIssuesToPullRequestSettings PrcaSettings => base.PrcaSettings;
public new ReportIssuesToPullRequestSettings PrcaSettings => base.PrcaSettings;

public IEnumerable<IPrcaDiscussionThread> ThreadsMarkedAsFixed => this.threadsMarkedAsFixed;

public IEnumerable<ICodeAnalysisIssue> PostedIssues => this.postedIssues;

public PrcaCommentFormat CommentFormat { get; set; }

public bool ShouldFailOnInitialization { get; set; } = false;

public override PrcaCommentFormat GetPreferredCommentFormat()
{
return this.CommentFormat;
}

public override bool Initialize(ReportIssuesToPullRequestSettings settings)
{
var result = base.Initialize(settings);

return result && !this.ShouldFailOnInitialization;
}

protected override IEnumerable<IPrcaDiscussionThread> InternalFetchActiveDiscussionThreads(string commentSource)
{
return this.discussionThreads;
Expand Down
307 changes: 307 additions & 0 deletions src/Cake.Prca.Tests/IssueReaderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
namespace Cake.Prca.Tests
{
using System.Collections.Generic;
using System.Linq;
using Prca.Issues;
using Shouldly;
using Xunit;

public sealed class IssueReaderTests
{
public sealed class TheCtor
{
[Fact]
public void Should_Throw_If_Log_Is_Null()
{
// Given
var fixture = new PrcaFixture
{
Log = null
};

// When
var result = Record.Exception(() => fixture.ReadIssues(PrcaCommentFormat.Undefined));

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

[Fact]
public void Should_Throw_If_Code_Analysis_Provider_List_Is_Null()
{
// Given
var fixture = new PrcaFixture
{
CodeAnalysisProviders = null
};

// When
var result = Record.Exception(() => fixture.ReadIssues(PrcaCommentFormat.Undefined));

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

[Fact]
public void Should_Throw_If_Code_Analysis_Provider_List_Is_Empty()
{
// Given
var fixture = new PrcaFixture();
fixture.CodeAnalysisProviders.Clear();

// When
var result = Record.Exception(() => fixture.ReadIssues(PrcaCommentFormat.Undefined));

// Then
result.IsArgumentException("issueProviders");
}

[Fact]
public void Should_Throw_If_Code_Analysis_Provider_Is_Null()
{
// Given
var fixture = new PrcaFixture();
fixture.CodeAnalysisProviders.Clear();
fixture.CodeAnalysisProviders.Add(null);

// When
var result = Record.Exception(() => fixture.ReadIssues(PrcaCommentFormat.Undefined));

// Then
result.IsArgumentOutOfRangeException("issueProviders");
}

[Fact]
public void Should_Throw_If_Settings_Are_Null()
{
// Given
var fixture = new PrcaFixture
{
Settings = null
};

// When
var result = Record.Exception(() => fixture.ReadIssues(PrcaCommentFormat.Undefined));

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

public sealed class TheReadIssuesMethod
{
[Fact]
public void Should_Initialize_Code_Analysis_Provider()
{
// Given
var fixture = new PrcaFixture();

// When
fixture.ReadIssues(PrcaCommentFormat.Undefined);

// Then
fixture.CodeAnalysisProviders.ShouldAllBe(x => x.PrcaSettings == fixture.Settings);
}

[Fact]
public void Should_Initialize_All_Code_Analysis_Provider()
{
// Given
var fixture = new PrcaFixture();
fixture.CodeAnalysisProviders.Clear();
fixture.CodeAnalysisProviders.Add(
new FakeCodeAnalysisProvider(
fixture.Log,
new List<ICodeAnalysisIssue>
{
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\FakeCodeAnalysisProvider.cs",
10,
"Foo",
0,
"Foo",
"Foo"),
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\FakeCodeAnalysisProvider.cs",
12,
"Bar",
0,
"Bar",
"Bar")
}));
fixture.CodeAnalysisProviders.Add(
new FakeCodeAnalysisProvider(
fixture.Log,
new List<ICodeAnalysisIssue>
{
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\Foo.cs",
5,
"Foo",
0,
"Foo",
"Foo"),
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\Bar.cs",
7,
"Bar",
0,
"Bar",
"Bar")
}));

// When
fixture.ReadIssues(PrcaCommentFormat.Undefined);

// Then
fixture.CodeAnalysisProviders.ShouldAllBe(x => x.PrcaSettings == fixture.Settings);
}

[Fact]
public void Should_Read_Correct_Number_Of_Code_Analysis_Issues()
{
// Given
var issue1 =
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\FakeCodeAnalysisProvider.cs",
10,
"Foo",
0,
"Foo",
"Foo");
var issue2 =
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\FakeCodeAnalysisProvider.cs",
12,
"Bar",
0,
"Bar",
"Bar");
var fixture = new PrcaFixture();
fixture.CodeAnalysisProviders.Clear();
fixture.CodeAnalysisProviders.Add(
new FakeCodeAnalysisProvider(
fixture.Log,
new List<ICodeAnalysisIssue>
{
issue1,
issue2
}));

// When
var issues = fixture.ReadIssues(PrcaCommentFormat.Undefined).ToList();

// Then
issues.Count.ShouldBe(2);
issues.ShouldContain(issue1);
issues.ShouldContain(issue2);
}

[Fact]
public void Should_Read_Correct_Number_Of_Code_Analysis_Issues_Not_Related_To_A_File()
{
// Given
var issue1 =
new CodeAnalysisIssue(
null,
null,
"Foo",
0,
"Foo",
"Foo");
var issue2 =
new CodeAnalysisIssue(
null,
null,
"Bar",
0,
"Bar",
"Bar");
var fixture = new PrcaFixture();
fixture.CodeAnalysisProviders.Clear();
fixture.CodeAnalysisProviders.Add(
new FakeCodeAnalysisProvider(
fixture.Log,
new List<ICodeAnalysisIssue>
{
issue1,
issue2
}));

// When
var issues = fixture.ReadIssues(PrcaCommentFormat.Undefined).ToList();

// Then
issues.Count.ShouldBe(2);
issues.ShouldContain(issue1);
issues.ShouldContain(issue2);
}

[Fact]
public void Should_Read_Correct_Number_Of_Code_Analysis_Issues_From_Multiple_Providers()
{
// Given
var issue1 =
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\FakeCodeAnalysisProvider.cs",
10,
"Foo",
0,
"Foo",
"Foo");
var issue2 =
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\FakeCodeAnalysisProvider.cs",
12,
"Bar",
0,
"Bar",
"Bar");
var issue3 =
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\Foo.cs",
5,
"Foo",
0,
"Foo",
"Foo");
var issue4 =
new CodeAnalysisIssue(
@"src\Cake.Prca.Tests\Bar.cs",
7,
"Bar",
0,
"Bar",
"Bar");
var fixture = new PrcaFixture();
fixture.CodeAnalysisProviders.Clear();
fixture.CodeAnalysisProviders.Add(
new FakeCodeAnalysisProvider(
fixture.Log,
new List<ICodeAnalysisIssue>
{
issue1,
issue2
}));
fixture.CodeAnalysisProviders.Add(
new FakeCodeAnalysisProvider(
fixture.Log,
new List<ICodeAnalysisIssue>
{
issue3,
issue4
}));

// When
var issues = fixture.ReadIssues(PrcaCommentFormat.Undefined).ToList();

// Then
issues.Count.ShouldBe(4);
issues.ShouldContain(issue1);
issues.ShouldContain(issue2);
issues.ShouldContain(issue3);
issues.ShouldContain(issue4);
}
}
}
}
Loading

0 comments on commit d9985cf

Please sign in to comment.