mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:52:57 +08:00
Add many more tests
This commit is contained in:
parent
1920a4e029
commit
1dbaf9b7a7
@ -108,9 +108,9 @@ namespace osu.Game.Tests.Chat
|
||||
[Test]
|
||||
public void TestOldFormatLink()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a (simple test)[https://osu.ppy.sh]." });
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a (simple test)[https://osu.ppy.sh] of links." });
|
||||
|
||||
Assert.AreEqual("This is a simple test.", result.DisplayContent);
|
||||
Assert.AreEqual("This is a simple test of links.", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||
Assert.AreEqual(10, result.Links[0].Index);
|
||||
@ -129,6 +129,62 @@ namespace osu.Game.Tests.Chat
|
||||
Assert.AreEqual(11, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMarkdownFormatLink()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a [simple test](https://osu.ppy.sh)." });
|
||||
|
||||
Assert.AreEqual("This is a simple test.", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||
Assert.AreEqual(10, result.Links[0].Index);
|
||||
Assert.AreEqual(11, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChannelLink()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is an #english and #japanese." });
|
||||
|
||||
Assert.AreEqual("This is an #english and #japanese.", result.DisplayContent);
|
||||
Assert.AreEqual(2, result.Links.Count);
|
||||
Assert.AreEqual("osu://chan/#english", result.Links[0].Url);
|
||||
Assert.AreEqual("osu://chan/#japanese", result.Links[1].Url);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsuProtocol()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "This is a custom protocol osu://chan/#english." });
|
||||
|
||||
Assert.AreEqual("This is a custom protocol osu://chan/#english.", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("osu://chan/#english", result.Links[0].Url);
|
||||
Assert.AreEqual(26, result.Links[0].Index);
|
||||
Assert.AreEqual(19, result.Links[0].Length);
|
||||
|
||||
result = MessageFormatter.FormatMessage(new Message { Content = "This is a [custom protocol](osu://chan/#english)." });
|
||||
|
||||
Assert.AreEqual("This is a custom protocol.", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("osu://chan/#english", result.Links[0].Url);
|
||||
Assert.AreEqual("#english", result.Links[0].Argument);
|
||||
Assert.AreEqual(10, result.Links[0].Index);
|
||||
Assert.AreEqual(15, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsuMpProtocol()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "Join my multiplayer game osump://12346." });
|
||||
|
||||
Assert.AreEqual(result.Content, result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("osump://12346", result.Links[0].Url);
|
||||
Assert.AreEqual(25, result.Links[0].Index);
|
||||
Assert.AreEqual(13, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRecursiveBreaking()
|
||||
{
|
||||
|
@ -100,6 +100,7 @@ namespace osu.Game.Tests.Visual
|
||||
addMessageWithChecks("Wiki link for tasty [[Performance Points]]", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("(osu forums)[https://osu.ppy.sh/forum] (old link format)", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("[https://osu.ppy.sh/home New site] (new link format)", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("[osu forums](https://osu.ppy.sh/forum) (new link format 2)", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("[https://osu.ppy.sh/home This is only a link to the new osu webpage but this is supposed to test word wrap.]", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("is now listening to [https://osu.ppy.sh/s/93523 IMAGE -MATERIAL- <Version 0>]", 1, true, expectedActions: LinkAction.OpenBeatmapSet);
|
||||
addMessageWithChecks("is now playing [https://osu.ppy.sh/b/252238 IMAGE -MATERIAL- <Version 0>]", 1, true, expectedActions: LinkAction.OpenBeatmap);
|
||||
@ -113,8 +114,8 @@ namespace osu.Game.Tests.Visual
|
||||
addMessageWithChecks("Join my multiplayer game osump://12346.",1, expectedActions: LinkAction.JoinMultiplayerMatch);
|
||||
addMessageWithChecks("Join my [multiplayer game](osump://12346).", 1, expectedActions: LinkAction.JoinMultiplayerMatch);
|
||||
addMessageWithChecks("Join my [#english](osu://chan/english).", 1, expectedActions: LinkAction.OpenChannel);
|
||||
addMessageWithChecks("Join my osu://chan/english.", 1, expectedActions: LinkAction.OpenChannel);
|
||||
addMessageWithChecks("Join my #english.", 1, expectedActions: LinkAction.OpenChannel);
|
||||
addMessageWithChecks("Join my osu://chan/#english.", 1, expectedActions: LinkAction.OpenChannel);
|
||||
addMessageWithChecks("Join my #english or #japanese channels.", 2, expectedActions: new [] { LinkAction.OpenChannel, LinkAction.OpenChannel });
|
||||
}
|
||||
|
||||
private void testEcho()
|
||||
|
Loading…
Reference in New Issue
Block a user