2021-12-06 21:07:47 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Online.Chat
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2021-12-07 00:38:37 +00:00
|
|
|
public class MessageNotifierTest
|
2021-12-06 21:07:47 +00:00
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameMidlinePositive()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("This is a test message", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameStartOfLinePositive()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test message", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameEndOfLinePositive()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("This is a test", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameMidlineNegative()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("This is a testmessage for notifications", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameStartOfLineNegative()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Testmessage", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameEndOfLineNegative()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("This is a notificationtest", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2021-12-28 19:21:59 +00:00
|
|
|
public void TestContainsUsernameBetweenPunctuation()
|
2021-12-06 21:07:47 +00:00
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Hello 'test'-message", "Test"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameUnicode()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test \u0460\u0460 message", "\u0460\u0460"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameUnicodeNegative()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Test ha\u0460\u0460o message", "\u0460\u0460"));
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
2021-12-07 00:55:45 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameSpecialCharactersPositive()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test [#^-^#] message", "[#^-^#]"));
|
2021-12-07 00:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameSpecialCharactersNegative()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Test pad[#^-^#]oru message", "[#^-^#]"));
|
2021-12-07 00:55:45 +00:00
|
|
|
}
|
2021-12-07 01:34:35 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameAtSign()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("@username hi", "username"));
|
2021-12-07 01:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestContainsUsernameColon()
|
|
|
|
{
|
2021-12-14 15:23:51 +00:00
|
|
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("username: hi", "username"));
|
2021-12-07 01:34:35 +00:00
|
|
|
}
|
2021-12-06 21:07:47 +00:00
|
|
|
}
|
|
|
|
}
|