This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/tests/MfGames.Nitride.Markdown.Tests/MakeSingleLinkListItemsTests.cs

98 lines
2.7 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 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);
}
}