Tidy up test logic

This commit is contained in:
Dean Herbert 2022-09-07 16:43:48 +09:00
parent 3003fc1061
commit cb1bb99208

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -20,7 +18,7 @@ namespace osu.Game.Tests.Visual.Ranking
{ {
public class TestSceneHitEventTimingDistributionGraph : OsuTestScene public class TestSceneHitEventTimingDistributionGraph : OsuTestScene
{ {
private HitEventTimingDistributionGraph graph; private HitEventTimingDistributionGraph graph = null!;
private static readonly HitObject placeholder_object = new HitCircle(); private static readonly HitObject placeholder_object = new HitCircle();
@ -63,7 +61,12 @@ namespace osu.Game.Tests.Visual.Ranking
createTest(CreateDistributedHitEvents(0, 50).Select(h => createTest(CreateDistributedHitEvents(0, 50).Select(h =>
{ {
double offset = Math.Abs(h.TimeOffset); double offset = Math.Abs(h.TimeOffset);
var result = offset > 36 ? HitResult.Miss : offset > 32 ? HitResult.Meh : offset > 24 ? HitResult.Ok : offset > 16 ? HitResult.Good : offset > 8 ? HitResult.Great : HitResult.Perfect; HitResult result = offset > 36 ? HitResult.Miss
: offset > 32 ? HitResult.Meh
: offset > 24 ? HitResult.Ok
: offset > 16 ? HitResult.Good
: offset > 8 ? HitResult.Great
: HitResult.Perfect;
return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null); return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null);
}).ToList()); }).ToList());
} }
@ -74,13 +77,24 @@ namespace osu.Game.Tests.Visual.Ranking
var wide = CreateDistributedHitEvents(0, 50).Select(h => var wide = CreateDistributedHitEvents(0, 50).Select(h =>
{ {
double offset = Math.Abs(h.TimeOffset); double offset = Math.Abs(h.TimeOffset);
var result = offset > 36 ? HitResult.Miss : offset > 32 ? HitResult.Meh : offset > 24 ? HitResult.Ok : offset > 16 ? HitResult.Good : offset > 8 ? HitResult.Great : HitResult.Perfect; HitResult result = offset > 36 ? HitResult.Miss
: offset > 32 ? HitResult.Meh
: offset > 24 ? HitResult.Ok
: offset > 16 ? HitResult.Good
: offset > 8 ? HitResult.Great
: HitResult.Perfect;
return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null); return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null);
}); });
var narrow = CreateDistributedHitEvents(0, 50).Select(h => var narrow = CreateDistributedHitEvents(0, 50).Select(h =>
{ {
double offset = Math.Abs(h.TimeOffset); double offset = Math.Abs(h.TimeOffset);
var result = offset > 25 ? HitResult.Miss : offset > 20 ? HitResult.Meh : offset > 15 ? HitResult.Ok : offset > 10 ? HitResult.Good : offset > 5 ? HitResult.Great : HitResult.Perfect; HitResult result = offset > 25 ? HitResult.Miss
: offset > 20 ? HitResult.Meh
: offset > 15 ? HitResult.Ok
: offset > 10 ? HitResult.Good
: offset > 5 ? HitResult.Great
: HitResult.Perfect;
return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null); return new HitEvent(h.TimeOffset, result, placeholder_object, placeholder_object, null);
}); });
createTest(wide.Concat(narrow).ToList()); createTest(wide.Concat(narrow).ToList());