From 6549ca530480828076c7bd372cb8fec764189260 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Aug 2023 00:20:37 +0900 Subject: [PATCH] Revert some usages of `AsNonNull()` in tests We generally prefer `!` when it is unambiguous usage (ie. direct access). --- .../NonVisual/LadderInfoSerialisationTest.cs | 5 ++--- .../Screens/TestSceneMapPoolScreen.cs | 15 +++++++-------- osu.Game.Tournament.Tests/TournamentTestScene.cs | 7 +++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/osu.Game.Tournament.Tests/NonVisual/LadderInfoSerialisationTest.cs b/osu.Game.Tournament.Tests/NonVisual/LadderInfoSerialisationTest.cs index d18651b8bb..acb4a87ffc 100644 --- a/osu.Game.Tournament.Tests/NonVisual/LadderInfoSerialisationTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/LadderInfoSerialisationTest.cs @@ -3,7 +3,6 @@ using Newtonsoft.Json; using NUnit.Framework; -using osu.Framework.Extensions.ObjectExtensions; using osu.Game.Tournament.Models; namespace osu.Game.Tournament.Tests.NonVisual @@ -36,8 +35,8 @@ namespace osu.Game.Tournament.Tests.NonVisual PlayersPerTeam = { Value = 4 }, Teams = { - match.Team1.Value.AsNonNull(), - match.Team2.Value.AsNonNull(), + match.Team1.Value!, + match.Team2.Value!, }, Rounds = { diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index 254d5c6996..7b2c1ba336 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -4,7 +4,6 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Tournament.Components; @@ -31,7 +30,7 @@ namespace osu.Game.Tournament.Tests.Screens { 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++) addBeatmap(); @@ -51,7 +50,7 @@ namespace osu.Game.Tournament.Tests.Screens { 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++) addBeatmap(); @@ -71,7 +70,7 @@ namespace osu.Game.Tournament.Tests.Screens { 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++) addBeatmap(); @@ -91,7 +90,7 @@ namespace osu.Game.Tournament.Tests.Screens { 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++) 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", () => { - Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); + Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear(); for (int i = 0; i < 12; i++) 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", () => { - Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Clear(); + Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear(); for (int i = 0; i < 12; i++) 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") { - Ladder.CurrentMatch.Value.AsNonNull().Round.Value.AsNonNull().Beatmaps.Add(new RoundBeatmap + Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Add(new RoundBeatmap { Beatmap = CreateSampleBeatmap(), Mods = mods diff --git a/osu.Game.Tournament.Tests/TournamentTestScene.cs b/osu.Game.Tournament.Tests/TournamentTestScene.cs index 0cf1e22211..f24fc61d85 100644 --- a/osu.Game.Tournament.Tests/TournamentTestScene.cs +++ b/osu.Game.Tournament.Tests/TournamentTestScene.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading; using osu.Framework.Allocation; -using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Framework.Utils; @@ -41,10 +40,10 @@ namespace osu.Game.Tournament.Tests match = CreateSampleMatch(); - Ladder.Rounds.Add(match.Round.Value.AsNonNull()); + Ladder.Rounds.Add(match.Round.Value!); Ladder.Matches.Add(match); - Ladder.Teams.Add(match.Team1.Value.AsNonNull()); - Ladder.Teams.Add(match.Team2.Value.AsNonNull()); + Ladder.Teams.Add(match.Team1.Value!); + Ladder.Teams.Add(match.Team2.Value!); Ruleset.BindTo(Ladder.Ruleset); Dependencies.CacheAs(new StableInfo(storage));