Fix crashes due to ladder re-use

This commit is contained in:
smoogipoo 2020-03-23 10:28:17 +09:00
parent b1b0bcb34d
commit 754d0ca14d
1 changed files with 15 additions and 6 deletions

View File

@ -1,10 +1,12 @@
// 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 System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Tournament.Models;
using osu.Game.Users;
@ -13,8 +15,20 @@ namespace osu.Game.Tournament.Tests
[TestFixture]
public abstract class LadderTestScene : TournamentTestScene
{
[Cached]
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
[Resolved]
protected LadderInfo Ladder { get; private set; }
private RulesetStore rulesetStore { get; set; }
[BackgroundDependencyLoader]
private void load()
{
if (Ladder.Ruleset.Value == null)
Ladder.Ruleset.Value = rulesetStore.AvailableRulesets.First();
Ruleset.BindTo(Ladder.Ruleset);
}
protected override void LoadComplete()
{
@ -22,13 +36,8 @@ protected override void LoadComplete()
TournamentMatch match = CreateSampleMatch();
Ladder.Rounds.Clear();
Ladder.Rounds.Add(match.Round.Value);
Ladder.Matches.Clear();
Ladder.Matches.Add(match);
Ladder.Teams.Clear();
Ladder.Teams.Add(match.Team1.Value);
Ladder.Teams.Add(match.Team2.Value);