mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add tournament LadderInfo
serialisation tests
This commit is contained in:
@ -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),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
using osu.Game.Tournament.IO;
|
using osu.Game.Tournament.IO;
|
||||||
@ -152,7 +153,16 @@ namespace osu.Game.Tournament.Tests
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static BeatmapInfo CreateSampleBeatmapInfo() =>
|
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();
|
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
Type = type;
|
Type = type;
|
||||||
BackgroundColour = OsuColour.Gray(0.2f);
|
BackgroundColour = OsuColour.Gray(0.2f);
|
||||||
Action = () => RequestSelection(type);
|
Action = () => RequestSelection?.Invoke(type);
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user