1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Add tournament LadderInfo serialisation tests

This commit is contained in:
Dean Herbert 2021-10-25 16:45:46 +09:00
parent 37ec4db017
commit 7c99193ada
3 changed files with 77 additions and 2 deletions

View File

@ -0,0 +1,65 @@
// 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 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 =
{
match.Team1.Value,
match.Team2.Value,
},
Rounds =
{
new TournamentRound
{
Beatmaps =
{
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
}
}
},
Matches =
{
match,
},
Progressions =
{
new TournamentProgression(1, 2),
new TournamentProgression(1, 3, true),
}
};
}
}
}

View File

@ -8,6 +8,7 @@ using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Tests.Visual;
using osu.Game.Tournament.IO;
@ -152,7 +153,16 @@ namespace osu.Game.Tournament.Tests
};
public static BeatmapInfo CreateSampleBeatmapInfo() =>
new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } };
new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
Title = "Test Title",
Artist = "Test Artist",
ID = RNG.Next(0, 1000000)
},
OnlineInfo = new BeatmapOnlineInfo(),
};
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();

View File

@ -237,7 +237,7 @@ namespace osu.Game.Tournament
{
Type = type;
BackgroundColour = OsuColour.Gray(0.2f);
Action = () => RequestSelection(type);
Action = () => RequestSelection?.Invoke(type);
RelativeSizeAxes = Axes.X;
}