2022-12-24 06:38:24 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using MfGames.Gallium;
|
|
|
|
using MfGames.Nitride.Contents;
|
|
|
|
using MfGames.TestSetup;
|
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
2023-01-15 00:19:42 +00:00
|
|
|
namespace MfGames.Nitride.Markdown.Tests;
|
2022-12-24 06:38:24 +00:00
|
|
|
|
|
|
|
/// <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);
|
2023-01-15 18:43:42 +00:00
|
|
|
string content = output.First().GetTextContentString()!.Trim();
|
2022-12-24 06:38:24 +00:00
|
|
|
|
|
|
|
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);
|
2023-01-15 18:43:42 +00:00
|
|
|
string content = output.First().GetTextContentString()!.Trim();
|
2022-12-24 06:38:24 +00:00
|
|
|
|
|
|
|
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);
|
2023-01-15 18:43:42 +00:00
|
|
|
string content = output.First().GetTextContentString()!.Trim();
|
2022-12-24 06:38:24 +00:00
|
|
|
|
|
|
|
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);
|
2023-01-15 18:43:42 +00:00
|
|
|
string content = output.First().GetTextContentString()!.Trim();
|
2022-12-24 06:38:24 +00:00
|
|
|
|
|
|
|
Assert.Equal("- [Empty space](link)", content);
|
|
|
|
}
|
|
|
|
}
|