mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
test: add tests for MDLink
This commit is contained in:
parent
2445e36cfd
commit
43d2e8feea
@ -105,6 +105,46 @@ internal class MarkdownTests
|
|||||||
Assert.That("Hello, world!".MDItalic(true), Is.EqualTo("_Hello, world!_"));
|
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]
|
[Test]
|
||||||
public void MDStrikeOut_ShouldThrowArgumentNullException_GivenNull()
|
public void MDStrikeOut_ShouldThrowArgumentNullException_GivenNull()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user