-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
0372508
commit 35fc9cd
Showing
7 changed files
with
241 additions
and
2 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,14 @@ | ||
// Copyright (c) Josef Pihrt. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using DotMarkdown.Linq; | ||
using static DotMarkdown.Tests.TestHelpers; | ||
|
||
namespace DotMarkdown.Tests; | ||
|
||
internal static class DocusaurusTestHelpers | ||
{ | ||
public static MFencedCodeBlock CreateCodeBlock() | ||
{ | ||
return new MFencedCodeBlock(CodeBlockText(), CodeBlockInfo()); | ||
} | ||
} |
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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<AssemblyName>DotMarkdown.Docusaurus.Tests</AssemblyName> | ||
<RootNamespace>DotMarkdown.Docusaurus.Tests</RootNamespace> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.1" /> | ||
<PackageReference Include="xunit" Version="2.3.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" /> | ||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Tests\DotMarkdown.Tests.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,80 @@ | ||
// Copyright (c) Josef Pihrt. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using DotMarkdown.Linq; | ||
using Xunit; | ||
using static DotMarkdown.Tests.TestHelpers; | ||
|
||
namespace DotMarkdown.Tests; | ||
|
||
public static class MDocusaurusCodeBlockTests | ||
{ | ||
[Fact] | ||
public static void MFencedCodeBlock_Equals() | ||
{ | ||
MFencedCodeBlock block = CreateCodeBlock(); | ||
|
||
Assert.True(block.Equals((object)block)); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_NotEquals() | ||
{ | ||
MFencedCodeBlock block = CreateCodeBlock(); | ||
MFencedCodeBlock block2 = block.Modify(); | ||
|
||
Assert.False(block.Equals((object)block2)); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_GetHashCode_Equal() | ||
{ | ||
MFencedCodeBlock block = CreateCodeBlock(); | ||
|
||
Assert.Equal(block.GetHashCode(), block.GetHashCode()); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_GetHashCode_NotEqual() | ||
{ | ||
MFencedCodeBlock block = CreateCodeBlock(); | ||
MFencedCodeBlock block2 = block.Modify(); | ||
|
||
Assert.NotEqual(block.GetHashCode(), block2.GetHashCode()); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_OperatorEquals() | ||
{ | ||
MFencedCodeBlock block = CreateCodeBlock(); | ||
MFencedCodeBlock block2 = block; | ||
|
||
Assert.True(block == block2); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_OperatorNotEquals() | ||
{ | ||
MFencedCodeBlock block = CreateCodeBlock(); | ||
MFencedCodeBlock block2 = block.Modify(); | ||
|
||
Assert.True(block != block2); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_Constructor_AssignText() | ||
{ | ||
string text = CodeBlockText(); | ||
var block = new MFencedCodeBlock(text: text, info: CodeBlockInfo()); | ||
|
||
Assert.Equal(text, block.Text); | ||
} | ||
|
||
[Fact] | ||
public static void MFencedCodeBlock_Constructor_AssignInfo() | ||
{ | ||
string info = CodeBlockInfo(); | ||
var block = new MFencedCodeBlock(text: CodeBlockText(), info: info); | ||
|
||
Assert.Equal(info, block.Info); | ||
} | ||
} |
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,98 @@ | ||
// Copyright (c) Josef Pihrt. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using DotMarkdown.Linq; | ||
using Xunit; | ||
using static DotMarkdown.Linq.MFactory; | ||
using static DotMarkdown.Tests.MarkdownSamples; | ||
using static DotMarkdown.Tests.TestHelpers; | ||
|
||
#pragma warning disable CS1718 | ||
|
||
namespace DotMarkdown.Tests; | ||
|
||
public static class MarkdownWriterTests | ||
{ | ||
[Theory] | ||
[InlineData("```", null)] | ||
[InlineData("```", CodeFenceStyle.Backtick)] | ||
[InlineData("~~~", CodeFenceStyle.Tilde)] | ||
public static void MarkdownWriter_Write_CodeBlock_CodeFenceStyle(string syntax, CodeFenceStyle? style) | ||
{ | ||
MarkdownWriter mw = CreateBuilderWithCodeFenceOptions(style); | ||
|
||
MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText); | ||
block.WriteTo(mw); | ||
|
||
Assert.Equal( | ||
syntax + DefaultText + NewLine + Chars + NewLine + syntax + NewLine2, | ||
mw.ToStringAndClear()); | ||
} | ||
|
||
[Fact] | ||
public static void MarkdownWriter_Write_CodeBlock_CodeBlockOptionsNone() | ||
{ | ||
MarkdownWriter mw = CreateBuilderWithCodeBlockOptions(CodeBlockOptions.None); | ||
|
||
MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText); | ||
|
||
mw.Write(DefaultText); | ||
mw.Write(block); | ||
mw.Write(block); | ||
mw.Write(DefaultText); | ||
|
||
Assert.Equal( | ||
DefaultText + NewLine + CodeBlockMarkdown + CodeBlockMarkdown + DefaultText, | ||
mw.ToStringAndClear()); | ||
} | ||
|
||
[Fact] | ||
public static void MarkdownWriter_Write_CodeBlock_CodeBlockOptionsEmptyLineBefore() | ||
{ | ||
MarkdownWriter mw = CreateBuilderWithCodeBlockOptions(CodeBlockOptions.EmptyLineBefore); | ||
|
||
MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText); | ||
|
||
mw.Write(DefaultText); | ||
mw.Write(block); | ||
mw.Write(block); | ||
mw.Write(DefaultText); | ||
|
||
Assert.Equal( | ||
DefaultText + NewLine2 + CodeBlockMarkdown + NewLine + CodeBlockMarkdown + DefaultText, | ||
mw.ToStringAndClear()); | ||
} | ||
|
||
[Fact] | ||
public static void MarkdownWriter_Write_CodeBlock_CodeBlockOptionsEmptyLineAfter() | ||
{ | ||
MarkdownWriter mw = CreateBuilderWithCodeBlockOptions(CodeBlockOptions.EmptyLineAfter); | ||
|
||
MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText); | ||
|
||
mw.Write(DefaultText); | ||
mw.Write(block); | ||
mw.Write(block); | ||
mw.Write(DefaultText); | ||
|
||
Assert.Equal( | ||
DefaultText + NewLine + CodeBlockMarkdown + NewLine + CodeBlockMarkdown + NewLine + DefaultText, | ||
mw.ToStringAndClear()); | ||
} | ||
|
||
[Fact] | ||
public static void MarkdownWriter_Write_CodeBlock_CodeBlockOptionsEmptyLineBeforeAndAfter() | ||
{ | ||
MarkdownWriter mw = CreateBuilderWithCodeBlockOptions(CodeBlockOptions.EmptyLineBeforeAndAfter); | ||
|
||
MFencedCodeBlock block = FencedCodeBlock(Chars, DefaultText); | ||
|
||
mw.Write(DefaultText); | ||
mw.Write(block); | ||
mw.Write(block); | ||
mw.Write(DefaultText); | ||
|
||
Assert.Equal( | ||
DefaultText + NewLine2 + CodeBlockMarkdown + NewLine + CodeBlockMarkdown + NewLine + DefaultText, | ||
mw.ToStringAndClear()); | ||
} | ||
} |
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