This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
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
25 changed files
with
832 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Nuget] | ||
; Use the new InProcess client, because some packages have long file paths. | ||
UseInProcessClient=true |
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
3 changes: 2 additions & 1 deletion
3
...ests/MarkdownlintIssuesProviderFixture.cs → ...lint/MarkdownlintIssuesProviderFixture.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
3 changes: 2 additions & 1 deletion
3
....Tests/MarkdownlintIssuesProviderTests.cs → ...wnlint/MarkdownlintIssuesProviderTests.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
3 changes: 2 additions & 1 deletion
3
....Tests/MarkdownlintIssuesSettingsTests.cs → ...wnlint/MarkdownlintIssuesSettingsTests.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
48 changes: 48 additions & 0 deletions
48
src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderFixture.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,48 @@ | ||
namespace Cake.Issues.Markdownlint.Tests.MarkdownlintCli | ||
{ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Cake.Issues.Markdownlint.MarkdownlintCli; | ||
using Cake.Testing; | ||
using Core.Diagnostics; | ||
|
||
internal class MarkdownlintCliIssuesProviderFixture | ||
{ | ||
public MarkdownlintCliIssuesProviderFixture(string fileResourceName) | ||
{ | ||
this.Log = new FakeLog { Verbosity = Verbosity.Normal }; | ||
|
||
using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Markdownlint.Tests.Testfiles." + fileResourceName)) | ||
{ | ||
using (var sr = new StreamReader(stream)) | ||
{ | ||
this.Settings = | ||
MarkdownlintCliIssuesSettings.FromContent( | ||
sr.ReadToEnd()); | ||
} | ||
} | ||
|
||
this.RepositorySettings = | ||
new RepositorySettings(@"c:\Source\Cake.Issues"); | ||
} | ||
|
||
public FakeLog Log { get; set; } | ||
|
||
public MarkdownlintCliIssuesSettings Settings { get; set; } | ||
|
||
public RepositorySettings RepositorySettings { get; set; } | ||
|
||
public MarkdownlintCliIssuesProvider Create() | ||
{ | ||
var provider = new MarkdownlintCliIssuesProvider(this.Log, this.Settings); | ||
provider.Initialize(this.RepositorySettings); | ||
return provider; | ||
} | ||
|
||
public IEnumerable<IIssue> ReadIssues() | ||
{ | ||
var issueProvider = this.Create(); | ||
return issueProvider.ReadIssues(IssueCommentFormat.PlainText); | ||
} | ||
} | ||
} |
156 changes: 156 additions & 0 deletions
156
src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderTests.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,156 @@ | ||
namespace Cake.Issues.Markdownlint.Tests.MarkdownlintCli | ||
{ | ||
using System.Linq; | ||
using Cake.Issues.Markdownlint.MarkdownlintCli; | ||
using Cake.Testing; | ||
using Core.IO; | ||
using Shouldly; | ||
using Testing; | ||
using Xunit; | ||
|
||
public sealed class MarkdownlintCliIssuesProviderTests | ||
{ | ||
public sealed class TheCtor | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Log_Is_Null() | ||
{ | ||
// Given / When | ||
var result = Record.Exception(() => | ||
new MarkdownlintCliIssuesProvider( | ||
null, | ||
MarkdownlintCliIssuesSettings.FromContent("Foo"))); | ||
|
||
// Then | ||
result.IsArgumentNullException("log"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
var result = Record.Exception(() => | ||
new MarkdownlintCliIssuesProvider( | ||
new FakeLog(), | ||
null)); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
} | ||
|
||
public sealed class TheReadIssuesMethod | ||
{ | ||
[Fact] | ||
public void Should_Read_Issue_Correct() | ||
{ | ||
// Given | ||
var fixture = new MarkdownlintCliIssuesProviderFixture("markdownlint-cli.log"); | ||
|
||
// When | ||
var issues = fixture.ReadIssues().ToList(); | ||
|
||
// Then | ||
issues.Count.ShouldBe(8); | ||
CheckIssue( | ||
issues[0], | ||
@"docs/index.md", | ||
1, | ||
"MD022", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022", | ||
0, | ||
"Headers should be surrounded by blank lines [Context: \"# foo\"]"); | ||
CheckIssue( | ||
issues[1], | ||
@"docs/index.md", | ||
2, | ||
"MD009", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009", | ||
0, | ||
"Trailing spaces [Expected: 2; Actual: 1]"); | ||
CheckIssue( | ||
issues[2], | ||
@"docs/index.md", | ||
2, | ||
"MD013", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013", | ||
0, | ||
"Line length [Expected: 100; Actual: 811]"); | ||
CheckIssue( | ||
issues[3], | ||
@"docs/index.md", | ||
4, | ||
"MD022", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022", | ||
0, | ||
"Headers should be surrounded by blank lines [Context: \"# bar\"]"); | ||
CheckIssue( | ||
issues[4], | ||
@"docs/index.md", | ||
4, | ||
"MD025", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md025", | ||
0, | ||
"Multiple top level headers in the same document [Context: \"# bar\"]"); | ||
CheckIssue( | ||
issues[5], | ||
@"docs/index.md", | ||
5, | ||
"MD031", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md031", | ||
0, | ||
"Fenced code blocks should be surrounded by blank lines [Context: \"```\"]"); | ||
CheckIssue( | ||
issues[6], | ||
@"docs/index.md", | ||
5, | ||
"MD040", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md040", | ||
0, | ||
"Fenced code blocks should have a language specified [Context: \"```\"]"); | ||
CheckIssue( | ||
issues[7], | ||
@"docs/index.md", | ||
6, | ||
"MD009", | ||
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009", | ||
0, | ||
"Trailing spaces [Expected: 2; Actual: 1]"); | ||
} | ||
|
||
private static void CheckIssue( | ||
IIssue issue, | ||
string affectedFileRelativePath, | ||
int? line, | ||
string rule, | ||
string ruleUrl, | ||
int priority, | ||
string message) | ||
{ | ||
if (issue.AffectedFileRelativePath == null) | ||
{ | ||
affectedFileRelativePath.ShouldBeNull(); | ||
} | ||
else | ||
{ | ||
issue.AffectedFileRelativePath.ToString().ShouldBe(new FilePath(affectedFileRelativePath).ToString()); | ||
issue.AffectedFileRelativePath.IsRelative.ShouldBe(true, "Issue path is not relative"); | ||
} | ||
|
||
issue.Line.ShouldBe(line); | ||
issue.Rule.ShouldBe(rule); | ||
|
||
if (issue.RuleUrl == null) | ||
{ | ||
ruleUrl.ShouldBeNull(); | ||
} | ||
else | ||
{ | ||
issue.RuleUrl.ToString().ShouldBe(ruleUrl); | ||
} | ||
|
||
issue.Priority.ShouldBe(priority); | ||
issue.Message.ShouldBe(message); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.