-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
1 parent
cc47312
commit 20bedc2
Showing
8 changed files
with
171 additions
and
25 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
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
4 changes: 4 additions & 0 deletions
4
src/Tests/StartEndTesterIsBeginSnippetTests.ShouldThrowForKeyEndingWithSymbol.approved.txt
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,4 @@ | ||
Key should not start or end with symbols. | ||
Key: key_ | ||
Path: file | ||
Line: <!-- begin-snippet: key_ --> |
4 changes: 4 additions & 0 deletions
4
src/Tests/StartEndTesterIsBeginSnippetTests.ShouldThrowForKeyStartingWithSymbol.approved.txt
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,4 @@ | ||
Key should not start or end with symbols. | ||
Key: _key | ||
Path: file | ||
Line: <!-- begin-snippet: _key--> |
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,107 @@ | ||
using ApprovalTests; | ||
using MarkdownSnippets; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
public class StartEndTesterIsBeginSnippetTests : | ||
TestBase | ||
{ | ||
[Fact] | ||
public void CanExtractFromXml() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("<!-- begin-snippet: CodeKey -->", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("CodeKey", key); | ||
} | ||
|
||
[Fact] | ||
public void ShouldThrowForNoKey() | ||
{ | ||
var exception = Assert.Throws<SnippetReadingException>(() => StartEndTester.IsBeginSnippet("<!-- begin-snippet: -->", "file", out _)); | ||
Assert.Equal("No Key could be derived. Line: '<!-- begin-snippet: -->'.", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void ShouldNotThrowForNoKeyWithNoSpace() | ||
{ | ||
StartEndTester.IsBeginSnippet("<!--begin-snippet:-->", "file", out _); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractFromXmlWithMissingSpaces() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("<!--begin-snippet: CodeKey-->", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("CodeKey", key); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractFromXmlWithExtraSpaces() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("<!-- begin-snippet: CodeKey -->", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("CodeKey", key); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractWithNoTrailingCharacters() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("<!-- begin-snippet: CodeKey", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("CodeKey", key); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractWithUnderScores() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("<!-- begin-snippet: Code_Key -->", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("Code_Key", key); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractWithDashes() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("<!-- begin-snippet: Code-Key -->", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("Code-Key", key); | ||
} | ||
|
||
[Fact] | ||
public void ShouldThrowForKeyStartingWithSymbol() | ||
{ | ||
var exception = Assert.Throws<SnippetReadingException>(() => | ||
StartEndTester.IsBeginSnippet("<!-- begin-snippet: _key-->", "file", out _)); | ||
|
||
Approvals.Verify(exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void ShouldThrowForKeyEndingWithSymbol() | ||
{ | ||
var exception = Assert.Throws<SnippetReadingException>(() => | ||
StartEndTester.IsBeginSnippet("<!-- begin-snippet: key_ -->", "file", out _)); | ||
Approvals.Verify(exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractWithDifferentEndComments() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("/* begin-snippet: CodeKey */", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("CodeKey", key); | ||
} | ||
|
||
[Fact] | ||
public void CanExtractWithDifferentEndCommentsAndNoSpaces() | ||
{ | ||
var isStartCode = StartEndTester.IsBeginSnippet("/*begin-snippet: CodeKey */", "file", out var key); | ||
Assert.True(isStartCode); | ||
Assert.Equal("CodeKey", key); | ||
} | ||
|
||
public StartEndTesterIsBeginSnippetTests(ITestOutputHelper output) : | ||
base(output) | ||
{ | ||
} | ||
} |
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