1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +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]
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),
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.Both,
},
}
};
foreach (var b in round.Beatmaps)

View File

@ -13,10 +13,10 @@ namespace osu.Game.Tournament.Tests
[BackgroundDependencyLoader]
private void load()
{
var team1 = Ladder.Teams.First(t => t.Acronym == "USA");
var team2 = Ladder.Teams.First(t => t.Acronym == "JPN");
var team1 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA");
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)
{

View File

@ -1,6 +1,7 @@
// 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;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Video;
@ -84,7 +85,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Colour = col,
Text = group.Name.Value,
Text = group?.Name.Value ?? "Unknown Grouping",
Font = "Exo2.0-Light",
Spacing = new Vector2(10, 0),
TextSize = 50,
@ -94,7 +95,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
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,
},
}
@ -134,15 +135,18 @@ namespace osu.Game.Tournament.Screens.TeamIntro
},
};
foreach (var p in team.Players)
players.Add(new OsuSpriteText
{
Text = p.Username,
TextSize = 24,
Colour = colour,
Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = left ? Anchor.CentreRight : Anchor.CentreLeft,
});
if (team != null)
{
foreach (var p in team.Players)
players.Add(new OsuSpriteText
{
Text = p.Username,
TextSize = 24,
Colour = colour,
Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft,
Origin = left ? Anchor.CentreRight : Anchor.CentreLeft,
});
}
}
private class TeamDisplay : DrawableTournamentTeam
@ -168,7 +172,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Flag,
new OsuSpriteText
{
Text = team.FullName.ToUpper(),
Text = team?.FullName.ToUpper() ?? "???",
TextSize = 40,
Colour = Color4.Black,
Font = "Exo2.0-Light",