101 lines
2.7 KiB
C#
101 lines
2.7 KiB
C#
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
|
||
|
using MfGames.Gallium;
|
||
|
using MfGames.Nitride.Contents;
|
||
|
using MfGames.Nitride.Markdown;
|
||
|
using MfGames.Nitride.Tests;
|
||
|
using MfGames.TestSetup;
|
||
|
|
||
|
using Xunit;
|
||
|
using Xunit.Abstractions;
|
||
|
|
||
|
namespace MfGames.Nitride.Slugs.Tests;
|
||
|
|
||
|
/// <summary>
|
||
|
/// Tests the functionality of the WriteFiles().
|
||
|
/// </summary>
|
||
|
public class MakeSingleLinkListItemsTests : TestBase<MarkdownTestContext>
|
||
|
{
|
||
|
public MakeSingleLinkListItemsTests(ITestOutputHelper output)
|
||
|
: base(output)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void AlreadyFullMarkdownLink()
|
||
|
{
|
||
|
using MarkdownTestContext context = this.CreateContext();
|
||
|
|
||
|
List<Entity> input = new()
|
||
|
{
|
||
|
new Entity()
|
||
|
.Set(IsMarkdown.Instance)
|
||
|
.SetTextContent("- [Empty](link)"),
|
||
|
};
|
||
|
MakeSingleLinkListItems?
|
||
|
op = context.Resolve<MakeSingleLinkListItems>();
|
||
|
IEnumerable<Entity> output = op.Run(input);
|
||
|
string content = output.First().GetText()!.Trim();
|
||
|
|
||
|
Assert.Equal("- [Empty](link)", content);
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void ExtendSingleMarkdownLink()
|
||
|
{
|
||
|
using MarkdownTestContext context = this.CreateContext();
|
||
|
|
||
|
List<Entity> input = new()
|
||
|
{
|
||
|
new Entity()
|
||
|
.Set(IsMarkdown.Instance)
|
||
|
.SetTextContent("- [Empty](link) space"),
|
||
|
};
|
||
|
MakeSingleLinkListItems?
|
||
|
op = context.Resolve<MakeSingleLinkListItems>();
|
||
|
IEnumerable<Entity> output = op.Run(input);
|
||
|
string content = output.First().GetText()!.Trim();
|
||
|
|
||
|
Assert.Equal("- [Empty space](link)", content);
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void NoLinksNoChange()
|
||
|
{
|
||
|
using MarkdownTestContext context = this.CreateContext();
|
||
|
|
||
|
List<Entity> input = new()
|
||
|
{
|
||
|
new Entity()
|
||
|
.Set(IsMarkdown.Instance)
|
||
|
.SetTextContent("- Empty"),
|
||
|
};
|
||
|
MakeSingleLinkListItems?
|
||
|
op = context.Resolve<MakeSingleLinkListItems>();
|
||
|
IEnumerable<Entity> output = op.Run(input);
|
||
|
string content = output.First().GetText()!.Trim();
|
||
|
|
||
|
Assert.Equal("- Empty", content);
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void RemoveSecondMarkdownLink()
|
||
|
{
|
||
|
using MarkdownTestContext context = this.CreateContext();
|
||
|
|
||
|
List<Entity> input = new()
|
||
|
{
|
||
|
new Entity()
|
||
|
.Set(IsMarkdown.Instance)
|
||
|
.SetTextContent("- [Empty](link) [space](link2)"),
|
||
|
};
|
||
|
MakeSingleLinkListItems?
|
||
|
op = context.Resolve<MakeSingleLinkListItems>();
|
||
|
IEnumerable<Entity> output = op.Run(input);
|
||
|
string content = output.First().GetText()!.Trim();
|
||
|
|
||
|
Assert.Equal("- [Empty space](link)", content);
|
||
|
}
|
||
|
}
|