Isolate "server-side" multiplayer rooms in testing

This commit is contained in:
Dan Balasescu
2022-06-03 19:17:31 +09:00
parent 538ad1bc98
commit 646f5f0f33
2 changed files with 12 additions and 5 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
@ -44,9 +45,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
switch (request)
{
case CreateRoomRequest createRoomRequest:
var apiRoom = new Room();
apiRoom.CopyFrom(createRoomRequest.Room);
var apiRoom = cloneRoom(createRoomRequest.Room);
// Passwords are explicitly not copied between rooms.
apiRoom.HasPassword.Value = !string.IsNullOrEmpty(createRoomRequest.Room.Password.Value);
@ -178,12 +177,13 @@ namespace osu.Game.Tests.Visual.OnlinePlay
private Room createResponseRoom(Room room, bool withParticipants)
{
var responseRoom = new Room();
responseRoom.CopyFrom(room);
var responseRoom = cloneRoom(room);
responseRoom.Password.Value = null;
if (!withParticipants)
responseRoom.RecentParticipants.Clear();
return responseRoom;
}
private Room cloneRoom(Room source) => JsonConvert.DeserializeObject<Room>(JsonConvert.SerializeObject(source));
}
}