diff --git a/osu.Game.Tests/Resources/TestResources.cs b/osu.Game.Tests/Resources/TestResources.cs
index a77dc8d49b..e0572e604c 100644
--- a/osu.Game.Tests/Resources/TestResources.cs
+++ b/osu.Game.Tests/Resources/TestResources.cs
@@ -73,7 +73,12 @@ namespace osu.Game.Tests.Resources
private static string getTempFilename() => temp_storage.GetFullPath(Guid.NewGuid() + ".osz");
- private static int importId;
+ private static int testId = 1;
+
+ ///
+ /// Get a unique int value which is incremented each call.
+ ///
+ public static int GetNextTestID() => Interlocked.Increment(ref testId);
///
/// Create a test beatmap set model.
@@ -88,7 +93,7 @@ namespace osu.Game.Tests.Resources
RulesetInfo getRuleset() => rulesets?[j++ % rulesets.Length];
- int setId = Interlocked.Increment(ref importId);
+ int setId = GetNextTestID();
var metadata = new BeatmapMetadata
{
diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
index 3306b6624e..ad7e211354 100644
--- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
+++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs
@@ -139,8 +139,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void addRandomPlayer()
{
- int randomUser = RNG.Next(200000, 500000);
- multiplayerClient.AddUser(new APIUser { Id = randomUser, Username = $"user {randomUser}" });
+ int id = TestResources.GetNextTestID();
+ multiplayerClient.AddUser(new APIUser { Id = id, Username = $"user {id}" });
}
private void removeLastUser()
diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelList.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelList.cs
index a0cca5f53d..5f77e084da 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneChannelList.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneChannelList.cs
@@ -9,13 +9,13 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
-using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Overlays;
using osu.Game.Overlays.Chat.ChannelList;
using osu.Game.Overlays.Chat.Listing;
+using osu.Game.Tests.Resources;
namespace osu.Game.Tests.Visual.Online
{
@@ -160,7 +160,7 @@ namespace osu.Game.Tests.Visual.Online
private Channel createRandomPublicChannel()
{
- int id = RNG.Next(0, 10000);
+ int id = TestResources.GetNextTestID();
return new Channel
{
Name = $"#channel-{id}",
@@ -171,7 +171,7 @@ namespace osu.Game.Tests.Visual.Online
private Channel createRandomPrivateChannel()
{
- int id = RNG.Next(0, 10000);
+ int id = TestResources.GetNextTestID();
return new Channel(new APIUser
{
Id = id,
@@ -181,7 +181,7 @@ namespace osu.Game.Tests.Visual.Online
private Channel createRandomAnnounceChannel()
{
- int id = RNG.Next(0, 10000);
+ int id = TestResources.GetNextTestID();
return new Channel
{
Name = $"Announce {id}",
diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
index 372cf60853..a47205094e 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
@@ -32,6 +32,7 @@ using osu.Game.Overlays.Chat.ChannelList;
using osuTK;
using osuTK.Input;
using osu.Game.Graphics.UserInterfaceV2;
+using osu.Game.Tests.Resources;
namespace osu.Game.Tests.Visual.Online
{
@@ -121,7 +122,7 @@ namespace osu.Game.Tests.Visual.Online
return true;
case PostMessageRequest postMessage:
- postMessage.TriggerSuccess(new Message(getNextTestID())
+ postMessage.TriggerSuccess(new Message(TestResources.GetNextTestID())
{
Content = postMessage.Message.Content,
ChannelId = postMessage.Message.ChannelId,
@@ -718,7 +719,7 @@ namespace osu.Game.Tests.Visual.Online
private Channel createPrivateChannel()
{
- int id = getNextTestID();
+ int id = TestResources.GetNextTestID();
return new Channel(new APIUser
{
@@ -739,10 +740,6 @@ namespace osu.Game.Tests.Visual.Online
};
}
- private static int testId = DummyAPIAccess.DUMMY_USER_ID + 1;
-
- private static int getNextTestID() => Interlocked.Increment(ref testId);
-
private partial class TestChatOverlay : ChatOverlay
{
public bool SlowLoading { get; set; }