Skip to content

Commit

Permalink
test: add tests for MDLink
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Aug 27, 2023
1 parent 2445e36 commit 43d2e8f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions X10D.Tests/src/Text/MarkdownTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,46 @@ public void MDItalic_ShouldReturnItalicTextWithUnderscores_GivenText_AndTrueUnde
Assert.That("Hello, world!".MDItalic(true), Is.EqualTo("_Hello, world!_"));
}

[Test]
public void MDLink_ShouldThrowArgumentNullException_GivenNullUrl()
{
Assert.Multiple(() =>
{
Assert.Throws<ArgumentNullException>(() => "".MDLink((string)null!));
Assert.Throws<ArgumentNullException>(() => "".MDLink((Uri)null!));
Assert.Throws<ArgumentNullException>(() => ((Uri)null!).MDLink("Hello, world!"));
});
}

[Test]
public void MDLink_ShouldReturnUrlOnly_GivenNullOrEmptyLabel()
{
const string url = "https://example.com/";
Assert.Multiple(() =>
{
Assert.That(((string)null!).MDLink(url), Is.EqualTo(url));
Assert.That(string.Empty.MDLink(url), Is.EqualTo(url));

Assert.That(new Uri(url).MDLink(null), Is.EqualTo(url));
Assert.That(new Uri(url).MDLink(string.Empty), Is.EqualTo(url));
});
}

[Test]
public void MDLink_ShouldReturnFormattedLink_GivenValidLabelAndUrl()
{
const string url = "https://example.com/";
const string label = "Hello, world!";

Assert.Multiple(() =>
{
Assert.That(label.MDLink(url), Is.EqualTo($"[{label}]({url})"));
Assert.That(label.MDLink(new Uri(url)), Is.EqualTo($"[{label}]({url})"));

Assert.That(new Uri(url).MDLink(label), Is.EqualTo($"[{label}]({url})"));
});
}

[Test]
public void MDStrikeOut_ShouldThrowArgumentNullException_GivenNull()
{
Expand Down

0 comments on commit 43d2e8f

Please sign in to comment.