Skip to content

Commit

Permalink
Revert some usages of AsNonNull() in tests
Browse files Browse the repository at this point in the history
We generally prefer `!` when it is unambiguous usage (ie. direct access).
  • Loading branch information
peppy committed Aug 9, 2023
1 parent 5ad8087 commit 6549ca5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -36,8 +35,8 @@ private static LadderInfo createSampleLadder()
PlayersPerTeam = { Value = 4 },
Teams =
{
match.Team1.Value.AsNonNull(),
match.Team2.Value.AsNonNull(),
match.Team1.Value!,
match.Team2.Value!,
},
Rounds =
{
Expand Down
15 changes: 7 additions & 8 deletions osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +30,7 @@ public void TestFewMaps()
{
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();
Expand All @@ -51,7 +50,7 @@ public void TestJustEnoughMaps()
{
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();
Expand All @@ -71,7 +70,7 @@ public void TestManyMaps()
{
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();
Expand All @@ -91,7 +90,7 @@ public void TestJustEnoughMods()
{
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");
Expand All @@ -117,7 +116,7 @@ public void TestManyMods()
{
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");
Expand All @@ -137,7 +136,7 @@ public void TestSplitMapPoolByMods()
{
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");
Expand All @@ -154,7 +153,7 @@ public void TestSplitMapPoolByMods()

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
Expand Down
7 changes: 3 additions & 4 deletions osu.Game.Tournament.Tests/TournamentTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,10 +40,10 @@ private void load(TournamentStorage storage)

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));
Expand Down

0 comments on commit 6549ca5

Please sign in to comment.