1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-07 01:23:56 +08:00
Files
osu-lazer/osu.Game.Tests/Online/Chat/MessageNotifierTest.cs
T
Dean Herbert a996261304 Update lots of packages (#36996)
It's been a while.

Notes:

- `SharpCompress` usages changed a bit. Manually adjusted these, mostly
just renames or adjusted parameters.
- nUnit 3 -> 4 migrated using
https://gist.github.com/peppy/07994386d793a117350cb5f24b156585. there's
a mode in this script to update to the newer `Assert.That` syntax but it
requires fixes and couldn't really be bothered.
- DeepEqual nuked as the only usage was on a disabled test. The reason
it's disabled has been merged upstream, but it's failing for other
(realm) reasons which I don't think is worthwhile to investigate for
now.
- This bumps Moq. I think the author is back in a sensible headspace and
the new version has the stupid shit removed, so probably okay? Nice to
be on a level playing field with packages for once in a long time.
- Automapper is silly, but we've discussed this elsewhere.
- `TestRealmKeyBindingStore` failures are a wildcard, but fixed by using
a more standardised testing method. Dunno why, don't care.

---------

Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
2026-03-17 03:58:02 +09:00

92 lines
2.9 KiB
C#

// 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 NUnit.Framework.Legacy;
using osu.Game.Online.Chat;
namespace osu.Game.Tests.Online.Chat
{
[TestFixture]
public class MessageNotifierTest
{
[Test]
public void TestContainsUsernameMidlinePositive()
{
ClassicAssert.True(MessageNotifier.MatchUsername("This is a test message", "Test").Success);
}
[Test]
public void TestContainsUsernameStartOfLinePositive()
{
ClassicAssert.True(MessageNotifier.MatchUsername("Test message", "Test").Success);
}
[Test]
public void TestContainsUsernameEndOfLinePositive()
{
ClassicAssert.True(MessageNotifier.MatchUsername("This is a test", "Test").Success);
}
[Test]
public void TestContainsUsernameMidlineNegative()
{
ClassicAssert.False(MessageNotifier.MatchUsername("This is a testmessage for notifications", "Test").Success);
}
[Test]
public void TestContainsUsernameStartOfLineNegative()
{
ClassicAssert.False(MessageNotifier.MatchUsername("Testmessage", "Test").Success);
}
[Test]
public void TestContainsUsernameEndOfLineNegative()
{
ClassicAssert.False(MessageNotifier.MatchUsername("This is a notificationtest", "Test").Success);
}
[Test]
public void TestContainsUsernameBetweenPunctuation()
{
ClassicAssert.True(MessageNotifier.MatchUsername("Hello 'test'-message", "Test").Success);
}
[Test]
public void TestContainsUsernameUnicode()
{
ClassicAssert.True(MessageNotifier.MatchUsername("Test \u0460\u0460 message", "\u0460\u0460").Success);
}
[Test]
public void TestContainsUsernameUnicodeNegative()
{
ClassicAssert.False(MessageNotifier.MatchUsername("Test ha\u0460\u0460o message", "\u0460\u0460").Success);
}
[Test]
public void TestContainsUsernameSpecialCharactersPositive()
{
ClassicAssert.True(MessageNotifier.MatchUsername("Test [#^-^#] message", "[#^-^#]").Success);
}
[Test]
public void TestContainsUsernameSpecialCharactersNegative()
{
ClassicAssert.False(MessageNotifier.MatchUsername("Test pad[#^-^#]oru message", "[#^-^#]").Success);
}
[Test]
public void TestContainsUsernameAtSign()
{
ClassicAssert.True(MessageNotifier.MatchUsername("@username hi", "username").Success);
}
[Test]
public void TestContainsUsernameColon()
{
ClassicAssert.True(MessageNotifier.MatchUsername("username: hi", "username").Success);
}
}
}