1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Revert some usages of AsNonNull() in tests

We generally prefer `!` when it is unambiguous usage (ie. direct access).
This commit is contained in:
Dean Herbert 2023-08-10 00:20:37 +09:00
parent 5ad80879b7
commit 6549ca5304
3 changed files with 12 additions and 15 deletions

View File

@ -3,7 +3,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Tests.NonVisual namespace osu.Game.Tournament.Tests.NonVisual
@ -36,8 +35,8 @@ namespace osu.Game.Tournament.Tests.NonVisual
PlayersPerTeam = { Value = 4 }, PlayersPerTeam = { Value = 4 },
Teams = Teams =
{ {
match.Team1.Value.AsNonNull(), match.Team1.Value!,
match.Team2.Value.AsNonNull(), match.Team2.Value!,
}, },
Rounds = Rounds =
{ {

View File

@ -4,7 +4,6 @@
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
@ -31,7 +30,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("load few maps", () => AddStep("load few maps", () =>
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
addBeatmap(); addBeatmap();
@ -51,7 +50,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("load just enough maps", () => AddStep("load just enough maps", () =>
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 18; i++) for (int i = 0; i < 18; i++)
addBeatmap(); addBeatmap();
@ -71,7 +70,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("load many maps", () => AddStep("load many maps", () =>
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 19; i++) for (int i = 0; i < 19; i++)
addBeatmap(); addBeatmap();
@ -91,7 +90,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("load many maps", () => AddStep("load many maps", () =>
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 11; i++) for (int i = 0; i < 11; i++)
addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM");
@ -117,7 +116,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("load many maps", () => AddStep("load many maps", () =>
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM");
@ -137,7 +136,7 @@ namespace osu.Game.Tournament.Tests.Screens
{ {
AddStep("load many maps", () => AddStep("load many maps", () =>
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear();
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM");
@ -154,7 +153,7 @@ namespace osu.Game.Tournament.Tests.Screens
private void addBeatmap(string mods = "NM") private void addBeatmap(string mods = "NM")
{ {
Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Add(new RoundBeatmap Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Add(new RoundBeatmap
{ {
Beatmap = CreateSampleBeatmap(), Beatmap = CreateSampleBeatmap(),
Mods = mods Mods = mods

View File

@ -4,7 +4,6 @@
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Utils; using osu.Framework.Utils;
@ -41,10 +40,10 @@ namespace osu.Game.Tournament.Tests
match = CreateSampleMatch(); match = CreateSampleMatch();
Ladder.Rounds.Add(match.Round.Value.AsNonNull()); Ladder.Rounds.Add(match.Round.Value!);
Ladder.Matches.Add(match); Ladder.Matches.Add(match);
Ladder.Teams.Add(match.Team1.Value.AsNonNull()); Ladder.Teams.Add(match.Team1.Value!);
Ladder.Teams.Add(match.Team2.Value.AsNonNull()); Ladder.Teams.Add(match.Team2.Value!);
Ruleset.BindTo(Ladder.Ruleset); Ruleset.BindTo(Ladder.Ruleset);
Dependencies.CacheAs(new StableInfo(storage)); Dependencies.CacheAs(new StableInfo(storage));