osu/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayer.cs

48 lines
1.5 KiB
C#
Raw Normal View History

2020-12-21 09:42:31 +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.
2020-12-23 20:00:47 +00:00
using NUnit.Framework;
using osu.Game.Screens.OnlinePlay.Components;
2020-12-23 20:00:47 +00:00
using osu.Game.Users;
2020-12-21 09:42:31 +00:00
namespace osu.Game.Tests.Visual.Multiplayer
2020-12-21 09:42:31 +00:00
{
2020-12-25 04:38:11 +00:00
public class TestSceneMultiplayer : MultiplayerTestScene
2020-12-21 09:42:31 +00:00
{
2020-12-25 04:38:11 +00:00
public TestSceneMultiplayer()
2020-12-21 09:42:31 +00:00
{
2020-12-25 04:38:11 +00:00
var multi = new TestMultiplayer();
2020-12-21 09:42:31 +00:00
AddStep("show", () => LoadScreen(multi));
AddUntilStep("wait for loaded", () => multi.IsLoaded);
}
2020-12-23 20:00:47 +00:00
[Test]
public void TestOneUserJoinedMultipleTimes()
{
var user = new User { Id = 33 };
AddRepeatStep("add user multiple times", () => Client.AddUser(user), 3);
AddAssert("room has 2 users", () => Client.Room?.Users.Count == 2);
}
[Test]
public void TestOneUserLeftMultipleTimes()
{
var user = new User { Id = 44 };
AddStep("add user", () => Client.AddUser(user));
AddAssert("room has 2 users", () => Client.Room?.Users.Count == 2);
AddRepeatStep("remove user multiple times", () => Client.RemoveUser(user), 3);
AddAssert("room has 1 user", () => Client.Room?.Users.Count == 1);
}
private class TestMultiplayer : Screens.OnlinePlay.Multiplayer.Multiplayer
2020-12-21 09:42:31 +00:00
{
2020-12-25 04:38:11 +00:00
protected override RoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
2020-12-21 09:42:31 +00:00
}
}
}