mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Move UserLookupCache inside dependencies
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
// 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 osu.Game.Database;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public interface IMultiplayerRoomTestDependencies : IRoomTestDependencies
|
||||
public interface IMultiplayerTestDependencies : IOnlinePlayTestDependencies
|
||||
{
|
||||
/// <summary>
|
||||
/// The cached <see cref="MultiplayerClient"/>.
|
||||
@ -18,5 +19,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
/// The cached <see cref="IRoomManager"/>.
|
||||
/// </summary>
|
||||
new TestMultiplayerRoomManager RoomManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The cached <see cref="UserLookupCache"/>.
|
||||
/// </summary>
|
||||
TestUserLookupCache LookupCache { get; }
|
||||
}
|
||||
}
|
@ -1,21 +1,26 @@
|
||||
// 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 osu.Game.Database;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class MultiplayerRoomTestDependencies : RoomTestDependencies, IMultiplayerRoomTestDependencies
|
||||
public class MultiplayerRoomTestDependencies : RoomTestDependencies, IMultiplayerTestDependencies
|
||||
{
|
||||
public TestMultiplayerClient Client { get; }
|
||||
public TestUserLookupCache LookupCache { get; }
|
||||
public new TestMultiplayerRoomManager RoomManager => (TestMultiplayerRoomManager)base.RoomManager;
|
||||
|
||||
public MultiplayerRoomTestDependencies()
|
||||
{
|
||||
Client = new TestMultiplayerClient(RoomManager);
|
||||
LookupCache = new TestUserLookupCache();
|
||||
|
||||
CacheAs<MultiplayerClient>(Client);
|
||||
CacheAs<UserLookupCache>(LookupCache);
|
||||
}
|
||||
|
||||
protected override IRoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
|
||||
|
@ -8,13 +8,14 @@ using osu.Game.Tests.Visual.OnlinePlay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public abstract class MultiplayerTestScene : OnlinePlayTestScene
|
||||
public abstract class MultiplayerTestScene : OnlinePlayTestScene, IMultiplayerTestDependencies
|
||||
{
|
||||
public const int PLAYER_1_ID = 55;
|
||||
public const int PLAYER_2_ID = 56;
|
||||
|
||||
public TestMultiplayerClient Client => RoomDependencies.Client;
|
||||
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
|
||||
public TestUserLookupCache LookupCache => RoomDependencies?.LookupCache;
|
||||
|
||||
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
|
||||
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
|
||||
namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
{
|
||||
public interface IRoomTestDependencies
|
||||
public interface IOnlinePlayTestDependencies
|
||||
{
|
||||
/// <summary>
|
||||
/// The cached <see cref="Room"/>.
|
@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
/// <summary>
|
||||
/// A <see cref="ScreenTestScene"/> providing all the dependencies cached by <see cref="OnlinePlayScreen"/> for testing <see cref="OnlinePlaySubScreen"/>s.
|
||||
/// </summary>
|
||||
public abstract class OnlinePlayTestScene : ScreenTestScene, IRoomTestDependencies
|
||||
public abstract class OnlinePlayTestScene : ScreenTestScene, IOnlinePlayTestDependencies
|
||||
{
|
||||
public Bindable<Room> SelectedRoom => RoomDependencies?.SelectedRoom;
|
||||
public IRoomManager RoomManager => RoomDependencies?.RoomManager;
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
||||
/// <summary>
|
||||
/// Contains dependencies for testing online-play rooms.
|
||||
/// </summary>
|
||||
public class RoomTestDependencies : IReadOnlyDependencyContainer, IRoomTestDependencies
|
||||
public class RoomTestDependencies : IReadOnlyDependencyContainer, IOnlinePlayTestDependencies
|
||||
{
|
||||
public Bindable<Room> SelectedRoom { get; }
|
||||
public IRoomManager RoomManager { get; }
|
||||
|
19
osu.Game/Tests/Visual/TestUserLookupCache.cs
Normal file
19
osu.Game/Tests/Visual/TestUserLookupCache.cs
Normal file
@ -0,0 +1,19 @@
|
||||
// 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 System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestUserLookupCache : UserLookupCache
|
||||
{
|
||||
protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default) => Task.FromResult(new User
|
||||
{
|
||||
Id = lookup,
|
||||
Username = $"User {lookup}"
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user