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;
///
/// Tests the functionality of the WriteFiles().
///
public class MakeSingleLinkListItemsTests : TestBase
{
public MakeSingleLinkListItemsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void AlreadyFullMarkdownLink()
{
using MarkdownTestContext context = this.CreateContext();
List input = new()
{
new Entity()
.Set(IsMarkdown.Instance)
.SetTextContent("- [Empty](link)"),
};
MakeSingleLinkListItems?
op = context.Resolve();
IEnumerable 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 input = new()
{
new Entity()
.Set(IsMarkdown.Instance)
.SetTextContent("- [Empty](link) space"),
};
MakeSingleLinkListItems?
op = context.Resolve();
IEnumerable 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 input = new()
{
new Entity()
.Set(IsMarkdown.Instance)
.SetTextContent("- Empty"),
};
MakeSingleLinkListItems?
op = context.Resolve();
IEnumerable output = op.Run(input);
string content = output.First().GetTextContentString()!.Trim();
Assert.Equal("- Empty", content);
}
[Fact]
public void RemoveSecondMarkdownLink()
{
using MarkdownTestContext context = this.CreateContext();
List input = new()
{
new Entity()
.Set(IsMarkdown.Instance)
.SetTextContent("- [Empty](link) [space](link2)"),
};
MakeSingleLinkListItems?
op = context.Resolve();
IEnumerable output = op.Run(input);
string content = output.First().GetTextContentString()!.Trim();
Assert.Equal("- [Empty space](link)", content);
}
}