1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 20:05:29 +08:00

Extract local method

This commit is contained in:
Susko3 2023-11-30 23:25:28 +01:00
parent 9a32c0368e
commit 3ca3f25492

View File

@ -59,8 +59,6 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestLinksGeneral()
{
int messageIndex = 0;
addMessageWithChecks("test!");
addMessageWithChecks("dev.ppy.sh!");
addMessageWithChecks("https://dev.ppy.sh!", expectedActions: LinkAction.External);
@ -95,21 +93,21 @@ namespace osu.Game.Tests.Visual.Online
addMessageWithChecks("Join my #english or #japanese channels.", expectedActions: new[] { LinkAction.OpenChannel, LinkAction.OpenChannel });
addMessageWithChecks("Join my #english or #nonexistent #hashtag channels.", expectedActions: LinkAction.OpenChannel);
addMessageWithChecks("Hello world\uD83D\uDE12(<--This is an emoji). There are more:\uD83D\uDE10\uD83D\uDE00,\uD83D\uDE20");
}
void addMessageWithChecks(string text, bool isAction = false, bool isImportant = false, params LinkAction[] expectedActions)
private void addMessageWithChecks(string text, bool isAction = false, bool isImportant = false, params LinkAction[] expectedActions)
{
ChatLine newLine = null;
int index = messageIndex++;
AddStep("add message", () =>
{
newLine = new ChatLine(new DummyMessage(text, isAction, isImportant, index));
newLine = new ChatLine(new DummyMessage(text, isAction, isImportant));
textContainer.Add(newLine);
});
AddAssert($"msg #{index} has the right action", () => newLine.Message.Links.Select(l => l.Action), () => Is.EqualTo(expectedActions));
//AddAssert($"msg #{index} is " + (isAction ? "italic" : "not italic"), () => newLine.ContentFlow.Any() && isAction == isItalic());
AddAssert($"msg #{index} shows {expectedActions.Length} link(s)", isShowingLinks);
AddAssert($"msg has the right action", () => newLine.Message.Links.Select(l => l.Action), () => Is.EqualTo(expectedActions));
//AddAssert($"msg is " + (isAction ? "italic" : "not italic"), () => newLine.ContentFlow.Any() && isAction == isItalic());
AddAssert($"msg shows {expectedActions.Length} link(s)", isShowingLinks);
//bool isItalic() => newLine.ContentFlow.Where(d => d is OsuSpriteText).Cast<OsuSpriteText>().All(sprite => sprite.Font.Italics);
@ -126,7 +124,6 @@ namespace osu.Game.Tests.Visual.Online
&& newLine.DrawableContentFlow.Except(linkSprites.Concat(linkCompilers)).All(d => d.Colour == textColour);
}
}
}
[Test]
public void TestEcho()