2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2021-10-25 15:45:46 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Tournament.Models;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Tests.NonVisual
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class LadderInfoSerialisationTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDeserialise()
|
|
|
|
|
{
|
|
|
|
|
var ladder = createSampleLadder();
|
|
|
|
|
string serialised = JsonConvert.SerializeObject(ladder);
|
|
|
|
|
|
|
|
|
|
JsonConvert.DeserializeObject<LadderInfo>(serialised, new JsonPointConverter());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestSerialise()
|
|
|
|
|
{
|
|
|
|
|
var ladder = createSampleLadder();
|
|
|
|
|
JsonConvert.SerializeObject(ladder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static LadderInfo createSampleLadder()
|
|
|
|
|
{
|
|
|
|
|
var match = TournamentTestScene.CreateSampleMatch();
|
|
|
|
|
|
|
|
|
|
return new LadderInfo
|
|
|
|
|
{
|
|
|
|
|
PlayersPerTeam = { Value = 4 },
|
|
|
|
|
Teams =
|
|
|
|
|
{
|
2023-08-09 23:20:37 +08:00
|
|
|
|
match.Team1.Value!,
|
|
|
|
|
match.Team2.Value!,
|
2021-10-25 15:45:46 +08:00
|
|
|
|
},
|
|
|
|
|
Rounds =
|
|
|
|
|
{
|
|
|
|
|
new TournamentRound
|
|
|
|
|
{
|
|
|
|
|
Beatmaps =
|
|
|
|
|
{
|
2021-10-27 17:25:23 +08:00
|
|
|
|
new RoundBeatmap { Beatmap = TournamentTestScene.CreateSampleBeatmap() },
|
|
|
|
|
new RoundBeatmap { Beatmap = TournamentTestScene.CreateSampleBeatmap() },
|
2021-10-25 15:45:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Matches =
|
|
|
|
|
{
|
|
|
|
|
match,
|
|
|
|
|
},
|
|
|
|
|
Progressions =
|
|
|
|
|
{
|
|
|
|
|
new TournamentProgression(1, 2),
|
|
|
|
|
new TournamentProgression(1, 3, true),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|