1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Reduce test case crashes when missing data is present

This commit is contained in:
Dean Herbert 2018-10-25 01:29:08 +09:00
parent aaa8aca695
commit 5568e9ff8a
3 changed files with 23 additions and 18 deletions

View File

@ -17,9 +17,10 @@ namespace osu.Game.Tournament.Tests
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
var round = Ladder.Groupings.First(g => g.Name == "Finals"); var round = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals");
Add(new MapPoolScreen(round)); if (round != null)
Add(new MapPoolScreen(round));
} }
} }
@ -37,7 +38,7 @@ namespace osu.Game.Tournament.Tests
Padding = new MarginPadding(50), Padding = new MarginPadding(50),
Direction = FillDirection.Full, Direction = FillDirection.Full,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, }
}; };
foreach (var b in round.Beatmaps) foreach (var b in round.Beatmaps)

View File

@ -13,10 +13,10 @@ namespace osu.Game.Tournament.Tests
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
var team1 = Ladder.Teams.First(t => t.Acronym == "USA"); var team1 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA");
var team2 = Ladder.Teams.First(t => t.Acronym == "JPN"); var team2 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN");
var round = Ladder.Groupings.First(g => g.Name == "Finals"); var round = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals");
Add(new TeamIntroScreen(team1, team2, round) Add(new TeamIntroScreen(team1, team2, round)
{ {

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Video; using osu.Framework.Graphics.Video;
@ -84,7 +85,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Colour = col, Colour = col,
Text = group.Name.Value, Text = group?.Name.Value ?? "Unknown Grouping",
Font = "Exo2.0-Light", Font = "Exo2.0-Light",
Spacing = new Vector2(10, 0), Spacing = new Vector2(10, 0),
TextSize = 50, TextSize = 50,
@ -94,7 +95,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Colour = col, Colour = col,
Text = group.StartDate.Value.ToString("dd MMMM HH:mm UTC"), Text = (group?.StartDate.Value ?? DateTimeOffset.Now).ToString("dd MMMM HH:mm UTC"),
TextSize = 20, TextSize = 20,
}, },
} }
@ -134,15 +135,18 @@ namespace osu.Game.Tournament.Screens.TeamIntro
}, },
}; };
foreach (var p in team.Players) if (team != null)
players.Add(new OsuSpriteText {
{ foreach (var p in team.Players)
Text = p.Username, players.Add(new OsuSpriteText
TextSize = 24, {
Colour = colour, Text = p.Username,
Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft, TextSize = 24,
Origin = left ? Anchor.CentreRight : Anchor.CentreLeft, Colour = colour,
}); Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = left ? Anchor.CentreRight : Anchor.CentreLeft,
});
}
} }
private class TeamDisplay : DrawableTournamentTeam private class TeamDisplay : DrawableTournamentTeam
@ -168,7 +172,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Flag, Flag,
new OsuSpriteText new OsuSpriteText
{ {
Text = team.FullName.ToUpper(), Text = team?.FullName.ToUpper() ?? "???",
TextSize = 40, TextSize = 40,
Colour = Color4.Black, Colour = Color4.Black,
Font = "Exo2.0-Light", Font = "Exo2.0-Light",