100 lines
3.2 KiB
C#
100 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using MfGames.Gallium;
|
|
using MfGames.Nitride.Contents;
|
|
using MfGames.TestSetup;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace MfGames.Nitride.Markdown.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().GetTextContentString()!.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().GetTextContentString()!.Trim();
|
|
|
|
Assert.Equal("- [Empty space](link)", content);
|
|
}
|
|
|
|
[Fact]
|
|
public void ExtendSingleMarkdownLinkStar()
|
|
{
|
|
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().GetTextContentString()!.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().GetTextContentString()!.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().GetTextContentString()!.Trim();
|
|
|
|
Assert.Equal("- [Empty space](link)", content);
|
|
}
|
|
}
|