2018-09-10 03:51:38 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using osu.Framework.Allocation;
|
2018-09-16 04:35:51 +08:00
|
|
|
using osu.Framework.Configuration;
|
2018-09-10 03:51:38 +08:00
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osu.Game.Tournament.Components;
|
2018-09-21 17:51:37 +08:00
|
|
|
using osu.Game.Tournament.Screens.Ladder;
|
2018-09-10 03:51:38 +08:00
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Tests
|
|
|
|
{
|
|
|
|
public class TestCaseLadderManager : OsuTestCase
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private readonly LadderManager manager;
|
|
|
|
|
2018-09-16 04:35:51 +08:00
|
|
|
[Cached]
|
|
|
|
private Bindable<TournamentConditions> conditions = new Bindable<TournamentConditions>(new TournamentConditions { BestOf = 9 });
|
|
|
|
|
2018-09-10 03:51:38 +08:00
|
|
|
public TestCaseLadderManager()
|
|
|
|
{
|
|
|
|
var teams = JsonConvert.DeserializeObject<List<TournamentTeam>>(File.ReadAllText(@"teams.json"));
|
2018-09-15 21:13:32 +08:00
|
|
|
var ladder = File.Exists(@"bracket.json") ? JsonConvert.DeserializeObject<LadderInfo>(File.ReadAllText(@"bracket.json")) : new LadderInfo();
|
2018-09-10 03:51:38 +08:00
|
|
|
|
|
|
|
Child = manager = new LadderManager(ladder, teams);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
2018-09-16 04:35:51 +08:00
|
|
|
File.WriteAllText(@"bracket.json", JsonConvert.SerializeObject(manager.CreateInfo(),
|
2018-09-15 21:13:32 +08:00
|
|
|
new JsonSerializerSettings
|
|
|
|
{
|
|
|
|
NullValueHandling = NullValueHandling.Ignore,
|
|
|
|
DefaultValueHandling = DefaultValueHandling.Ignore
|
|
|
|
}));
|
2018-09-10 03:51:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|